]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
allow alias Cisco -> Vendor-Specific.Cisco
authorAlan T. DeKok <aland@freeradius.org>
Tue, 3 Oct 2023 14:48:31 +0000 (10:48 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 3 Oct 2023 14:48:31 +0000 (10:48 -0400)
because we don't hate our end users enough to force them to
write huge long strings every time

share/dictionary/radius/dictionary.cisco
src/lib/server/tmpl_tokenize.c
src/tests/keywords/vsa-alias [new file with mode: 0644]

index 87105e7356a360726e11bb4fa304c33feb21a8f6..beb14532828a3e15fa955b18ba0f99a6e10711f8 100644 (file)
@@ -227,3 +227,5 @@ VALUE       Disconnect-Cause                VPN-Session-Limit       607
 VALUE  Disconnect-Cause                VPN-Call-Redirect       608
 
 END-VENDOR     Cisco
+
+ALIAS          Cisco Vendor-Specific.Cisco
index 6202f479c8161440981120566c7ee59e87d6b63e..59d5eeb08c17b14740e7f697aaf11e1c99ed0b79 100644 (file)
@@ -1575,6 +1575,29 @@ fr_slen_t tmpl_attr_ref_afrom_unresolved_substr(TALLOC_CTX *ctx, tmpl_attr_error
        return fr_sbuff_set(name, &our_name);
 }
 
+/*
+ *     Add attr_ref when we've parsed an intermediate dictionary name
+ *     which is itself a ref.
+ */
+static void tmpl_attr_ref_fixup(TALLOC_CTX *ctx, tmpl_t *vpt, fr_dict_attr_t const *da)
+{
+       tmpl_attr_t *ar;
+
+       if (tmpl_attr_tail_da(vpt) == da) return;
+
+       if (!da->parent->flags.is_root) tmpl_attr_ref_fixup(ctx, vpt, da->parent);
+
+       MEM(ar = talloc(ctx, tmpl_attr_t));
+       *ar = (tmpl_attr_t) {
+               .ar_num = NUM_UNSPEC,
+               .ar_type = TMPL_ATTR_TYPE_NORMAL,
+               .ar_da = da,
+               .ar_parent = da->parent,
+       };
+
+       tmpl_attr_insert(vpt, ar);
+}
+
 /** Parse an attribute reference, either an OID or attribute name
  *
  * @note Do not call directly.
@@ -1662,7 +1685,10 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t
                 */
                if (da) {
                        our_parent = da->parent;
-                       fr_assert(our_parent->flags.is_root);
+
+                       if (!our_parent->flags.is_root) {
+                               tmpl_attr_ref_fixup(ctx, vpt, our_parent);
+                       }
                }
        } else {
                fr_assert(parent != NULL);
diff --git a/src/tests/keywords/vsa-alias b/src/tests/keywords/vsa-alias
new file mode 100644 (file)
index 0000000..23458c9
--- /dev/null
@@ -0,0 +1,10 @@
+#
+#  Alias from Cisco -> Vendor-Specific.Cisco
+#
+&Cisco.AVPair := "foo"
+
+if !(&Vendor-Specific.Cisco.AVPair == "foo") {
+       test_fail
+}
+
+success