From: Nick Porter Date: Tue, 31 Oct 2023 08:56:07 +0000 (+0000) Subject: Use new xlat function syntax in inline comments X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ef6460da47a1175c7029f5042c56b6cd90d6a9d;p=thirdparty%2Ffreeradius-server.git Use new xlat function syntax in inline comments --- diff --git a/src/lib/eap_aka_sim/xlat.c b/src/lib/eap_aka_sim/xlat.c index 1805a8f34cf..79070b05c56 100644 --- a/src/lib/eap_aka_sim/xlat.c +++ b/src/lib/eap_aka_sim/xlat.c @@ -41,7 +41,7 @@ static xlat_arg_parser_t const aka_sim_xlat_id_method_xlat_args[] = { /** Returns the SIM method EAP-SIM or EAP-AKA hinted at by the user identifier * @verbatim -%(aka_sim_id_method:%{id_attr}) +%aka_sim_id_method(%{id_attr}) @endverbatim * * @ingroup xlat_functions @@ -98,7 +98,7 @@ static xlat_arg_parser_t const aka_sim_xlat_id_type_xlat_args[] = { /** Returns the type of identity used * @verbatim -%(aka_sim_id_type:%{id_attr}) +%aka_sim_id_type(%{id_attr}) @endverbatim * * @ingroup xlat_functions @@ -154,7 +154,7 @@ static xlat_arg_parser_t const aka_sim_id_3gpp_temporary_id_key_index_xlat_args[ /** Returns the key index from a 3gpp temporary id * @verbatim -%(3gpp_temporary_id_key_index:%{id_attr}) +%3gpp_temporary_id_key_index(%{id_attr}) @endverbatim * * @ingroup xlat_functions @@ -193,7 +193,7 @@ xlat_arg_parser_t aka_sim_3gpp_temporary_id_decrypt_xlat_args[] = { /** Decrypt a 3gpp temporary id * @verbatim - %(3gpp_temporary_id_decrypt: ) + %3gpp_temporary_id_decrypt( ) @endverbatim * * The pseudonym is in the format @@ -337,7 +337,7 @@ xlat_arg_parser_t aka_sim_3gpp_temporary_id_encrypt_xlat_args[] = { /** Encrypts a 3gpp pseudonym * @verbatim -%(3gpp_temporary_id_encrypt: [(pseudonym|fastauth)]) +%3gpp_temporary_id_encrypt(, , , [(pseudonym|fastauth)]) @endverbatim * * @ingroup xlat_functions diff --git a/src/lib/server/main_config.c b/src/lib/server/main_config.c index 8e2deae6180..89a38ad358d 100644 --- a/src/lib/server/main_config.c +++ b/src/lib/server/main_config.c @@ -556,7 +556,7 @@ static xlat_arg_parser_t const xlat_config_args[] = { /** xlat to get config values * @verbatim -%(config:section.subsection.attribute) +%config(section.subsection.attribute) @endverbatim * * @ingroup xlat_functions @@ -1390,7 +1390,7 @@ do {\ if (!client_list_parse_section(cs, 0, false)) goto failure; /* - * Register the %(config:section.subsection) xlat function. + * Register the %config(section.subsection) xlat function. */ if (unlikely((xlat = xlat_func_register(NULL, "config", xlat_config, FR_TYPE_STRING)) == NULL)) goto failure; xlat_func_args_set(xlat, xlat_config_args); diff --git a/src/lib/server/trigger.c b/src/lib/server/trigger.c index eb600b3e857..2c121d0b185 100644 --- a/src/lib/server/trigger.c +++ b/src/lib/server/trigger.c @@ -272,7 +272,7 @@ static unlang_action_t trigger_run(rlm_rcode_t *p_result, UNUSED int *priority, * @param[in] name the path relative to the global trigger section ending in the trigger name * e.g. module.ldap.pool.start. * @param[in] rate_limit whether to rate limit triggers. - * @param[in] args to make available via the @verbatim %(trigger:) @endverbatim xlat. + * @param[in] args to make available via the @verbatim %trigger() @endverbatim xlat. * @return * - 0 on success. * - -1 on failure. diff --git a/src/lib/tls/conf.c b/src/lib/tls/conf.c index 9378923d08a..27196617dea 100644 --- a/src/lib/tls/conf.c +++ b/src/lib/tls/conf.c @@ -89,7 +89,7 @@ static CONF_PARSER tls_cache_config[] = { }, .dflt = "auto" }, { FR_CONF_OFFSET("name", FR_TYPE_TMPL, fr_tls_cache_conf_t, id_name), - .dflt = "%{EAP-Type}%(interpreter:server)", .quote = T_DOUBLE_QUOTED_STRING }, + .dflt = "%{EAP-Type}%interpreter(server)", .quote = T_DOUBLE_QUOTED_STRING }, { FR_CONF_OFFSET("lifetime", FR_TYPE_TIME_DELTA, fr_tls_cache_conf_t, lifetime), .dflt = "1d" }, #if OPENSSL_VERSION_NUMBER >= 0x10100000L diff --git a/src/lib/unlang/edit.c b/src/lib/unlang/edit.c index d9f92fb22f9..25348a522f5 100644 --- a/src/lib/unlang/edit.c +++ b/src/lib/unlang/edit.c @@ -935,12 +935,12 @@ static int check_rhs(request_t *request, unlang_frame_state_edit_t *state, edit_ * If we deleted the attribute when processing the LHS, then you couldn't reference an attribute * in it's own assignment: * - * &foo := %(tolower:foo) + * &foo := %tolower(foo) * * so we have to delay the deletion until the RHS has been fully expanded. But we don't always * delete everything. e.g. if the map is: * - * &foo[1] := %(tolower:foo[1]) + * &foo[1] := %tolower(foo[1]) * * The we just apply the assignment to the LHS, over-writing it's value. */ diff --git a/src/lib/unlang/xlat_builtin.c b/src/lib/unlang/xlat_builtin.c index 619746f9071..f2685a18652 100644 --- a/src/lib/unlang/xlat_builtin.c +++ b/src/lib/unlang/xlat_builtin.c @@ -440,7 +440,7 @@ static xlat_arg_parser_t const xlat_func_file_name_args[] = { }; static xlat_arg_parser_t const xlat_func_file_name_count_args[] = { - { .required = true, .type = FR_TYPE_STRING }, + { .required = true, .type = FR_TYPE_STRING }, { .required = false, .type = FR_TYPE_UINT32 }, XLAT_ARG_PARSER_TERMINATOR }; @@ -1242,7 +1242,7 @@ static xlat_arg_parser_t const xlat_func_next_time_args[] = { /** Calculate number of seconds until the next n hour(s), day(s), week(s), year(s). * - * For example, if it were 16:18 %(nexttime:1h) would expand to 2520. + * For example, if it were 16:18 %nexttime(1h) would expand to 2520. * * The envisaged usage for this function is to limit sessions so that they don't * cross billing periods. The output of the xlat should be combined with %{rand:} to create @@ -2851,7 +2851,7 @@ static xlat_action_t xlat_func_strlen(TALLOC_CTX *ctx, fr_dcursor_t *out, #ifdef HAVE_REGEX_PCRE2 /** Perform regex substitution TODO CHECK * - * Called when %(subst:) pattern begins with "/" + * Called when %subst() pattern begins with "/" * @verbatim %subst(, //[flags], ) diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index 79eac596ebb..bc753ed5d1a 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -1154,7 +1154,7 @@ static bool xlat_logical_or(xlat_logical_rctx_t *rctx, fr_value_box_list_t const fr_value_box_list_foreach(in, box) { if (fr_box_is_group(box)) { if (!xlat_logical_or(rctx, &box->vb_group)) return false; - continue; + continue; } /* @@ -1261,7 +1261,7 @@ static bool xlat_logical_and(xlat_logical_rctx_t *rctx, fr_value_box_list_t cons fr_value_box_list_foreach(in, box) { if (fr_box_is_group(box)) { if (!xlat_logical_or(rctx, &box->vb_group)) return false; - continue; + continue; } /* @@ -1488,7 +1488,7 @@ static xlat_action_t xlat_func_unary_complement(TALLOC_CTX *ctx, fr_dcursor_t *o * xlat_tokenize() just makes all unknown arguments into XLAT_BOX, of data type FR_TYPE_STRING. Whereas * xlat_tokenize_expr() calls tmpl_afrom_substr(), which tries hard to create a particular data type. * - * This function fixes up calls of the form %(op_add: 3 4), which normally passes 2 arguments of "3" and "4", + * This function fixes up calls of the form %op_add(3, 4), which normally passes 2 arguments of "3" and "4", * so that the arguments are instead passed as integers 3 and 4. * * This fixup isn't *strictly* necessary, but it's good to have no surprises in the code, if the user creates diff --git a/src/lib/unlang/xlat_tokenize.c b/src/lib/unlang/xlat_tokenize.c index 86414a91151..6d1d76fc59f 100644 --- a/src/lib/unlang/xlat_tokenize.c +++ b/src/lib/unlang/xlat_tokenize.c @@ -607,7 +607,7 @@ int xlat_tokenize_function_args(xlat_exp_head_t *head, fr_sbuff_t *in, /** Parse an xlat function and its child argument * * Parses a function call string in the format - * @verbatim %{:} @endverbatim + * @verbatim %() @endverbatim * * @return * - 0 if the string was parsed into a function. @@ -689,7 +689,7 @@ static int xlat_tokenize_function_new(xlat_exp_head_t *head, fr_sbuff_t *in, tmp * Anything else, it must be a full function name. */ fr_sbuff_set(in, &m_s); - } + } fr_sbuff_adv_past_allowed(in, SIZE_MAX, xlat_func_chars, NULL); @@ -1237,7 +1237,7 @@ static int xlat_tokenize_input(xlat_exp_head_t *head, fr_sbuff_t *in, TALLOC_FREE(node); /* nope, couldn't use it */ if (xlat_tokenize_function_args(head, in, t_rules) < 0) goto error; continue; - } + } /* * More migration hacks: allow %foo(...) diff --git a/src/modules/rlm_chap/rlm_chap.c b/src/modules/rlm_chap/rlm_chap.c index 19fc285796b..8734eaaaa4b 100644 --- a/src/modules/rlm_chap/rlm_chap.c +++ b/src/modules/rlm_chap/rlm_chap.c @@ -121,7 +121,7 @@ static xlat_arg_parser_t const xlat_func_chap_password_args[] = { * * Example: @verbatim -"%(chap.password:)" == 0x +%chap.password() == 0x @endverbatim * * @ingroup xlat_functions diff --git a/src/modules/rlm_cipher/rlm_cipher.c b/src/modules/rlm_cipher/rlm_cipher.c index 6db7e87d1fd..e60e40e9948 100644 --- a/src/modules/rlm_cipher/rlm_cipher.c +++ b/src/modules/rlm_cipher/rlm_cipher.c @@ -775,7 +775,7 @@ static xlat_arg_parser_t const cipher_rsa_verify_xlat_arg[] = { * Arguments are @verbatim(, ...)@endverbatim * @verbatim -%(<inst>.verify:<signature> <plaintext>...) +%<inst>.verify(<signature> <plaintext>...) @endverbatim * * If multiple arguments are provided (after @verbatim<signature>@endverbatim) @@ -809,7 +809,7 @@ static xlat_action_t cipher_rsa_verify_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, */ if (in_head->type != FR_TYPE_OCTETS) { REDEBUG("Signature argument wrong type, expected %s, got %s. " - "Use %%(base64.decode:<text>) or %%{hex_decode:<text>} if signature is armoured", + "Use %%base64.decode(<text>) or %%hex_decode(<text>) if signature is armoured", fr_type_to_str(FR_TYPE_OCTETS), fr_type_to_str(in_head->type)); return XLAT_ACTION_FAIL; @@ -890,7 +890,7 @@ static xlat_arg_parser_t const cipher_certificate_xlat_args[] = { * Arguments are @verbatim(<digest>)@endverbatim * @verbatim -%(<inst>.certificate:fingerprint <digest>) +%<inst>.certificate(fingerprint, <digest>) @endverbatim * * @ingroup xlat_functions @@ -939,7 +939,7 @@ static xlat_action_t cipher_fingerprint_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, /** Return the serial of the public certificate * @verbatim -%(<inst>.certificate:serial) +%<inst>.certificate(serial) @endverbatim * * @ingroup xlat_functions diff --git a/src/modules/rlm_client/rlm_client.c b/src/modules/rlm_client/rlm_client.c index 247efbfbf68..8fdbf2b8e0b 100644 --- a/src/modules/rlm_client/rlm_client.c +++ b/src/modules/rlm_client/rlm_client.c @@ -226,7 +226,7 @@ static xlat_arg_parser_t const xlat_client_args[] = { * * Example: @verbatim -%(client:foo [<ipaddr>]) +%client(foo, [<ipaddr>]) @endverbatim * * @ingroup xlat_functions diff --git a/src/modules/rlm_date/rlm_date.c b/src/modules/rlm_date/rlm_date.c index 2c0c325a0eb..fac0d857f1e 100644 --- a/src/modules/rlm_date/rlm_date.c +++ b/src/modules/rlm_date/rlm_date.c @@ -148,19 +148,19 @@ static xlat_arg_parser_t const xlat_date_convert_args[] = { * * When the request arrived: @verbatim -%(date:request) +%date(request) @endverbatim * * Now: @verbatim -%(date:now} +%date(now) @endverbatim * * Examples (Tmp-Integer-0 = 1506101100): @verbatim update request { - &Tmp-String-0 := "%(date:%{Tmp-Integer-0})" ("Fri 22 Sep 18:25:00 BST 2017") - &Tmp-Integer-1 := "%(date:%{Tmp-String-0})" (1506101100) + &Tmp-String-0 := %date(%{Tmp-Integer-0}) ("Fri 22 Sep 18:25:00 BST 2017") + &Tmp-Integer-1 := %date(%{Tmp-String-0}) (1506101100) } @endverbatim * diff --git a/src/modules/rlm_delay/rlm_delay.c b/src/modules/rlm_delay/rlm_delay.c index 5c34cb62bd6..c3971d46cfe 100644 --- a/src/modules/rlm_delay/rlm_delay.c +++ b/src/modules/rlm_delay/rlm_delay.c @@ -211,7 +211,7 @@ static xlat_arg_parser_t const xlat_delay_args[] = { * * Example (delay 2 seconds): @verbatim -"%(delay:2)" +%delay(2) @endverbatim * * @ingroup xlat_functions diff --git a/src/modules/rlm_dict/rlm_dict.c b/src/modules/rlm_dict/rlm_dict.c index 49d82dd8797..9f6ba3946d2 100644 --- a/src/modules/rlm_dict/rlm_dict.c +++ b/src/modules/rlm_dict/rlm_dict.c @@ -33,7 +33,7 @@ static xlat_arg_parser_t const xlat_dict_attr_by_num_args[] = { XLAT_ARG_PARSER_TERMINATOR }; -/** Xlat for %(attr_by_num:\<number\>) +/** Xlat for %attr_by_num(\<number\>) * * @ingroup xlat_functions */ @@ -67,7 +67,7 @@ static xlat_arg_parser_t const xlat_dict_attr_by_oid_args[] = { XLAT_ARG_PARSER_TERMINATOR }; -/** Xlat for %(attr_by_oid:\<oid\>) +/** Xlat for %attr_by_oid(\<oid\>) * * @ingroup xlat_functions */ diff --git a/src/modules/rlm_exec/rlm_exec.c b/src/modules/rlm_exec/rlm_exec.c index 3483c6f8dff..7c4e94005be 100644 --- a/src/modules/rlm_exec/rlm_exec.c +++ b/src/modules/rlm_exec/rlm_exec.c @@ -122,7 +122,7 @@ static xlat_arg_parser_t const exec_xlat_args[] = { * * Example: @verbatim -"%(exec:/bin/echo hello)" == "hello" +%exec('/bin/echo', 'hello') == "hello" @endverbatim * * Exactly one request is consumed during the process lifetime, diff --git a/src/modules/rlm_icmp/rlm_icmp.c b/src/modules/rlm_icmp/rlm_icmp.c index 203d02b2836..68eecf657b3 100644 --- a/src/modules/rlm_icmp/rlm_icmp.c +++ b/src/modules/rlm_icmp/rlm_icmp.c @@ -161,7 +161,7 @@ static xlat_arg_parser_t const xlat_icmp_args[] = { * * Example (ping 192.0.2.1): @verbatim -"%(icmp:192.0.2.1)" +%icmp(192.0.2.1) @endverbatim * * @ingroup xlat_functions diff --git a/src/modules/rlm_mschap/rlm_mschap.c b/src/modules/rlm_mschap/rlm_mschap.c index 739408daf57..10be67dddf5 100644 --- a/src/modules/rlm_mschap/rlm_mschap.c +++ b/src/modules/rlm_mschap/rlm_mschap.c @@ -830,8 +830,8 @@ static int CC_HINT(nonnull (1, 2, 4, 5)) do_mschap_cpw(rlm_mschap_t const *inst, * we're expecting to use the ntlm-change-password-1 protocol * which needs the following on stdin: * - * username: %(mschap:User-Name) - * nt-domain: %(mschap:NT-Domain) + * username: %mschap(User-Name) + * nt-domain: %mschap(NT-Domain) * new-nt-password-blob: bin2hex(new_nt_password) - 1032 bytes encoded * old-nt-hash-blob: bin2hex(old_nt_hash) - 32 bytes encoded * new-lm-password-blob: 00000...0000 - 1032 bytes null @@ -999,11 +999,11 @@ ntlm_auth_err: * * this allows is to write e..g * - * %{sql:insert into ...} + * %sql(insert into ...) * * ...or... * - * %(exec:/path/to %(mschap:User-Name) %{MS-CHAP-New-Password})" + * %exec('/path/to', %mschap(User-Name), %{MS-CHAP-New-Password})" * */ } else if (inst->local_cpw) { diff --git a/src/modules/rlm_pap/rlm_pap.c b/src/modules/rlm_pap/rlm_pap.c index 40c6402c86e..0a134e9541a 100644 --- a/src/modules/rlm_pap/rlm_pap.c +++ b/src/modules/rlm_pap/rlm_pap.c @@ -795,7 +795,7 @@ static unlang_action_t CC_HINT(nonnull) pap_auth_lm(rlm_rcode_t *p_result, RETURN_MODULE_INVALID; } - len = xlat_eval(charbuf, sizeof(charbuf), request, "%(mschap:LM-Hash %{User-Password})", NULL, NULL); + len = xlat_eval(charbuf, sizeof(charbuf), request, "%mschap(LM-Hash, %{User-Password})", NULL, NULL); if (len < 0) RETURN_MODULE_FAIL; if ((fr_base16_decode(NULL, &digest_dbuff, &FR_SBUFF_IN(charbuf, len), false) != diff --git a/src/modules/rlm_perl/rlm_perl.c b/src/modules/rlm_perl/rlm_perl.c index 6167caf1ec1..2a4994909b9 100644 --- a/src/modules/rlm_perl/rlm_perl.c +++ b/src/modules/rlm_perl/rlm_perl.c @@ -202,7 +202,7 @@ static XS(XS_radiusd_log) /* * This is a wraper for xlat_aeval * Now users are able to get data that is accessible only via xlat - * e.g. %(client:...) + * e.g. %client(...) * Call syntax is radiusd::xlat(string), string will be handled the * same way it is described in EXPANSIONS section of man unlang */ diff --git a/src/modules/rlm_radius/test_plan.adoc b/src/modules/rlm_radius/test_plan.adoc index d4dca7dd8a7..66b21026d81 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/modules/rlm_redis/rlm_redis.c b/src/modules/rlm_redis/rlm_redis.c index 2cd540b1c6e..5d36dd964bd 100644 --- a/src/modules/rlm_redis/rlm_redis.c +++ b/src/modules/rlm_redis/rlm_redis.c @@ -317,7 +317,7 @@ static xlat_arg_parser_t const redis_node_xlat_args[] = { /** Return the node that is currently servicing a particular key * @verbatim -%(redis.node:<key> [<index>]) +%redis.node(<key>[, <index>]) @endverbatim * * @ingroup xlat_functions @@ -581,7 +581,7 @@ static xlat_arg_parser_t const redis_args[] = { /** Xlat to make calls to redis * @verbatim -%(redis:<redis command>) +%redis(<redis command>) @endverbatim * * @ingroup xlat_functions @@ -867,7 +867,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) xlat_func_args_set(xlat, redis_args); /* - * %(redis.node:<key>[ idx]) + * %redis.node(<key>[, idx]) */ if (unlikely((xlat = xlat_func_register_module(inst, mctx, "node", redis_node_xlat, FR_TYPE_STRING)) == NULL)) return -1; xlat_func_args_set(xlat, redis_node_xlat_args); diff --git a/src/modules/rlm_rest/rlm_rest.c b/src/modules/rlm_rest/rlm_rest.c index 35918e42c01..8388c79d5e3 100644 --- a/src/modules/rlm_rest/rlm_rest.c +++ b/src/modules/rlm_rest/rlm_rest.c @@ -395,7 +395,7 @@ static xlat_arg_parser_t const rest_xlat_args[] = { * * Example: @verbatim -%(rest:http://example.com/) +%rest(http://example.com/) @endverbatim * * @ingroup xlat_functions diff --git a/src/modules/rlm_unbound/rlm_unbound.5 b/src/modules/rlm_unbound/rlm_unbound.5 index 2d3ffc4afc1..613015a63ce 100644 --- a/src/modules/rlm_unbound/rlm_unbound.5 +++ b/src/modules/rlm_unbound/rlm_unbound.5 @@ -36,19 +36,19 @@ any libunbound configuration values. .PP An instance named, for example, "dns" will provide the following xlat functionalities: -.IP %(dns:<owner> <record type> [<limit>]) +.IP %dns(<owner>, <record type>[, <limit>]) Perform the lookup of <record type> against <owner> returning up to <limit> results. The returned data type is appropriate to the record type being queried. -.IP %(dns:<owner> A) +.IP %dns(<owner>, A) Performs an A lookup for the owner name, returning the results as IPv4 addresses. -.IP %(dns:<owner> AAAA) +.IP %dns(<owner>, AAAA) Performs an AAAA lookup for the owner name, returning the results as IPv6 addresses. -.IP %(dns:<owner> PTR) +.IP %dns(<owner>, PTR) Performs a PTR lookup for the owner. -.IP %(dns:<owner> MX 1) +.IP %dns(<owner>, MX, 1) Performs an MX lookup for the owner, returning just the first result. .PP .SH CAVEATS diff --git a/src/modules/rlm_unpack/rlm_unpack.c b/src/modules/rlm_unpack/rlm_unpack.c index 3f9208d4c87..5aa05cd96f0 100644 --- a/src/modules/rlm_unpack/rlm_unpack.c +++ b/src/modules/rlm_unpack/rlm_unpack.c @@ -42,7 +42,7 @@ static xlat_arg_parser_t const unpack_xlat_args[] = { * * Example: @verbatim -%(unpack:%{Class} 0 integer) +%unpack(%{Class}, 0, integer) @endverbatim * Expands Class, treating octet at offset 0 (bytes 0-3) as an "integer". *