Freeradius and php script [sec=unclassified]
Ranner, Frank MR
Frank.Ranner at defence.gov.au
Wed Sep 5 05:36:29 CEST 2007
From: freeradius-users-bounces at lists.freeradius.org
[mailto:freeradius-users-bounces at lists.freeradius.org] On Behalf Of
Khaldon manIP
Sent: Wednesday, 5 September 2007 02:12
To: freeradius-users at lists.freeradius.org
Subject: Freeradius and php script
Hi all,
I finally found out how to launch a script after authentication:
I have first created a module
exec modatt {
wait = yes
program = "/home/raduser/test.php %{User-Name} "
input_pairs = request
output_pairs = reply
}
and then I have added it in instantiate and authorize section
here is the php script (test.php):
#!/usr/bin/php
<?php
$argv = $_SERVER['argv'];
if ( $argv[1] == "toto")
echo "Session-Timeout:=100";
else
echo "Session-Timeout:=50";
?>
But I still have a problem: the session-timeout attribute is not
sent to the NAS.
The debug output is hereunder:
Tue Sep 4 17:26:57 2007 : Debug: Exec-Program output:
Session-Timeout:=100
Tue Sep 4 17:26:57 2007 : Debug: Exec-Program-Wait:
value-pairs: ,Session-Timeout:=100
Tue Sep 4 17:26:57 2007 : Error: Exec-Program-Wait:
/home/raduser/test.php %{User-Name} : unparsable reply
Tue Sep 4 17:26:57 2007 : Debug: Exec-Program: returned: 0
But I really don't know why because I execute a sh script
(instead of a php script), it works very well!!
here is my sh script (test.sh):
#!/bin/sh
if [ $1 == "toto" ]; then
echo "Session-Timeout:=100"
else
echo "Session-Timeout:=53"
fi
debug trace:
Tue Sep 4 17:58:00 2007 : Debug: Exec-Program output:
Session-Timeout:=100
Tue Sep 4 17:58:00 2007 : Debug: Exec-Program-Wait:
value-pairs: Session-Timeout:=100
Tue Sep 4 17:58:00 2007 : Debug: Exec-Program: returned: 0
I don't see any difference between the scripts (except one is
working and the other one not)....
Please, advise me...
Many Thanks
Try:
#!/usr/bin/php
<?php
$argv = $_SERVER['argv'];
if ( $argv[1] == "toto")
echo "Session-Timeout:=100\n";
else
echo "Session-Timeout:=50\n";
return 0;
?>
That is a more accurate emulation of the shell script and is immune to
extraneous white space after the php closing tag.
Regards
Frank Ranner
More information about the Freeradius-Users
mailing list