]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Print useful errors when autoloaders fail
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 15 Mar 2024 02:10:23 +0000 (22:10 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 15 Mar 2024 02:10:54 +0000 (22:10 -0400)
Not sure when this stopped working...

src/lib/server/dl_module.c
src/lib/util/dict_util.c
src/lib/util/dl.c

index 6bde7c3e9495285709629f78b4144b7b1d28dcbd..11671f5e962fdb53289587721defa3607be2b2a9 100644 (file)
@@ -664,6 +664,42 @@ dl_loader_t *dl_loader_from_module_loader(dl_module_loader_t *dl_module_l)
        return dl_module_l->dl_loader;
 }
 
+/** Wrapper to log errors
+ */
+static int dl_dict_enum_autoload(dl_t const *module, void *symbol, void *user_ctx)
+{
+       int ret;
+
+       ret = fr_dl_dict_enum_autoload(module, symbol, user_ctx);
+       if (ret < 0) PERROR("Failed autoloading enum value for \"%s\"", module->name);
+
+       return ret;
+}
+
+/** Wrapper to log errors
+ */
+static int dl_dict_attr_autoload(dl_t const *module, void *symbol, void *user_ctx)
+{
+       int ret;
+
+       ret = fr_dl_dict_attr_autoload(module, symbol, user_ctx);
+       if (ret < 0) PERROR("Failed autoloading attribute for \"%s\"", module->name);
+
+       return ret;
+}
+
+/** Wrapper to log errors
+ */
+static int dl_dict_autoload(dl_t const *module, void *symbol, void *user_ctx)
+{
+       int ret;
+
+       ret = fr_dl_dict_autoload(module, symbol, user_ctx);
+       if (ret < 0) PERROR("Failed autoloading dictionary for \"%s\"", module->name);
+
+       return ret;
+}
+
 /** Initialise structures needed by the dynamic linker
  *
  */
@@ -725,11 +761,11 @@ dl_module_loader_t *dl_module_loader_init(char const *lib_dir)
         *      Register dictionary autoload callbacks
         */
        dl_symbol_init_cb_register(dl_module_loader->dl_loader,
-                                  DL_PRIORITY_DICT_ENUM, "dict_enum", fr_dl_dict_enum_autoload, NULL);
+                                  DL_PRIORITY_DICT_ENUM, "dict_enum", dl_dict_enum_autoload, NULL);
        dl_symbol_init_cb_register(dl_module_loader->dl_loader,
-                                  DL_PRIORITY_DICT_ATTR, "dict_attr", fr_dl_dict_attr_autoload, NULL);
+                                  DL_PRIORITY_DICT_ATTR, "dict_attr", dl_dict_attr_autoload, NULL);
        dl_symbol_init_cb_register(dl_module_loader->dl_loader,
-                                  DL_PRIORITY_DICT, "dict", fr_dl_dict_autoload, NULL);
+                                  DL_PRIORITY_DICT, "dict", dl_dict_autoload, NULL);
        dl_symbol_free_cb_register(dl_module_loader->dl_loader,
                                   DL_PRIORITY_DICT, "dict", fr_dl_dict_autofree, NULL);
 
index 2f16cc94e0e0f22a4452c0e6b4407e950881e327..be45c6c79b638a31de8dc2b9a2fe27043983bc87 100644 (file)
@@ -3612,12 +3612,12 @@ int fr_dict_enum_autoload(fr_dict_enum_autoload_t const *to_load)
 
        for (p = to_load; p->out; p++) {
                if (unlikely(!p->attr)) {
-                       fr_strerror_const("Invalid autoload entry, missing attribute pointer");
+                       fr_strerror_printf("Invalid attribute autoload entry for \"%s\", missing attribute pointer", p->name);
                        return -1;
                }
 
                if (unlikely(!*p->attr)) {
-                       fr_strerror_printf("Can't resolve value '%s', attribute not loaded", p->name);
+                       fr_strerror_printf("Can't resolve value \"%s\", attribute not loaded", p->name);
                        fr_strerror_printf_push("Check fr_dict_attr_autoload_t struct has "
                                                "an entry to load the attribute \"%s\" is located in, and that "
                                                "the fr_dict_autoload_attr_t symbol name is correct", p->name);
@@ -3651,7 +3651,7 @@ int fr_dict_attr_autoload(fr_dict_attr_autoload_t const *to_load)
 
        for (p = to_load; p->out; p++) {
                if (!p->dict) {
-                       fr_strerror_const("Invalid autoload entry, missing dictionary pointer");
+                       fr_strerror_printf("Invalid attribute autoload entry for \"%s\", missing dictionary pointer", p->name);
                        return -1;
                }
 
index 43c52869fe1bd34157752d17e7aba92a5d548ca1..37717f9f82c82f4dbd6ede12de7e9f66a357e939 100644 (file)
@@ -258,7 +258,7 @@ int dl_symbol_init(dl_loader_t *dl_loader, dl_t const *dl)
                }
 
                if (init->func(dl, sym, init->uctx) < 0) {
-                       fr_strerror_printf("Iinitialiser \"%s\" failed", buffer);
+                       fr_strerror_printf("Initialiser \"%s\" failed", buffer);
                        return -1;
                }
        }