]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add tests for actually sending invalid attributes
authorAlan T. DeKok <aland@freeradius.org>
Fri, 8 May 2020 12:39:20 +0000 (08:39 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 8 May 2020 12:39:43 +0000 (08:39 -0400)
If an attribute is unknown, it's type MUST be octets.  AND we can
encode it.  In fact, we generally MUST encode it, as the admin
is trying to work around stupid vendor issues.

<cough> SUPERMICRO </cough>

src/lib/server/tmpl.c
src/tests/radclient/auth_4.out [new file with mode: 0644]
src/tests/radclient/auth_4.txt [new file with mode: 0644]
src/tests/radclient/config/radiusd.conf

index 0c185dff4d00e38d85602194ff6c0a5a16721916..366fd2ca5cce5b6c0b118c6d795727603ac5c470 100644 (file)
@@ -783,10 +783,10 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, attr_ref_error_t *err,
                        }
 
                        /*
-                        *      Unknown attributes can't be encoded, as we don't
-                        *      know how to encode them!
+                        *      Unknown attributes can be encoded, BUT
+                        *      they must be of type "octets".
                         */
-                       tmpl_unknown(vpt)->flags.internal = 1;
+                       fr_assert(tmpl_unknown(vpt)->type == FR_TYPE_OCTETS);
                        tmpl_da_set(vpt, tmpl_unknown(vpt));
 
                        p += slen;
diff --git a/src/tests/radclient/auth_4.out b/src/tests/radclient/auth_4.out
new file mode 100644 (file)
index 0000000..4a6c2e5
--- /dev/null
@@ -0,0 +1,9 @@
+Sent Access-Request Id 123 from 0.0.0.0:1234 to 127.0.0.1:12340 length 51 
+       Cleartext-Password = "hello"
+       User-Name = "bob"
+       User-Password = "hello"
+       NAS-Identifier = "auth_4"
+Received Access-Accept Id 123 from 127.0.0.1:12340 to 0.0.0.0:1234 via lo length 47 
+       Class = 0x483d342c493d34
+       Attr-26 = 0x483d342c493d34
+       Attr-26 = 0x483d342c493d43
diff --git a/src/tests/radclient/auth_4.txt b/src/tests/radclient/auth_4.txt
new file mode 100644 (file)
index 0000000..856fa7c
--- /dev/null
@@ -0,0 +1,6 @@
+#
+#      ARGV: -i 123 -c 1 -x -F
+#
+User-Name = "bob",
+User-Password = "hello"
+NAS-Identifier = "auth_4"
index f531b55e86c4469b4b1628f447604e08fa190cf0..ed975246fb28158e31c9b7fee594732ad1bae7c4 100644 (file)
@@ -108,11 +108,26 @@ server test {
        }
 
        recv Access-Request {
+               #
+               #  Ensure that we can send unknown attributes back.
+               #
+               if (&NAS-Identifier == "auth_4") {
+                       update reply {
+                               &Class := 0x483d342c493d34
+                       }
+
+                       update reply {
+                               &Attr-26 := &reply:Class
+                               &Attr-26 += 0x483d342c493d43
+                       }
+               }
+
                if (&User-Name == "bob") {
                        accept
                } else {
                        reject
                }
+
        }
 
        send Access-Accept {