From: Alan T. DeKok Date: Sat, 26 Aug 2023 20:02:04 +0000 (-0400) Subject: remove Client-Shortname and replace with %{client:shortname} X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=470b1a55e8c6bb0148aebe41bb27e56f6af8dca8;p=thirdparty%2Ffreeradius-server.git remove Client-Shortname and replace with %{client:shortname} --- diff --git a/doc/antora/modules/installation/pages/upgrade.adoc b/doc/antora/modules/installation/pages/upgrade.adoc index 18f920d62c9..808418407c9 100644 --- a/doc/antora/modules/installation/pages/upgrade.adoc +++ b/doc/antora/modules/installation/pages/upgrade.adoc @@ -705,6 +705,12 @@ and the parser is smart enough to figure things out. The following modules are new in v4. +=== rlm_client + +This module handles the `%{client:..}` xlat expansions. + +The `Client-Shortname` attribute has been removed. You should use `%{client:shortname}` instead. + === rlm_radius The `radius` module has taken over much of the functionality of diff --git a/share/dictionary/freeradius/dictionary.freeradius.internal b/share/dictionary/freeradius/dictionary.freeradius.internal index e7997b33594..36a7c5f3c38 100644 --- a/share/dictionary/freeradius/dictionary.freeradius.internal +++ b/share/dictionary/freeradius/dictionary.freeradius.internal @@ -142,9 +142,9 @@ ATTRIBUTE Stripped-User-Domain 1001 string # Connext-Rate, Add-Prefix, Add-Suffix ATTRIBUTE Expiration 1010 date -ATTRIBUTE Client-Shortname 1011 string virtual +# 1011 was Client-Shortname. Use %{client:shortname} instead -# Was Raw-Attribute. No longer supported +# 1012 Was Raw-Attribute. No longer supported ATTRIBUTE User-Category 1013 string ATTRIBUTE Pam-Auth 1014 string diff --git a/src/lib/server/tmpl_eval.c b/src/lib/server/tmpl_eval.c index 1ffc591769d..8f7f0cdc7db 100644 --- a/src/lib/server/tmpl_eval.c +++ b/src/lib/server/tmpl_eval.c @@ -51,7 +51,6 @@ fr_dict_autoload_t tmpl_dict[] = { { NULL } }; -static fr_dict_attr_t const *attr_client_shortname; static fr_dict_attr_t const *attr_packet_dst_ip_address; static fr_dict_attr_t const *attr_packet_dst_ipv6_address; static fr_dict_attr_t const *attr_packet_dst_port; @@ -70,7 +69,6 @@ extern fr_dict_attr_t const *tmpl_attr_unspec; fr_dict_attr_t const *tmpl_attr_unspec; static fr_dict_attr_autoload_t tmpl_dict_attr[] = { - { .out = &attr_client_shortname, .name = "Client-Shortname", .type = FR_TYPE_STRING, .dict = &dict_freeradius }, { .out = &attr_module_return_code, .name = "Module-Return-Code", .type = FR_TYPE_UINT32, .dict = &dict_freeradius }, { .out = &attr_packet_dst_ip_address, .name = "Packet-Dst-IP-Address", .type = FR_TYPE_IPV4_ADDR, .dict = &dict_freeradius }, { .out = &attr_packet_dst_ipv6_address, .name = "Packet-Dst-IPV6-Address", .type = FR_TYPE_IPV6_ADDR, .dict = &dict_freeradius }, @@ -1104,12 +1102,11 @@ static int tmpl_eval_pair_virtual(TALLOC_CTX *ctx, fr_value_box_list_t *out, /* * Some non-packet expansions */ - if (tmpl_attr_tail_da(vpt) == attr_client_shortname) { - fr_client_t *client = client_from_request(request); - if (!client || !client->shortname) return 0; + if (tmpl_attr_tail_da(vpt) == attr_request_processing_stage) { + if (!request->component) return 0; MEM(value = fr_value_box_alloc_null(ctx)); - if (fr_value_box_bstrdup_buffer(ctx, value, tmpl_attr_tail_da(vpt), client->shortname, false) < 0) { + if (fr_value_box_strdup(ctx, value, tmpl_attr_tail_da(vpt), request->component, false) < 0) { error: talloc_free(value); return -1; @@ -1117,14 +1114,6 @@ static int tmpl_eval_pair_virtual(TALLOC_CTX *ctx, fr_value_box_list_t *out, goto done; } - if (tmpl_attr_tail_da(vpt) == attr_request_processing_stage) { - if (!request->component) return 0; - - MEM(value = fr_value_box_alloc_null(ctx)); - if (fr_value_box_strdup(ctx, value, tmpl_attr_tail_da(vpt), request->component, false) < 0) goto error; - goto done; - } - if (tmpl_attr_tail_da(vpt) == attr_virtual_server) { if (!unlang_call_current(request)) return 0; diff --git a/src/tests/keywords/virtual-exists b/src/tests/keywords/virtual-exists index b8ccc5618f6..a86a6620340 100644 --- a/src/tests/keywords/virtual-exists +++ b/src/tests/keywords/virtual-exists @@ -1,6 +1,6 @@ # # PRE: if # -if (&Client-Shortname) { +if (&Virtual-Server) { success } diff --git a/src/tests/keywords/xlat-virtual-attr b/src/tests/keywords/xlat-virtual-attr index 71837142d6e..17d30330479 100644 --- a/src/tests/keywords/xlat-virtual-attr +++ b/src/tests/keywords/xlat-virtual-attr @@ -2,10 +2,6 @@ # PRE: if # -if (!("%{Client-Shortname}" == 'test')) { - test_fail -} - if (!("%{Virtual-Server}" == 'default')) { test_fail } @@ -51,13 +47,6 @@ if (!("%{Packet-Dst-Port}" == '1812')) { test_fail } - -# We should allow the user to overload virtual attributes -&Client-Shortname := 'my_test_client' -if (!("%{Client-Shortname}" == 'my_test_client')) { - test_fail -} - # Operations on virtual attributes should be the same as on real ones if (!("%{Virtual-Server[0]}" == 'default')) { test_fail