From: Nick Porter Date: Wed, 30 Aug 2023 09:14:01 +0000 (+0100) Subject: Convert %(chap_password:) to a module xlat so we can pass in the instance data X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77f303afc4a4d70d00dc531104d0b483c5432cfa;p=thirdparty%2Ffreeradius-server.git Convert %(chap_password:) to a module xlat so we can pass in the instance data --- diff --git a/src/modules/rlm_chap/rlm_chap.c b/src/modules/rlm_chap/rlm_chap.c index 0aaed886e32..68d8ed373b3 100644 --- a/src/modules/rlm_chap/rlm_chap.c +++ b/src/modules/rlm_chap/rlm_chap.c @@ -78,7 +78,7 @@ static xlat_arg_parser_t const xlat_func_chap_password_args[] = { * * Example: @verbatim -"%(chap_password:)" == 0x +"%(chap.password:)" == 0x @endverbatim * * @ingroup xlat_functions @@ -295,21 +295,17 @@ static int mod_instantiate(module_inst_ctx_t const *mctx) return 0; } -static int mod_load(void) +static int mod_bootstrap(module_inst_ctx_t const *mctx) { xlat_t *xlat; - if (unlikely((xlat = xlat_func_register(NULL, "chap_password", xlat_func_chap_password, FR_TYPE_OCTETS)) == NULL)) return -1; + if (unlikely((xlat = xlat_func_register_module(NULL, mctx, "password", xlat_func_chap_password, + FR_TYPE_OCTETS)) == NULL)) return -1; xlat_func_args_set(xlat, xlat_func_chap_password_args); return 0; } -static void mod_unload(void) -{ - xlat_func_unregister("chap_password"); -} - /* * The module name should be the only globally exported symbol. * That is, everything else should be 'static'. @@ -325,8 +321,7 @@ module_rlm_t rlm_chap = { .magic = MODULE_MAGIC_INIT, .name = "chap", .inst_size = sizeof(rlm_chap_t), - .onload = mod_load, - .unload = mod_unload, + .bootstrap = mod_bootstrap, .config = module_config, .instantiate = mod_instantiate }, diff --git a/src/modules/rlm_radius/test_plan.adoc b/src/modules/rlm_radius/test_plan.adoc index bb645758cc5..d4dca7dd8a7 100644 --- a/src/modules/rlm_radius/test_plan.adoc +++ b/src/modules/rlm_radius/test_plan.adoc @@ -45,7 +45,7 @@ Class = 0x69616D616E6F706171756576616C756569616D616E6F706171756576616C7565 ==== CHAP Access-Request - unlang ``` User-Name = "testuser" -Chap-Password = %(chap_password:supersecret) +Chap-Password = %(chap.password:supersecret) Service-Type = Framed-User NAS-IP-Address = 127.0.0.1 Tunnel-Password = "supersecret" diff --git a/src/tests/auth/chap b/src/tests/auth/chap index 580f197e176..9f53bed3fb4 100644 --- a/src/tests/auth/chap +++ b/src/tests/auth/chap @@ -5,4 +5,4 @@ # # Set CHAP-Password # -&CHAP-Password := "%(chap_password:%{CHAP-Password})" +&CHAP-Password := "%(chap.password:%{CHAP-Password})" diff --git a/src/tests/auth/chap_header b/src/tests/auth/chap_header index 58fab442478..bfabd951af0 100644 --- a/src/tests/auth/chap_header +++ b/src/tests/auth/chap_header @@ -10,4 +10,4 @@ # # Set CHAP-Password # -&request.CHAP-Password := "%(chap_password:%{request.CHAP-Password})" +&request.CHAP-Password := "%(chap.password:%{request.CHAP-Password})" diff --git a/src/tests/modules/chap/chap_password.unlang b/src/tests/modules/chap/chap_password.unlang index ec943811385..ac2f35bc753 100644 --- a/src/tests/modules/chap/chap_password.unlang +++ b/src/tests/modules/chap/chap_password.unlang @@ -2,7 +2,7 @@ &CHAP-Challenge := 0x0102030405060708090a0b0c0d0e0f10 &control.Password.Cleartext := "supersecret" -&CHAP-Password := "%(chap_password:%{control.Password.Cleartext})" +&CHAP-Password := "%(chap.password:%{control.Password.Cleartext})" chap.authenticate if (ok) {