From: Alan T. DeKok Date: Sat, 5 Sep 2009 16:17:26 +0000 (+0200) Subject: First stab at removing libltdl. X-Git-Tag: release_2_1_7~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10c6aa455fc8753a3ea279968dabbde41c335faa;p=thirdparty%2Ffreeradius-server.git First stab at removing libltdl. The code is protected by preprocessor directives so that it doesn't affect the release. But it's a good first step to removing insanity. --- diff --git a/src/include/modpriv.h b/src/include/modpriv.h index 818f73aadc2..d73e5212a59 100644 --- a/src/include/modpriv.h +++ b/src/include/modpriv.h @@ -12,12 +12,12 @@ typedef void *lt_dlhandle; lt_dlhandle lt_dlopenext(const char *name); void *lt_dlsym(lt_dlhandle handle, const char *symbol); +int lt_dlclose(lt_dlhandle handle); +const char *lt_dlerror(void); #define LTDL_SET_PRELOADED_SYMBOLS(_x) #define lt_dlinit(_x) (0) -#define lt_dlclose(_x) #define lt_dlexit(_x) -#define lt_dlerror(foo) "Internal error" #define lt_dlsetsearchpath(_x) #endif diff --git a/src/main/modules.c b/src/main/modules.c index 0a77269121e..6682ab79cb3 100644 --- a/src/main/modules.c +++ b/src/main/modules.c @@ -94,42 +94,84 @@ static const section_type_value_t section_type_value[RLM_COMPONENT_COUNT] = { #ifdef WITHOUT_LIBLTDL +#ifdef WITH_DLOPEN +#include + +#ifndef RTLD_NOW +#define RTLD_NOW (0) +#endif +#ifndef RTLD_LOCAL +#define RTLD_LOCAL (0) +#endif + +lt_dlhandle lt_dlopenext(const char *name) +{ + char buffer[256]; + + strlcpy(buffer, name, sizeof(buffer)); + + /* + * FIXME: Make this configurable... + */ + strlcat(buffer, ".so", sizeof(buffer)); + + return dlopen(buffer, RTLD_NOW | RTLD_LOCAL); +} + +void *lt_dlsym(lt_dlhandle handle, UNUSED const char *symbol) +{ + return dlsym(handle, symbol); +} + +int lt_dlclose(lt_dlhandle handle) +{ + return dlclose(handle); +} + +const char *lt_dlerror(void) +{ + return dlerror(); +} + + +#else /* without dlopen */ typedef struct lt_dlmodule_t { const char *name; void *ref; } lt_dlmodule_t; +typedef struct eap_type_t EAP_TYPE; +typedef struct rlm_sql_module_t rlm_sql_module_t; + /* - * Define modules here. + * FIXME: Write hackery to auto-generate this data. + * We only need to do this on systems that don't have dlopen. */ extern module_t rlm_pap; extern module_t rlm_chap; extern module_t rlm_eap; +extern module_t rlm_sql; +/* and so on ... */ -/* - * EAP structures are defined elsewhere. - */ -typedef struct eap_type_t EAP_TYPE; - -/* - * And so on for other EAP types. - */ extern EAP_TYPE rlm_eap_md5; +extern rlm_sql_module_t rlm_sql_mysql; +/* and so on ... */ static const lt_dlmodule_t lt_dlmodules[] = { { "rlm_pap", &rlm_pap }, { "rlm_chap", &rlm_chap }, { "rlm_eap", &rlm_eap }, + /* and so on ... */ + { "rlm_eap_md5", &rlm_eap_md5 }, - - /* - * Add other modules here. - */ + /* and so on ... */ + + { "rlm_sql_mysql", &rlm_sql_mysql }, + /* and so on ... */ { NULL, NULL } }; - lt_dlhandle lt_dlopenext(const char *name) { int i; @@ -147,6 +189,18 @@ void *lt_dlsym(lt_dlhandle handle, UNUSED const char *symbol) { return handle; } + +int lt_dlclose(lt_dlhandle handle) +{ + return 0; +} + +const char *lt_dlerror(void) +{ + return "Unspecified error"; +} + +#endif /* WITH_DLOPEN */ #endif /* WITHOUT_LIBLTDL */ static int virtual_server_idx(const char *name)