Hi, When I put something like that into unlang rules: %{%{Operator-Name}:-} my server fails with ASSERT FAILED src/main/xlat.c[1509]: node->alternate != NULL The same is with other attribute names. When I put non empty default value all goes smoothly. I'm testing the current master git version: radiusd: FreeRADIUS Version 3.0.0 (git #6d78b5f) Maja -- Maja Gorecka-Wolniewicz mgw@umk.pl Uczelniane Centrum Information & Communication Informatyczne Technology Centre Uniwersytet Mikolaja Kopernika Nicolaus Copernicus University Coll. Maximum, pl. Rapackiego 1, 87-100 Torun, Poland tel.: +48 56-611-27-40 fax: +48 56-622-18-50 tel. kom.: +48-693032574
Maja Wolniewicz wrote:
When I put something like that into unlang rules:
%{%{Operator-Name}:-}
That should be a parse error.
my server fails with ASSERT FAILED src/main/xlat.c[1509]: node->alternate != NULL
The same is with other attribute names. When I put non empty default value all goes smoothly.
The solution is to do a "git pull", and re-build. I've just pushed a fix. Alan DeKok.
W dniu 13.05.2013 15:07, Alan DeKok pisze:
Maja Wolniewicz wrote:
When I put something like that into unlang rules:
%{%{Operator-Name}:-} That should be a parse error.
my server fails with ASSERT FAILED src/main/xlat.c[1509]: node->alternate != NULL
The same is with other attribute names. When I put non empty default value all goes smoothly. The solution is to do a "git pull", and re-build. I've just pushed a fix. Thanks.
Now update reply { Chargeable-User-Identity = "%{md5:${policy.cui_hash_key}%{tolower:%{User-Name}}%{%{Operator-Name}:-}}" } produces (10) ERROR: %{md5:changeme%{tolower:%{User-Name}}%{%{Operator-Name}:-}} (10) ERROR: ^ Empty expansion is invalid is it right behaviour? It works in FR2. Maja
Alan DeKok. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
-- Maja Gorecka-Wolniewicz mgw@umk.pl Uczelniane Centrum Information & Communication Informatyczne Technology Centre Uniwersytet Mikolaja Kopernika Nicolaus Copernicus University Coll. Maximum, pl. Rapackiego 1, 87-100 Torun, Poland tel.: +48 56-611-27-40 fax: +48 56-622-18-50 tel. kom.: +48-693032574
Maja Wolniewicz wrote:
update reply { Chargeable-User-Identity = "%{md5:${policy.cui_hash_key}%{tolower:%{User-Name}}%{%{Operator-Name}:-}}" }
produces (10) ERROR: %{md5:changeme%{tolower:%{User-Name}}%{%{Operator-Name}:-}} (10) ERROR: ^ Empty expansion is invalid
is it right behaviour?
I would say yes.
It works in FR2.
Hmm... a lot of things worked by accident in v2. The v3 code has a LOT of cleanups and fixes. You can work around this by doing: %{md5:changeme%{tolower:%{User-Name}}%{%{Operator-Name}:-""}} Which also works in v2. Alan DeKok.
Alan DeKok, 13.05.2013 18:30:
(10) ERROR: %{md5:changeme%{tolower:%{User-Name}}%{%{Operator-Name}:-}} %{md5:changeme%{tolower:%{User-Name}}%{%{Operator-Name}:-""}}
I may be missing something here, but aren't unset attributes just expanded to an empty string? If so, what is difference between the outcome of %{%{Unset-Attribute}:-""} and a simple %{Unset-Attribute} ? Oh, and btw: As the :- syntax is copied from Unix shells, shouldn't it just be "%{Attribute-Name:-attribute not set}", i.e. without additional "%{}"? In shells it's "${VARNAME:-VARNAME is empty}", not "${${VAR}:-VAR is empty}" (except if you have stored a variable name VAR, of course). Using :- with a static string doesn't make much sense, so the extra %{} is kind of redundant. But I guess it's too late for such a change now (maybe not for 3.0). Regards Jakob
Jakob Hirsch wrote:
I may be missing something here, but aren't unset attributes just expanded to an empty string?
Yes.
If so, what is difference between the outcome of %{%{Unset-Attribute}:-""} and a simple %{Unset-Attribute}
Nothing. But %{%{Foo-Bar}:-} is redundant. It says "If there's no Foo-Bar, then use an empty string. But if there's no Foo-Bar, the result of a %{} expansion *is* an empty string.
Oh, and btw: As the :- syntax is copied from Unix shells, shouldn't it just be "%{Attribute-Name:-attribute not set}", i.e. without additional "%{}"? In shells it's "${VARNAME:-VARNAME is empty}", not "${${VAR}:-VAR is empty}" (except if you have stored a variable name VAR, of course). Using :- with a static string doesn't make much sense, so the extra %{} is kind of redundant. But I guess it's too late for such a change now (maybe not for 3.0).
The change was made deliberately, and to avoid bugs. In shell, variable names can't have colons. In FreeRADIUS modules, they can. e.g. this is ambiguous: %{module:-foo:-bar} Is "-foo" a parameter to "module"? This is not ambiguous: %{%{module:-foo}:-bar} As a result, this behavior will remain in v3. Anyone wanting to see more cases of what works and what doesn't can read src/tests/xlat.txt Alan DeKok.
Alan DeKok, 15.05.2013 15:27:
If so, what is difference between the outcome of %{%{Unset-Attribute}:-""} and a simple %{Unset-Attribute} Nothing.
So the OP's assignment "%{md5:${policy.cui_hash_key}%{tolower:%{User-Name}}%{%{Operator-Name}:-}}" could simply rewritten to this? "%{md5:${policy.cui_hash_key}%{tolower:%{User-Name}}%{Operator-Name}}"
The change was made deliberately, and to avoid bugs. In shell, variable names can't have colons. In FreeRADIUS modules, they can.
Oh, ok, I wasn't aware if this.
On 15 May 2013, at 12:35, Jakob Hirsch <jh@plonk.de> wrote:
Alan DeKok, 15.05.2013 15:27:
If so, what is difference between the outcome of %{%{Unset-Attribute}:-""} and a simple %{Unset-Attribute} Nothing.
So the OP's assignment
"%{md5:${policy.cui_hash_key}%{tolower:%{User-Name}}%{%{Operator-Name}:-}}"
could simply rewritten to this?
"%{md5:${policy.cui_hash_key}%{tolower:%{User-Name}}%{Operator-Name}}"
Yes. Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS Development Team
W dniu 15.05.2013 18:40, Alan DeKok pisze:
Jakob Hirsch wrote:
So the OP's assignment
"%{md5:${policy.cui_hash_key}%{tolower:%{User-Name}}%{%{Operator-Name}:-}}"
could simply rewritten to this?
"%{md5:${policy.cui_hash_key}%{tolower:%{User-Name}}%{Operator-Name}}" Yes. I'm still having trouble with it. It works correctly when Operator-Name is set, but when Operator-Name is unset (it does not appear in Access-Request packets)
${policy.cui_hash_key}%{tolower:%{User-Name}}%{Operator-Name} where cui_hash_key is changeme, User-Name is someone@somewhere is expanded as changemesomeone@somewere_ expand: 'changeme%{tolower:%{User-Name}}%{Operator-Name}' -> 'changemesomeone@somewere_' the same is when I have ${policy.cui_hash_key}%{tolower:%{User-Name}}%{%{Operator-Name}:-aaa} expand: 'changeme%{tolower:%{User-Name}}%{%{Operator-Name}:-aaa}' -> 'changemesomeone@somewere_' It seems that Operator-Name is set then to _ Maja
Alan DeKok. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
-- Maja Gorecka-Wolniewicz mgw@umk.pl Uczelniane Centrum Information & Communication Informatyczne Technology Centre Uniwersytet Mikolaja Kopernika Nicolaus Copernicus University Coll. Maximum, pl. Rapackiego 1, 87-100 Torun, Poland tel.: +48 56-611-27-40 fax: +48 56-622-18-50 tel. kom.: +48-693032574
Maja Wolniewicz wrote:
I'm still having trouble with it. It works correctly when Operator-Name is set, but when Operator-Name is unset (it does not appear in Access-Request packets)
${policy.cui_hash_key}%{tolower:%{User-Name}}%{Operator-Name}
where cui_hash_key is changeme, User-Name is someone@somewhere
is expanded as changemesomeone@somewere_
Hmm... I guess you'll have to use %{%{Operator-Name}:-} I'll make sure that works for v3. Alan DeKok.
W dniu 16.05.2013 23:44, Alan DeKok pisze:
Maja Wolniewicz wrote:
I'm still having trouble with it. It works correctly when Operator-Name is set, but when Operator-Name is unset (it does not appear in Access-Request packets)
${policy.cui_hash_key}%{tolower:%{User-Name}}%{Operator-Name}
where cui_hash_key is changeme, User-Name is someone@somewhere
is expanded as changemesomeone@somewere_ Hmm... I guess you'll have to use %{%{Operator-Name}:-} Today with last git version the sever dies while parsing it.
Maja
I'll make sure that works for v3.
Alan DeKok. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
-- Maja Gorecka-Wolniewicz mgw@umk.pl Uczelniane Centrum Information & Communication Informatyczne Technology Centre Uniwersytet Mikolaja Kopernika Nicolaus Copernicus University Coll. Maximum, pl. Rapackiego 1, 87-100 Torun, Poland tel.: +48 56-611-27-40 fax: +48 56-622-18-50 tel. kom.: +48-693032574
participants (4)
-
Alan DeKok -
Arran Cudbard-Bell -
Jakob Hirsch -
Maja Wolniewicz