]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
%map() returns bool, not int8
authorAlan T. DeKok <aland@freeradius.org>
Sat, 29 Mar 2025 23:52:01 +0000 (19:52 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 30 Mar 2025 12:42:18 +0000 (08:42 -0400)
and isn't it really %eval(), but with assignment?

The normal %eval() evaluates conditions and expressions.

src/lib/unlang/xlat_builtin.c
src/tests/keywords/map-xlat
src/tests/keywords/map-xlat-nested
src/tests/keywords/map-xlat-nested-overwrite
src/tests/keywords/map-xlat-struct

index 8b4c0a82d36edfe69cfb814057f843f72f6077f9..cca7a5dfd060c727b455e20e65f9fb5f3340c802 100644 (file)
@@ -1270,8 +1270,8 @@ static xlat_action_t xlat_func_map(TALLOC_CTX *ctx, fr_dcursor_t *out,
                return XLAT_ACTION_FAIL;
        }
 
-       MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_INT8, NULL));
-       vb->vb_int8 = 0;        /* Default fail value - changed to 1 on success */
+       MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_BOOL, NULL));
+       vb->vb_bool = false;    /* Default fail value - changed to true on success */
        fr_dcursor_append(out, vb);
 
        switch (map->lhs->type) {
@@ -1306,7 +1306,7 @@ static xlat_action_t xlat_func_map(TALLOC_CTX *ctx, fr_dcursor_t *out,
        talloc_free(map);
        if (ret < 0) return XLAT_ACTION_FAIL;
 
-       vb->vb_int8 = 1;
+       vb->vb_bool = true;
        return XLAT_ACTION_DONE;
 }
 
@@ -4296,7 +4296,7 @@ do { \
 
        XLAT_REGISTER_PURE("bin", xlat_func_bin, FR_TYPE_OCTETS, xlat_func_bin_arg);
        XLAT_REGISTER_PURE("hex", xlat_func_hex, FR_TYPE_STRING, xlat_func_hex_arg);
-       XLAT_REGISTER_PURE("map", xlat_func_map, FR_TYPE_INT8, xlat_func_map_arg);
+       XLAT_REGISTER_PURE("map", xlat_func_map, FR_TYPE_BOOL, xlat_func_map_arg);
        XLAT_REGISTER_PURE("md4", xlat_func_md4, FR_TYPE_OCTETS, xlat_func_md4_arg);
        XLAT_REGISTER_PURE("md5", xlat_func_md5, FR_TYPE_OCTETS, xlat_func_md5_arg);
 #if defined(HAVE_REGEX_PCRE) || defined(HAVE_REGEX_PCRE2)
index a45c6056c2701f6c69cf13bbe7956560918b5f71..1087efd948c0cdd6c953197677276c4b9afdc003 100644 (file)
@@ -9,7 +9,7 @@ request += {
        NAS-Port-Id = "request.Vendor-Specific.Nokia-SR.MSAP-Interface += 'UNICAST_7360OLT4'"
 }
 
-if (!("%map(%{Filter-Id})" == 1)) {
+if !%map(Filter-Id) {
        test_fail
 }
 
@@ -18,7 +18,7 @@ if (!(control.Filter-Id == 'testing123')) {
 }
 
 foreach thing (NAS-Port-Id[*]) {
-       if (%map(thing) != 1) {
+       if !%map(thing) {
                test_fail
        }
 }
index 385a53e939b5c226004bcea3e88f98a46c827dc4..85961474171d16285d591379453e6e40350736e6 100644 (file)
@@ -5,7 +5,7 @@
 #
 Filter-Id := "request.Tmp-Group-0.User-Name = 'testing123'"
 
-if (!("%map(%{Filter-Id})" == 1)) {
+if !%map(Filter-Id) {
        test_fail
 }
 
index a61ede0b046c9a39d2bdeba4f5546de90b8215eb..fb6ad6fe5254da62c44263ef9f80a04a63965144 100644 (file)
@@ -5,15 +5,15 @@
 #
 Filter-Id := "request.Tmp-Group-0.Filter-Id := 'testing123'"
 
-if (!(%map("%{Filter-Id}") == 1)) {
+if !%map(Filter-Id) {
        test_fail
 }
 
-if (!(%map("%{Filter-Id}") == 1)) {
+if !%map(Filter-Id) {
        test_fail
 }
 
-if (!(%map("request.Tmp-Group-0.User-Name := 'testing000'") == 1)) {
+if !%map("request.Tmp-Group-0.User-Name := 'testing000'") {
        test_fail
 }
 
index 5f898b9021811e6a959cad756256afed61a06b12..1607503113148099dc25c3c2f1f8ede27d19ac10 100644 (file)
@@ -8,7 +8,7 @@ string test_string
 
 test_string := "IA-PD.IAID = 11"
 
-if (!("%map(%{test_string})" == 1)) {
+if !%map(test_string) {
        test_fail
 }