Ok, this is not tested but hopefully should help you get started:
In your radiusd.conf you need to define an exec module:
modules {
...
exec allow9to5 {
wait = yes
program = "/usr/bin/php -f /somedir/allow9-5.php"
input_pairs = request
output_pairs = reply
packet_type = Access-Request
}
...
}
Then for the module itself (allow9-5.php):
<?php
// you might need this with earlier versions of php which
// always spit out http headers. This will buffer all of
// that and later we will throw it away
ob_start();
// just in case you want to read some
// attributes ...
$nasip = $_ENV['NAS_IP_ADDRESS'];
$nasid = $_ENV['NAS_IDENTIFIER'];
// throw away anything already in the output buffer
ob_end_clean();
// Now to the meat, first see if we are within the window
// get current date
$date = getdate();
$curhour = $date['hour'];
if ($curhour > 9 || $curhour <= 17) {
// current unix timestamp
$curtime = time();
// unix timestamp at 17:00
$fivepm = mktime (17, 00, 00, $date['month'], $date['day'],
$date['year']);
// seconds until 17:00
$seconds = $fivepm - $curtime;
$minutes = $seconds / 60;
// return this as an attribute
echo "Session-Timeout := \"$minutes\"";
// zero return means accept
$retval = 0;
} else {
// otherwise reject
$retval = 1;
}
exit ($retval);
?>
Note that some 4.x phps print the return value to stdout - beware of this.
Also note that the responsibility of disconnecting is with the NAS - you are
telling it how long to allow the session which if our arithmetic is correct
is until 5pm. At that time you are at the mercy of your NAS - make sure it is
configured to do this.
Hope this helps,
Regards,
Simon.
---
On Friday 03 September 2004 14:56, Edgars wrote:
> can somone explain how rlm_exec module works?
> i'm interested in how to run *.php program before user authentication,
> is this module capable of doing that?
> How and in what form to pass the necessary attributes to the PHP program
> and what should be returned?
>
> Your help will be greatly appreciated!
> Edgars
>
> -
> List info/subscribe/unsubscribe? See
> http://www.freeradius.org/list/users.html
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html