Exec remote command in Preprocess
Hello I want to make some additional checks under authorization. I edited default file in preprocess section. This is how I want to make it: preprocess if (%{exec:/path/to/script.sh} == "some numbers"){ update control { Auth-Type := "Accept" } } else { update control { Auth-Type := "Reject" } } However this doesn't work. Debug shows: Bare %{...} is invalid in condition at: %{exec:/path/to/script.sh} == "some numbers") What im doing wrong ? Is there possibility to execute remote script in this place ?
Rafal Pilos wrote:
if (%{exec:/path/to/script.sh} == "some numbers"){
That's wrong. See "man unlang".
However this doesn't work. Debug shows: Bare %{...} is invalid in condition at: %{exec:/path/to/script.sh} == "some numbers") What im doing wrong ?
Add quotes around the exec: if ("%{exec:...}" == "blah") {
Is there possibility to execute remote script in this place ?
Yes. Alan DeKok.
Thanks, I updated config and now is accepted. if ("%{exec:/test/script.sh %{User-Name}}" == "257"){ update control { Auth-Type := "Accept" } } else { update control { Auth-Type := "Reject" } However theres another problem, script returns 257 but Exec: program returned: 0 Fri Feb 28 22:59:34 2014 : Info: ++[preprocess] = ok Fri Feb 28 22:59:34 2014 : Info: ++? if ("%{exec:/test/script.sh %{User-Name}}" == "257") Fri Feb 28 22:59:34 2014 : Info: Executing /test/script.sh %{User-Name} Fri Feb 28 22:59:34 2014 : Info: expand: %{User-Name} -> user01 Fri Feb 28 22:59:34 2014 : Debug: Exec output: 257 Fri Feb 28 22:59:34 2014 : Debug: Exec plaintext: 257 Fri Feb 28 22:59:34 2014 : Info: Exec: program returned: 0 Fri Feb 28 22:59:34 2014 : Info: result 0 Fri Feb 28 22:59:34 2014 : Info: expand: %{exec:/test/script.sh %{User-Name}} -> 257 Fri Feb 28 22:59:34 2014 : Info: ? Evaluating ("%{exec:/test/script.sh %{User-Name}}" == "257") -> FALSE Fri Feb 28 22:59:34 2014 : Info: ++? if ("%{exec:/test/script.sh %{User-Name}}" == "257") -> FALSE Fri Feb 28 22:59:34 2014 : Info: ++else else { Fri Feb 28 22:59:34 2014 : Info: +++update control { What should I do to use output from script (257) directly as result to compare ? 2014-02-28 20:39 GMT+01:00 Alan DeKok <aland@deployingradius.com>:
Rafal Pilos wrote:
if (%{exec:/path/to/script.sh} == "some numbers"){
That's wrong. See "man unlang".
However this doesn't work. Debug shows: Bare %{...} is invalid in condition at: %{exec:/path/to/script.sh} == "some numbers") What im doing wrong ?
Add quotes around the exec:
if ("%{exec:...}" == "blah") {
Is there possibility to execute remote script in this place ?
Yes.
Alan DeKok. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Rafal Pilos wrote:
Thanks, I updated config and now is accepted.
Good.
However theres another problem, script returns 257 but Exec: program returned: 0
No... the return code from the program is 0. The string returned is different.
Fri Feb 28 22:59:34 2014 : Debug: Exec output: 257
That's the program output.
Fri Feb 28 22:59:34 2014 : Info: Exec: program returned: 0
That's the program return value.
Fri Feb 28 22:59:34 2014 : Info: result 0 Fri Feb 28 22:59:34 2014 : Info: expand: %{exec:/test/script.sh %{User-Name}} -> 257 Fri Feb 28 22:59:34 2014 : Info: ? Evaluating ("%{exec:/test/script.sh %{User-Name}}" == "257") -> FALSE
Hmm... you probably have the "exec" module misconfigured. You need: wait = yes output = none Alan DeKok.
participants (2)
-
Alan DeKok -
Rafal Pilos