xlat: something like eval()? problems with avp into in another avp
Hi, I would like to know how "expand" an avp into in another avp. below my example. Wed Sep 16 13:37:43 2015 : Debug: (0) policy my.captive_redirect { Wed Sep 16 13:37:43 2015 : Debug: (0) update { Wed Sep 16 13:37:43 2015 : Debug: (0) EXPAND %{My-Portal-Url} Wed Sep 16 13:37:43 2015 : Debug: (0) --> http://meu-host.intra.net/integration-bus/v1/redir/start?acctSessionId=%{Acct-Session-Id} Wed Sep 16 13:37:43 2015 : Debug: (0) &reply:Alc-Wlan-Portal-Url := http://meu-host.intra.net/integration-bus/v1/redir/start?acctSessionId=%{Acct-Session-Id} Wed Sep 16 13:37:43 2015 : Debug: (0) } # update = noop Wed Sep 16 13:37:43 2015 : Debug: (0) } # policy alcatel.captive_redirect = noop example: but, when calling the %{redis: ..}, they resolve everything fine. Wed Sep 16 13:37:43 2015 : Debug: (0) policy mcare-redis.set_my_portal_url { Wed Sep 16 13:37:43 2015 : Debug: (0) if (!&My-Portal-Url) { Wed Sep 16 13:37:43 2015 : Debug: (0) if (!&My-Portal-Url) -> FALSE Wed Sep 16 13:37:43 2015 : Debug: (0) if (&My-Portal-Url) { Wed Sep 16 13:37:43 2015 : Debug: (0) if (&My-Portal-Url) -> TRUE Wed Sep 16 13:37:43 2015 : Debug: (0) if (&My-Portal-Url) { Wed Sep 16 13:37:43 2015 : Debug: %{redis_db03:HSET %{Acct-Session-Id} My-Portal-Url "%{My-Portal-Url}"} Wed Sep 16 13:37:43 2015 : Debug: Parsed xlat tree: Wed Sep 16 13:37:43 2015 : Debug: xlat --> redis_db03 Wed Sep 16 13:37:43 2015 : Debug: { Wed Sep 16 13:37:43 2015 : Debug: literal --> HSET Wed Sep 16 13:37:43 2015 : Debug: attribute --> Acct-Session-Id Wed Sep 16 13:37:43 2015 : Debug: literal --> My-Portal-Url " Wed Sep 16 13:37:43 2015 : Debug: attribute --> My-Portal-Url Wed Sep 16 13:37:43 2015 : Debug: literal --> " Wed Sep 16 13:37:43 2015 : Debug: } Wed Sep 16 13:37:43 2015 : Debug: rlm_redis (redis_db03): Reserved connection (0) Wed Sep 16 13:37:43 2015 : Debug: http://meu-host.intra.net/integration-bus/v1/redir/start?acctSessionId=%{Acct-Session-Id} Wed Sep 16 13:37:43 2015 : Debug: Parsed xlat tree: Wed Sep 16 13:37:43 2015 : Debug: literal --> http://meu-host.intra.net/integration-bus/v1/redir/start?acctSessionId= Wed Sep 16 13:37:43 2015 : Debug: attribute --> Acct-Session-Id Wed Sep 16 13:37:43 2015 : Debug: (0) EXPAND http://meu-host.intra.net/integration-bus/v1/redir/start?acctSessionId=%{Acct-Session-Id} Wed Sep 16 13:37:43 2015 : Debug: (0) --> http://meu-host.intra.net/integration-bus/v1/redir/start?acctSessionId=AB818... Wed Sep 16 13:37:43 2015 : Debug: rlm_redis (redis_db03): executing the query: "HSET AB818B000010C355F65FA1 My-Portal-Url " http://meu-host.intra.net/integration-bus/v1/redir/start?acctSessionId=%{Acct-Session-Id} "" Wed Sep 16 13:37:43 2015 : Debug: rlm_redis (redis_db03): Released connection (0) Wed Sep 16 13:37:43 2015 : Debug: (0) EXPAND %{redis_db03:HSET %{Acct-Session-Id} My-Portal-Url "%{My-Portal-Url}"} Wed Sep 16 13:37:43 2015 : Debug: (0) --> 0 Wed Sep 16 13:37:43 2015 : Debug: (0) } # if (&My-Portal-Url) = ok Wed Sep 16 13:37:43 2015 : Debug: (0) } # policy mcare-redis.set_my_portal_url = ok Alan, maybe a bug? :) -- Jorge Pereira
On Sep 16, 2015, at 9:53 AM, Jorge Pereira <jpereiran@gmail.com> wrote:
I would like to know how "expand" an avp into in another avp. below my example.
Wed Sep 16 13:37:43 2015 : Debug: (0) policy my.captive_redirect { Wed Sep 16 13:37:43 2015 : Debug: (0) update { Wed Sep 16 13:37:43 2015 : Debug: (0) EXPAND %{My-Portal-Url} Wed Sep 16 13:37:43 2015 : Debug: (0) --> http://meu-host.intra.net/integration-bus/v1/redir/start?acctSessionId=%{Acct-Session-Id} Wed Sep 16 13:37:43 2015 : Debug: (0) &reply:Alc-Wlan-Portal-Url := http://meu-host.intra.net/integration-bus/v1/redir/start?acctSessionId=%{Acct-Session-Id} Wed Sep 16 13:37:43 2015 : Debug: (0) } # update = noop Wed Sep 16 13:37:43 2015 : Debug: (0) } # policy alcatel.captive_redirect = noop
You can't do 2 layers of expansion. update request { Foo := "%{bar}" } will work. But if "bar" is itself an expansion, that won't wok. The "Foo" attribute will just get the string value of "bar", not the expanded version. The redis example is different. The RHS of the redis expansion %{redis: ... RHS ... } is itself expanded before being passed to redis. So a "double expansion" works there. Having the server *automatically* do double expansion of attributes would be terrible. Where would you stop? We'd be better off having an explicit "double expansion" thing: baz = "hello" bar := '%{baz}' # note single quotes... update request { Foo := "%{expand:%{Bar}}" } Which should work. Alan DeKok.
On 16 Sep 2015, at 14:53, Jorge Pereira <jpereiran@gmail.com> wrote:
Hi,
I would like to know how "expand" an avp into in another avp. below my example.
%{xlat:} is the xlat you're looking for to xlat your xlat. Can't remember if it's in v3.0.x though. %{map:} can also be used to evaluate AVP maps, again, not sure if it's in v3.0.x. If you run with -Xx the server should tell you which xlats were registered, but again, that may only be in v3.1.x. Hmm a pattern is emerging... Alan dislikes them, I think more on principle, but they are occasionally useful. -Arran Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
nice, %{xlat: ...} solve! Thanks A(L|rr)an!! -- Jorge Pereira On Wed, Sep 16, 2015 at 11:28 AM, Alan DeKok <aland@deployingradius.com> wrote:
On Sep 16, 2015, at 10:24 AM, Arran Cudbard-Bell < a.cudbardb@freeradius.org> wrote:
%{xlat:} is the xlat you're looking for to xlat your xlat.
Can't remember if it's in v3.0.x though.
Yes, it is. I'll have to go update the docs.
Alan DeKok.
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
participants (3)
-
Alan DeKok -
Arran Cudbard-Bell -
Jorge Pereira