]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Correct registration of rlm_unpack xlat
authorNick Porter <nick@portercomputing.co.uk>
Fri, 19 May 2023 16:17:18 +0000 (17:17 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 19 May 2023 18:35:45 +0000 (14:35 -0400)
src/modules/rlm_unpack/rlm_unpack.c

index 5a0ba45024c6ea5d5763facae85bd90aa1a11556..3f9208d4c870b689aabd64b935c11a4eb9a3806c 100644 (file)
@@ -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
        }
 };