]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Move stupid perl hack to where it should be
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 26 Aug 2019 21:28:04 +0000 (17:28 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 26 Aug 2019 21:28:04 +0000 (17:28 -0400)
src/bin/unit_test_attribute.c
src/lib/server/dl_module.c
src/lib/util/dl.c
src/lib/util/dl.h

index 7d2e73a51b0a7858268f83e0faed9abf089ba93b..1dee5ad1cd34086933784589f58570b2f6999917 100644 (file)
@@ -608,7 +608,7 @@ static ssize_t load_proto_library(char const *proto_name)
                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();
index c65e4435bc2ab5e0c6a8f70547de3abfacbe6c56..8e75c6fcf39e6c90d4a0912ea8dd0c914ee5247d 100644 (file)
@@ -52,6 +52,14 @@ struct dl_module_loader_s {
 
 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[] = {
@@ -341,7 +349,8 @@ dl_module_t const *dl_module(CONF_SECTION *conf, dl_module_t const *parent, char
         *      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"
index 3e9a9aa03abb2566b9ada453f53d65f83a2ecf2f..a6e0a8a22fc054aeeb9befd4ed3a2df7b05118d7 100644 (file)
@@ -377,13 +377,21 @@ static int _dl_free(dl_t *dl)
  * @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;
@@ -401,7 +409,7 @@ dl_t *dl_by_name(dl_loader_t *dl_loader, char const *name, void *uctx, bool uctx
        }
 
 #ifdef RTLD_GLOBAL
-       if (strcmp(name, "rlm_perl") == 0) {
+       if (sym_global) {
                flags |= RTLD_GLOBAL;
        } else
 #endif
index de0a71cdaeba311f3d498d578873a0e8688ecfb2..11472618e14bcc3debd4b2ac703d61f5bcf34033 100644 (file)
@@ -104,7 +104,7 @@ void                        dl_symbol_free_cb_unregister(dl_loader_t *dl_loader,
                                                     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);