From: Nick Porter Date: Fri, 19 May 2023 16:17:18 +0000 (+0100) Subject: Correct registration of rlm_unpack xlat X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54879db532db2d26b7fa5317ca8d37f9e07836d1;p=thirdparty%2Ffreeradius-server.git Correct registration of rlm_unpack xlat --- diff --git a/src/modules/rlm_unpack/rlm_unpack.c b/src/modules/rlm_unpack/rlm_unpack.c index 5a0ba45024c..3f9208d4c87 100644 --- a/src/modules/rlm_unpack/rlm_unpack.c +++ b/src/modules/rlm_unpack/rlm_unpack.c @@ -130,19 +130,22 @@ static xlat_action_t unpack_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, /* * Register the xlats */ -static int mod_bootstrap(module_inst_ctx_t const *mctx) +static int mod_load(void) { xlat_t *xlat; - xlat = xlat_func_register_module(NULL, mctx, "unpack", unpack_xlat, FR_TYPE_VOID); - if (xlat) { - xlat_func_args_set(xlat, unpack_xlat_args); - xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE); - } + if (unlikely(!(xlat = xlat_func_register(NULL, "unpack", unpack_xlat, FR_TYPE_VOID)))) return -1; + xlat_func_args_set(xlat, unpack_xlat_args); + xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE); return 0; } +static void mod_unload(void) +{ + xlat_func_unregister("unpack"); +} + /* * The module name should be the only globally exported symbol. * That is, everything else should be 'static'. @@ -158,6 +161,7 @@ module_rlm_t rlm_unpack = { .magic = MODULE_MAGIC_INIT, .name = "unpack", .type = MODULE_TYPE_THREAD_SAFE, - .bootstrap = mod_bootstrap + .onload = mod_load, + .unload = mod_unload } };