External script
Amit Butere
amitbutere64 at gmail.com
Sun Apr 26 21:21:21 CEST 2015
HI Alan,
Thanks for Response, i should have sent output in first post only.
this is module config..
exec mpp_check {
wait = yes
packet_type = Access-Request
program = "/usr/bin/php5 -f ${confdir}/check.php %{User-Name}
%{WISPr-Location-ID}"
shell_escape = yes
input_pairs = request
output_pairs = reply
}
------------------------------------------------------------------------------------------------------------------------------------------
this is how i am calling module
if((control:Start-Date)&&(control:End-Date)&&(control:Allowed-City)){
mpp_check {
reject = 3
noop = 1
updated = 2
}
if(reject){
update control {
&Reply-Message := "Your account has expired, %{User-Name}"
}
ok = reject
}
elsif (updated) {
update reply {
&Reply-Message := "Accept "
Auth-Type := Accept
}
}
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
below is debug output..
Mon Apr 27 00:43:14 2015 : Debug: (0) if
((control:Start-Date)&&(control:End-Date)&&(control:Allowed-City))
Mon Apr 27 00:43:14 2015 : Debug: (0) if
((control:Start-Date)&&(control:End-Date)&&(control:Allowed-City)) -> TRUE
Mon Apr 27 00:43:14 2015 : Debug: (0) if
((control:Start-Date)&&(control:End-Date)&&(control:Allowed-City)) {
Mon Apr 27 00:43:14 2015 : Debug: (0) modsingle[authorize]: calling
mpp_check (rlm_exec) for request 0
Mon Apr 27 00:43:14 2015 : Debug: (0) mpp_check : Executing: /usr/bin/php5
-f /etc/freeradius/check.php %{User-Name} %{WISPr-Location-ID}
Mon Apr 27 00:43:14 2015 : Debug: %{User-Name}
Mon Apr 27 00:43:14 2015 : Debug: Parsed xlat tree:
Mon Apr 27 00:43:14 2015 : Debug: attribute --> User-Name
Mon Apr 27 00:43:14 2015 : Debug: {
Mon Apr 27 00:43:14 2015 : Debug: ref 2
Mon Apr 27 00:43:14 2015 : Debug: list 1
Mon Apr 27 00:43:14 2015 : Debug: tag -128
Mon Apr 27 00:43:14 2015 : Debug: }
Mon Apr 27 00:43:14 2015 : Debug: (0) mpp_check : EXPAND %{User-Name}
Mon Apr 27 00:43:14 2015 : Debug: (0) mpp_check : --> testtest
Mon Apr 27 00:43:14 2015 : Debug: %{WISPr-Location-ID}
Mon Apr 27 00:43:14 2015 : Debug: Parsed xlat tree:
Mon Apr 27 00:43:14 2015 : Debug: attribute --> WISPr-Location-ID
Mon Apr 27 00:43:14 2015 : Debug: {
Mon Apr 27 00:43:14 2015 : Debug: ref 2
Mon Apr 27 00:43:14 2015 : Debug: list 1
Mon Apr 27 00:43:14 2015 : Debug: tag -128
Mon Apr 27 00:43:14 2015 : Debug: }
Mon Apr 27 00:43:14 2015 : Debug: (0) mpp_check : EXPAND
%{WISPr-Location-ID}
Mon Apr 27 00:43:14 2015 : Debug: (0) mpp_check : --> IN-BA-AC-0001
Mon Apr 27 00:43:14 2015 : ERROR: (0) mpp_check : Failed parsing output
from: /usr/bin/php5 -f /etc/freeradius/check.php %{User-Name}
%{WISPr-Location-ID}: Expecting operator
Mon Apr 27 00:43:14 2015 : ERROR: (0) mpp_check : Program returned code (0)
and output '1'
Mon Apr 27 00:43:14 2015 : Debug: (0) modsingle[authorize]: returned from
mpp_check (rlm_exec) for request 0
Mon Apr 27 00:43:14 2015 : Debug: (0) [mpp_check] = fail
Mon Apr 27 00:43:14 2015 : Debug: (0) } # if
((control:Start-Date)&&(control:End-Date)&&(control:Allowed-City)) = fail
Mon Apr 27 00:43:14 2015 : Debug: (0) } # authorize = fail
Mon Apr 27 00:43:14 2015 : Auth: (0) Invalid user (mpp_check: Failed
parsing output from: /usr/bin/php5 -f /etc/freeradius/check.php
%{User-Name} %{WISPr-Location-ID}: Expecting operator): [testtest/test]
(from client TEST-NAS port 2159018375 cli 00:0C:29:56:AB:8F)
Mon Apr 27 00:43:14 2015 : Debug: (0) Using Post-Auth-Type Reject
Mon Apr 27 00:43:14 2015 : Debug: (0) # Executing group from file
/etc/freeradius/sites-enabled/default
Mon Apr 27 00:43:14 2015 : Debug: (0) Post-Auth-Type REJECT {
i want to know how i can send module output back to radius as noop or
module ok
Thanks
Amit B.
On Sat, Apr 25, 2015 at 5:09 PM, Alan DeKok <aland at deployingradius.com>
wrote:
> On Apr 25, 2015, at 6:28 AM, Amit Butere <amitbutere64 at gmail.com> wrote:
> > I am trying to write external Php script and return module codes and
> match
> > those module codes using unlang .
>
> There's a sample script in scripts/exec-program-wait in the distribution
> "tar" file.
>
> > My script is being called and I can see that in debug.
> > The error I get here is .
> >
> > Failed parsing output from script.php attributes : expecting operator
>
> So... what is the output? Is it a secret?
>
> > I am returning values as 1 for success and 0 for fail
> > Ultimately radius says module fail.
> >
> > I would be checking what operators to return value from Php script.
>
> This is documented, with examples.
>
> http://networkradius.com/doc/3.0.8/raddb/mods-available/exec.html
>
> Alan DeKok.
>
>
> -
> List info/subscribe/unsubscribe? See
> http://www.freeradius.org/list/users.html
More information about the Freeradius-Users
mailing list