From: Arran Cudbard-Bell Date: Thu, 7 Dec 2023 18:40:32 +0000 (-0600) Subject: Fix support for outer, and fix support for caller and subrequests in conditions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9f73dceda035f748fbbcbb5134d0e6fd209a6ed;p=thirdparty%2Ffreeradius-server.git Fix support for outer, and fix support for caller and subrequests in conditions --- diff --git a/src/lib/server/tmpl_tokenize.c b/src/lib/server/tmpl_tokenize.c index 5cbccd9e357..7c481098001 100644 --- a/src/lib/server/tmpl_tokenize.c +++ b/src/lib/server/tmpl_tokenize.c @@ -610,16 +610,27 @@ static fr_slen_t tmpl_request_ref_list_from_substr(TALLOC_CTX *ctx, tmpl_attr_er /* * If the caller is asking for a namespace, then walk back up the tmpl_rules_t to find a parent namespace. */ - if (namespace && (ref == REQUEST_PARENT) && t_rules->parent) { + if (namespace && t_rules->parent) { t_rules = t_rules->parent; - if (t_rules->attr.namespace) { - *namespace = t_rules->attr.namespace; - } else if (t_rules->attr.dict_def) { - *namespace = fr_dict_root(t_rules->attr.dict_def); + switch (ref) { + case REQUEST_OUTER: + while (t_rules->parent) t_rules = t_rules->parent; /* Walk back to the root */ + FALL_THROUGH; - } else { - *namespace = NULL; + case REQUEST_PARENT: + if (t_rules->attr.namespace) { + *namespace = t_rules->attr.namespace; + } else if (t_rules->attr.dict_def) { + *namespace = fr_dict_root(t_rules->attr.dict_def); + + } else { + *namespace = NULL; + } + break; + + default: + break; } } diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index b25e20d41f9..e727bdf168c 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -3413,6 +3413,7 @@ static unlang_t *compile_if_subsection(unlang_t *parent, unlang_compile_t *unlan ssize_t slen; tmpl_rules_t t_rules = (tmpl_rules_t) { + .parent = unlang_ctx->rules->parent, .attr = { .dict_def = xr_rules.tr_rules->dict_def, .list_def = request_attr_request, diff --git a/src/tests/modules/cache_rbtree/cache-not-radius.unlang b/src/tests/modules/cache_rbtree/cache-not-radius.unlang index 406732872fc..afd1220fe17 100644 --- a/src/tests/modules/cache_rbtree/cache-not-radius.unlang +++ b/src/tests/modules/cache_rbtree/cache-not-radius.unlang @@ -5,6 +5,7 @@ subrequest dhcpv4.Discover { caller dhcpv4 { &parent.Gateway-IP-Address = 127.0.0.1 &parent.control.Your-IP-Address = 127.0.0.2 + &outer.control.Framed-IP-Address = 127.0.0.3 cache_not_radius if (!ok) { @@ -15,6 +16,14 @@ subrequest dhcpv4.Discover { if (!updated) { reject } + + if (!&parent.Your-IP-Address) { + reject + } + + if (!&outer.Framed-IP-Address) { + reject + } } } } diff --git a/src/tests/modules/cache_rbtree/module.conf b/src/tests/modules/cache_rbtree/module.conf index 3462b989009..4a0032386a7 100644 --- a/src/tests/modules/cache_rbtree/module.conf +++ b/src/tests/modules/cache_rbtree/module.conf @@ -84,5 +84,6 @@ cache cache_not_radius { update { &parent.Your-IP-Address := &parent.control.Your-IP-Address + &outer.Framed-IP-Address := &outer.control.Framed-IP-Address } }