]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Convert %(chap_password:) to a module xlat so we can pass in the instance data
authorNick Porter <nick@portercomputing.co.uk>
Wed, 30 Aug 2023 09:14:01 +0000 (10:14 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Wed, 30 Aug 2023 09:14:01 +0000 (10:14 +0100)
src/modules/rlm_chap/rlm_chap.c
src/modules/rlm_radius/test_plan.adoc
src/tests/auth/chap
src/tests/auth/chap_header
src/tests/modules/chap/chap_password.unlang

index 0aaed886e329dca6190df894589ab96ab1346d45..68d8ed373b37bcc864d07bd3e3c05beaac31e566 100644 (file)
@@ -78,7 +78,7 @@ static xlat_arg_parser_t const xlat_func_chap_password_args[] = {
  *
  * Example:
 @verbatim
-"%(chap_password:<password>)" == 0x<id><md5_hash>
+"%(chap.password:<password>)" == 0x<id><md5_hash>
 @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
        },
index bb645758cc51c3590b312e51794103349c2b6809..d4dca7dd8a74766daf9860cec8d712066c4bfec0 100644 (file)
@@ -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"
index 580f197e1766b0873e1e4eb82be6d2d79ea1f4ab..9f53bed3fb4b067675082a834b38982741b429a4 100644 (file)
@@ -5,4 +5,4 @@
 #
 #  Set CHAP-Password
 #
-&CHAP-Password := "%(chap_password:%{CHAP-Password})"
+&CHAP-Password := "%(chap.password:%{CHAP-Password})"
index 58fab442478ac0c38bf30233b4e2f4b326c61da5..bfabd951af0cb3b69eb05bcc6870a9fa849b8995 100644 (file)
@@ -10,4 +10,4 @@
 #
 #  Set CHAP-Password
 #
-&request.CHAP-Password := "%(chap_password:%{request.CHAP-Password})"
+&request.CHAP-Password := "%(chap.password:%{request.CHAP-Password})"
index ec943811385fee45ab92f689132a5e9a30321c41..ac2f35bc7538f68bedfdb20287a953a643bc343c 100644 (file)
@@ -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) {