From: Arran Cudbard-Bell Date: Fri, 15 Mar 2024 02:10:23 +0000 (-0400) Subject: Print useful errors when autoloaders fail X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0bf29e7d4b354dd5867a4bd9b5335fa7efccb92;p=thirdparty%2Ffreeradius-server.git Print useful errors when autoloaders fail Not sure when this stopped working... --- diff --git a/src/lib/server/dl_module.c b/src/lib/server/dl_module.c index 6bde7c3e949..11671f5e962 100644 --- a/src/lib/server/dl_module.c +++ b/src/lib/server/dl_module.c @@ -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); diff --git a/src/lib/util/dict_util.c b/src/lib/util/dict_util.c index 2f16cc94e0e..be45c6c79b6 100644 --- a/src/lib/util/dict_util.c +++ b/src/lib/util/dict_util.c @@ -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; } diff --git a/src/lib/util/dl.c b/src/lib/util/dl.c index 43c52869fe1..37717f9f82c 100644 --- a/src/lib/util/dl.c +++ b/src/lib/util/dl.c @@ -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; } }