]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
remove Client-Shortname and replace with %{client:shortname}
authorAlan T. DeKok <aland@freeradius.org>
Sat, 26 Aug 2023 20:02:04 +0000 (16:02 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 26 Aug 2023 20:02:04 +0000 (16:02 -0400)
doc/antora/modules/installation/pages/upgrade.adoc
share/dictionary/freeradius/dictionary.freeradius.internal
src/lib/server/tmpl_eval.c
src/tests/keywords/virtual-exists
src/tests/keywords/xlat-virtual-attr

index 18f920d62c9afdf0016f468cfc66bfe6020b36cd..808418407c9244c6b39ae8f385729ead6b0d19bb 100644 (file)
@@ -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
index e7997b3359458b9ff3b3db6b9044ad971f3d1162..36a7c5f3c389de8f1ef758a39d7910d23d8d16f3 100644 (file)
@@ -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
index 1ffc591769dbc22094d2ed232f95458a370664bb..8f7f0cdc7db3aeb132a075e1cb9c596536388e59 100644 (file)
@@ -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;
 
index b8ccc5618f67a20faaab84897bf0353d99917aee..a86a6620340ca58e803ad0ba5c9ca3d601577008 100644 (file)
@@ -1,6 +1,6 @@
 #
 #  PRE: if
 #
-if (&Client-Shortname) {
+if (&Virtual-Server) {
        success
 }
index 71837142d6ec4ca9052a929d87413d0208c6b526..17d30330479de7bbe4038026af5b9c9bfe47d3d1 100644 (file)
@@ -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