I have a internal check Attribute My-Test defined as string. I have the following in authorize update reply { Reply-Message = " Hi " } switch control:My-Test { case "500" { update control { Auth-Type := Reject } update reply { Reply-Message = " Rejected " } } case { update control { Auth-Type := PAM } update reply { Reply-Message = " Accepted " } } Firstly I noticed that I can not update an attribute twice as I always get the reply message Hi. Secondly the switch case does not work but an if does if (control:My-Test == "500" ) { update control { Auth-Type := Reject } update reply { Reply-Message = " Rejected " } } else { update control { Auth-Type := PAM } update reply { Reply-Message = " Accepted " } } Is this a bug or wrong programming ? Thank you Markus
Markus Moeller wrote:
I have a internal check Attribute My-Test defined as string. I have the following in authorize .. switch control:My-Test {
The switch statement should use double quotes: "%{control:My-Test}"
case {
... Which will always be taken, because the string above wasn't expanded
update reply { Reply-Message = " Accepted "
Which will not over-write the previous Reply-Message, because you used "=", and not ":=". Alan DeKok.
Does this mean it is treated differently in an if condition where I don't need the quotes ? Couldn't the switch statement treat the word the same way as the if statement treats the left hand side word and the case word like the right hand side of an if statement ? Thank you Markus "Alan DeKok" <aland@deployingradius.com> wrote in message news:479C2E97.7020207@deployingradius.com...
Markus Moeller wrote:
I have a internal check Attribute My-Test defined as string. I have the following in authorize .. switch control:My-Test {
The switch statement should use double quotes: "%{control:My-Test}"
case {
...
Which will always be taken, because the string above wasn't expanded
update reply { Reply-Message = " Accepted "
Which will not over-write the previous Reply-Message, because you used "=", and not ":=".
Alan DeKok. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Markus Moeller wrote:
Does this mean it is treated differently in an if condition where I don't need the quotes ?
No. The "man" page makes this clear. As of 2.0.1, you don't need quotes in certain cases when doing conditional comparisons. The same "man" page also says that for "switch" statements, the statement is expanded if it is in double quotes.
Couldn't the switch statement treat the word the same way as the if statement treats the left hand side word and the case word like the right hand side of an if statement ?
Yes. As always, patches are welcome. Alan DeKok.
participants (2)
-
Alan DeKok -
Markus Moeller