]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Remove old virtual attributes
authorAlan T. DeKok <aland@freeradius.org>
Tue, 29 Aug 2023 22:05:11 +0000 (18:05 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 29 Aug 2023 22:08:53 +0000 (18:08 -0400)
Module-Return-Code
Virtual-Server
Request-Processing-Stage

update examples, document them, etc.

doc/antora/modules/installation/pages/upgrade.adoc
raddb/mods-available/eap
share/dictionary/freeradius/dictionary.freeradius.internal
src/lib/server/tmpl_eval.c
src/lib/unlang/interpret.c
src/lib/unlang/xlat_eval.c
src/lib/unlang/xlat_expr.c
src/tests/keywords/virtual [deleted file]
src/tests/keywords/virtual-exists [deleted file]
src/tests/keywords/xlat-virtual-attr

index f7cbb5599ce00f8478bcd2821c93dca77cad8517..491d038fd7cd172848aff32cf79a76a2390ef4a9 100644 (file)
@@ -1031,5 +1031,10 @@ result in an error.
 
 == Deleted Functionality
 
-The `Response-Packet-Type` attribute has been removed.  Please replace
-it with `&reply.Packet-Type`.
+Many "virtual" or "fake" attributes have been removed or renamed.
+
+`&Module-Return-Code` should be replaced by `%{interpreter:rcode}`.
+
+`&Response-Packet-Type` should be replaced by `&reply.Packet-Type`.
+
+`&Virtual-Server` should be replaced by `%{interpreter:server}`.
index 77b93fe566039d5850952d31bb3720e55b157ec6..ce5814877fd5b1d07d7bda60e925f0c91ae4d4bf 100644 (file)
@@ -783,7 +783,7 @@ eap {
                        #  NOTE: OpenSSL only allows 32 bytes of session ctx, so
                        #  the value provided here is digested with SHA256.
                        #
-#                      name = "%{EAP-Type}%{Virtual-Server}"
+#                      name = "%{EAP-Type}%{interpreter:server}"
 
                        #
                        #  lifetime::
index 36a7c5f3c389de8f1ef758a39d7910d23d8d16f3..f474606650423cb8805a83b34ccb856fdbc51770 100644 (file)
@@ -65,18 +65,8 @@ ATTRIBUTE    Auth-Type                               12      integer
 ATTRIBUTE      Load-Balance-Key                        20      string
 ATTRIBUTE      Proxy-To-Realm                          21      string
 # 22 - was Replicate-To-Realm
-ATTRIBUTE      Virtual-Server                          23      string virtual
-ATTRIBUTE      Module-Return-Code                      24      integer virtual
-
-VALUE  Module-Return-Code              reject                  0
-VALUE  Module-Return-Code              fail                    1
-VALUE  Module-Return-Code              ok                      2
-VALUE  Module-Return-Code              handled                 3
-VALUE  Module-Return-Code              invalid                 4
-VALUE  Module-Return-Code              disallow                5
-VALUE  Module-Return-Code              notfound                6
-VALUE  Module-Return-Code              noop                    7
-VALUE  Module-Return-Code              updated                 8
+# 23 was Virtual-Server
+# 24 was Module-Return-Code
 
 #
 #      Cannonical definition of all available module methods
@@ -108,7 +98,7 @@ VALUE        Module-Method                   store                   22
 VALUE  Module-Method                   clear                   23
 VALUE  Module-Method                   refresh                 24
 
-ATTRIBUTE      Request-Processing-Stage                26      string virtual
+# 26 was Request-Processing-Stage
 
 #
 #      Range:  50 - 99
index 8f7f0cdc7db3aeb132a075e1cb9c596536388e59..2ffcfd6b545c5438704c7ea5b38861cb05d2587d 100644 (file)
@@ -59,9 +59,6 @@ static fr_dict_attr_t const *attr_packet_src_ipv6_address;
 static fr_dict_attr_t const *attr_packet_src_port;
 static fr_dict_attr_t const *attr_packet_type;
 static fr_dict_attr_t const *attr_packet_authentication_vector;
-static fr_dict_attr_t const *attr_request_processing_stage;
-static fr_dict_attr_t const *attr_virtual_server;
-static fr_dict_attr_t const *attr_module_return_code;
 
 /** Placeholder attribute for uses of unspecified attribute references
  */
@@ -69,15 +66,12 @@ 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_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 },
        { .out = &attr_packet_dst_port, .name = "Packet-Dst-Port", .type = FR_TYPE_UINT16, .dict = &dict_freeradius },
        { .out = &attr_packet_src_ip_address, .name = "Packet-Src-IP-Address", .type = FR_TYPE_IPV4_ADDR, .dict = &dict_freeradius },
        { .out = &attr_packet_src_ipv6_address, .name = "Packet-Src-IPv6-Address", .type = FR_TYPE_IPV6_ADDR, .dict = &dict_freeradius },
        { .out = &attr_packet_src_port, .name = "Packet-Src-Port", .type = FR_TYPE_UINT16, .dict = &dict_freeradius },
-       { .out = &attr_request_processing_stage, .name = "Request-Processing-Stage", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
-       { .out = &attr_virtual_server, .name = "Virtual-Server", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
 
        { .out = &attr_packet_authentication_vector, .name = "Packet-Authentication-Vector", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
        { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_radius },
@@ -1099,36 +1093,6 @@ static int tmpl_eval_pair_virtual(TALLOC_CTX *ctx, fr_value_box_list_t *out,
                goto done;
        }
 
-       /*
-        *      Some non-packet expansions
-        */
-       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) {
-               error:
-                       talloc_free(value);
-                       return -1;
-               }
-               goto done;
-       }
-
-       if (tmpl_attr_tail_da(vpt) == attr_virtual_server) {
-               if (!unlang_call_current(request)) return 0;
-
-               MEM(value = fr_value_box_alloc_null(ctx));
-               if (fr_value_box_bstrdup_buffer(ctx, value, tmpl_attr_tail_da(vpt),
-                                              cf_section_name2(unlang_call_current(request)), false) < 0) goto error;
-               goto done;
-       }
-
-       if (tmpl_attr_tail_da(vpt) == attr_module_return_code) {
-               MEM(value = fr_value_box_alloc(ctx, tmpl_attr_tail_da(vpt)->type, tmpl_attr_tail_da(vpt)));
-               value->datum.int32 = request->rcode;
-               goto done;
-       }
-
        /*
         *      All of the attributes must now refer to a packet.
         *      If there's no packet, we can't print any attribute
index d8b3805d434f1766b71b9b1ba78e27ff398d7c2d..d4534544c0d65c3e2ae0b964d05815cb3186c33e 100644 (file)
@@ -1457,7 +1457,7 @@ static xlat_action_t unlang_interpret_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
         */
        while (*fmt == '.') {
                if (depth <= 1) {
-                       if (fr_value_box_bstrndup(ctx, vb, NULL, "<underflow>", 11, false) < 0) {
+                       if (fr_value_box_bstrndup(vb, vb, NULL, "<underflow>", 11, false) < 0) {
                        error:
                                talloc_free(vb);
                                return XLAT_ACTION_FAIL;
@@ -1495,7 +1495,7 @@ static xlat_action_t unlang_interpret_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
         *      The current module
         */
        if (strcmp(fmt, "module") == 0) {
-               if (fr_value_box_strdup(ctx, vb, NULL, request->module, false) < 0) goto error;
+               if (fr_value_box_strdup(vb, vb, NULL, request->module, false) < 0) goto error;
 
                goto finish;
        }
@@ -1504,7 +1504,7 @@ static xlat_action_t unlang_interpret_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
         *      Name of the instruction.
         */
        if (strcmp(fmt, "name") == 0) {
-               if (fr_value_box_bstrndup(ctx, vb, NULL, instruction->name,
+               if (fr_value_box_bstrndup(vb, vb, NULL, instruction->name,
                                          strlen(instruction->name), false) < 0) goto error;
                goto finish;
        }
@@ -1513,7 +1513,7 @@ static xlat_action_t unlang_interpret_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
         *      The request processing stage.
         */
        if (strcmp(fmt, "processing_stage") == 0) {
-               if (fr_value_box_strdup(ctx, vb, NULL, request->component, false) < 0) goto error;
+               if (fr_value_box_strdup(vb, vb, NULL, request->component, false) < 0) goto error;
 
                goto finish;
        }
@@ -1522,7 +1522,7 @@ static xlat_action_t unlang_interpret_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
         *      The current return code.
         */
        if (strcmp(fmt, "rcode") == 0) {
-               if (fr_value_box_strdup(ctx, vb, NULL, fr_table_str_by_value(rcode_table, request->rcode, "<INVALID>"), false) < 0) goto error;
+               if (fr_value_box_strdup(vb, vb, NULL, fr_table_str_by_value(rcode_table, request->rcode, "<INVALID>"), false) < 0) goto error;
                
                goto finish;
        }
@@ -1533,7 +1533,7 @@ static xlat_action_t unlang_interpret_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
        if (strcmp(fmt, "server") == 0) {
                if (!unlang_call_current(request)) goto finish;
 
-               if (fr_value_box_strdup(ctx, vb, NULL, cf_section_name2(unlang_call_current(request)), false) < 0) goto error;
+               if (fr_value_box_strdup(vb, vb, NULL, cf_section_name2(unlang_call_current(request)), false) < 0) goto error;
 
                goto finish;
        }
@@ -1542,7 +1542,7 @@ static xlat_action_t unlang_interpret_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
         *      Unlang instruction type.
         */
        if (strcmp(fmt, "type") == 0) {
-               if (fr_value_box_bstrndup(ctx, vb, NULL, unlang_ops[instruction->type].name,
+               if (fr_value_box_bstrndup(vb, vb, NULL, unlang_ops[instruction->type].name,
                                          strlen(unlang_ops[instruction->type].name), false) < 0) goto error;
 
                goto finish;
@@ -1552,7 +1552,7 @@ static xlat_action_t unlang_interpret_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
         *      All of the remaining things need a CONF_ITEM.
         */
        if (!instruction->ci) {
-               if (fr_value_box_bstrndup(ctx, vb, NULL, "<INVALID>", 3, false) < 0) goto error;
+               if (fr_value_box_bstrndup(vb, vb, NULL, "<INVALID>", 3, false) < 0) goto error;
 
                goto finish;
        }
@@ -1570,7 +1570,7 @@ static xlat_action_t unlang_interpret_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
         *      Filename of the current section.
         */
        if (strcmp(fmt, "filename") == 0) {
-               if (fr_value_box_strdup(ctx, vb, NULL, cf_filename(instruction->ci), false) < 0) goto error;
+               if (fr_value_box_strdup(vb, vb, NULL, cf_filename(instruction->ci), false) < 0) goto error;
 
                goto finish;
        }
index 379f6fe8360ac6101909d4b09fbf7076a6f39a2f..e9b0d9ddb953e01f0e6d02837ca4a530f97cbb23 100644 (file)
@@ -49,12 +49,9 @@ static fr_dict_autoload_t xlat_eval_dict[] = {
 };
 
 fr_dict_attr_t const *attr_expr_bool_enum; /* xlat_expr.c */
-fr_dict_attr_t const *attr_module_return_code; /* xlat_expr.c */
 fr_dict_attr_t const *attr_cast_base; /* xlat_expr.c */
 
 static fr_dict_attr_autoload_t xlat_eval_dict_attr[] = {
-       { .out = &attr_module_return_code, .name = "Module-Return-Code", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
-
        { .out = &attr_expr_bool_enum, .name = "Expr-Bool-Enum", .type = FR_TYPE_BOOL, .dict = &dict_freeradius },
        { .out = &attr_cast_base, .name = "Cast-Base", .type = FR_TYPE_UINT8, .dict = &dict_freeradius },
        { NULL }
index 719bf77c4667d34fab617dce067320735d34a306..329437cd29d10474e7fd0d6a620a8abcdbc3fe5a 100644 (file)
@@ -1394,8 +1394,11 @@ static xlat_action_t xlat_func_rcode(TALLOC_CTX *ctx, fr_dcursor_t *out,
         *      matches the current rcode.
         */
        if (!src) {
-               MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_UINT32, attr_module_return_code));
-               vb->datum.int32 = request->rcode;
+               MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_STRING, NULL));
+               if (fr_value_box_strdup(vb, vb, NULL, fr_table_str_by_value(rcode_table, request->rcode, "<INVALID>"), false) < 0) {
+                       talloc_free(vb);
+                       return XLAT_ACTION_FAIL;
+               }
        } else {
                rlm_rcode_t rcode;
 
diff --git a/src/tests/keywords/virtual b/src/tests/keywords/virtual
deleted file mode 100644 (file)
index 9a48031..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#
-#  PRE: if
-#
-if (&Packet-Type == Access-Request) {
-       success
-}
diff --git a/src/tests/keywords/virtual-exists b/src/tests/keywords/virtual-exists
deleted file mode 100644 (file)
index a86a662..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#
-#  PRE: if
-#
-if (&Virtual-Server) {
-       success
-}
index 17d30330479de7bbe4038026af5b9c9bfe47d3d1..83fb6176ee50e0c4c23042c436bf5705db83d2b6 100644 (file)
@@ -2,15 +2,6 @@
 #  PRE: if
 #
 
-if (!("%{Virtual-Server}" == 'default')) {
-       test_fail
-}
-
-ok
-if (!("%{Module-Return-Code}" == 'ok')) {
-       test_fail
-}
-
 if (!("%{Packet-Type}" == 'Access-Request')) {
        test_fail
 }
@@ -47,17 +38,4 @@ if (!("%{Packet-Dst-Port}" == '1812')) {
        test_fail
 }
 
-# Operations on virtual attributes should be the same as on real ones
-if (!("%{Virtual-Server[0]}" == 'default')) {
-       test_fail
-}
-
-if (!("%{Virtual-Server[*]}" == 'default')) {
-       test_fail
-}
-
-if (!(%{Virtual-Server[#]} == 1)) {
-       test_fail
-}
-
 success