From 3e046ccabfe7dff97d3f8e64716852efed311390 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Mon, 10 Aug 2020 15:46:47 -0400 Subject: [PATCH] [core] dlsym for FAMNoExists() for compat w/ fam gamin should be used instead of fam; fam is no longer maintained This patch makes it safe to build lighttpd with gamin, but run on systems with the (deprecated) fam installed, which can happen due to historical package dependency declarations on some platforms (Debian, Ubuntu). gamin and fam are not 100% binary compatible. (Among other things, fam does not provide FAMNoExists()) x-ref: "llibgamin vs libfam conflict solving" https://salsa.debian.org/debian/lighttpd/-/merge_requests/18 "libgamin0: libfam shlib dependency wrongly set to libfam0" https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=510368 "undefined symbol: FAMNoExists" https://bugs.launchpad.net/bugs/1453463 --- src/stat_cache.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/stat_cache.c b/src/stat_cache.c index add0207c..fd9416b0 100644 --- a/src/stat_cache.c +++ b/src/stat_cache.c @@ -125,6 +125,12 @@ static void * stat_cache_sptree_find(splay_tree ** const sptree, #include +#ifdef HAVE_FAMNOEXISTS +#ifndef LIGHTTPD_STATIC +#include +#endif +#endif + typedef struct fam_dir_entry { buffer *name; int refcnt; @@ -364,7 +370,14 @@ static stat_cache_fam * stat_cache_init_fam(fdevents *ev, log_error_st *errh) { return NULL; } #ifdef HAVE_FAMNOEXISTS + #ifdef LIGHTTPD_STATIC FAMNoExists(&scf->fam); + #else + int (*FAMNoExists_fn)(FAMConnection *); + FAMNoExists_fn = + (int (*)(FAMConnection *))(intptr_t)dlsym(RTLD_DEFAULT,"FAMNoExists"); + if (FAMNoExists_fn) FAMNoExists_fn(&scf->fam); + #endif #endif scf->fd = FAMCONNECTION_GETFD(&scf->fam);