snprintf(dl_name, sizeof(dl_name), "libfreeradius-%s", proto_name);
if (dl) TALLOC_FREE(dl);
- dl = dl_by_name(dl_loader, dl_name, NULL, false);
+ dl = dl_by_name(dl_loader, dl_name, NULL, false, false);
if (!dl) {
fprintf(stderr, "Failed to link to library \"%s\": %s\n", dl_name, fr_strerror());
unload_proto_library();
static dl_module_loader_t *dl_module_loader;
+/** Modules which need RTLD_GLOBAL set
+ *
+ */
+static fr_table_num_sorted_t const dl_module_sym_global[] = {
+ { "rlm_perl", true }
+};
+static size_t dl_module_sym_global_len = NUM_ELEMENTS(dl_module_sym_global);
+
/** Name prefixes matching the types of loadable module
*/
static fr_table_num_sorted_t const dl_module_type_prefix[] = {
* Pass in dl_module as the uctx so that
* we can get at it in any callbacks.
*/
- dl = dl_by_name(dl_module_loader->dl_loader, module_name, dl_module, false);
+ dl = dl_by_name(dl_module_loader->dl_loader, module_name, dl_module, false,
+ fr_table_value_by_str(dl_module_sym_global, module_name, false));
if (!dl) {
cf_log_perr(conf, "Failed to link to module \"%s\"", module_name);
cf_log_err(conf, "Make sure it (and all its dependent libraries!) are in the search path"
* @param[in] dl_loader Tree of dynamically loaded libraries, and callbacks.
* @param[in] name of library to load. May be a relative path.
* @param[in] uctx Data to store within the dl_t.
- * @param[in] uctx_free Free the uctx data if this dl_t is freed.
+ * @param[in] uctx_free talloc_free the passed in uctx data if this
+ * dl_t is freed.
+ * @param[in] sym_global Set RTLD_GLOBAL to place all symbols from the module
+ * in the global symbol table.
* @return
* - A new dl_t on success, or a pointer to an existing
* one with the reference count increased.
* - NULL on error.
*/
-dl_t *dl_by_name(dl_loader_t *dl_loader, char const *name, void *uctx, bool uctx_free)
+dl_t *dl_by_name(dl_loader_t *dl_loader, char const *name, void *uctx, bool uctx_free,
+#ifdef RTLD_GLOBAL
+ bool sym_global)
+#else
+ UNUSED bool sym_global)
+#endif
{
int flags = RTLD_NOW;
void *handle = NULL;
}
#ifdef RTLD_GLOBAL
- if (strcmp(name, "rlm_perl") == 0) {
+ if (sym_global) {
flags |= RTLD_GLOBAL;
} else
#endif
char const *symbol, dl_unload_t func);
dl_t *dl_by_name(dl_loader_t *dl_loader, char const *name,
- void *uctx, bool uctx_free);
+ void *uctx, bool uctx_free, bool sym_global);
char const *dl_search_path(dl_loader_t *dl_loader);