(RADIATOR) Putting PostAuthHook script in background.

Matthew Trout matthewtrout at businessserve.co.uk
Fri Feb 13 06:26:40 CST 2004


On Fri, Feb 13, 2004 at 03:56:06PM -0800, Ziaur Rahman wrote:
> 
> Well, actually I wrote a perl script which updates my DynamicDNS server on
> specific users' login and logout. So, based on the Session Status I update
> the DNS server (remote). The script does the following things step by step:
> 
> 1. On every call from PostAuthHook, it connects to a local mysql database to
> see if the user is being enabled for DDNS or not.
> 2. If the user is disabled, it simply quits.
> 3. If the use is enabled, it checks the Acct-Status-Type attribute supplied
> by radiator.
> 4. If the Acct-Status-Type is Start, it adds the Framed-IP-Address in the
> DynamicDNS against the host registered for the user.
> 5. If the Acct-Status-Type is Stop, it removes the host record for that
> spacific user from the DNS.
> 
> So, if for any reason, the remote DNS server cannot be reached, radiator
> stalls. The irony is, it doesn't even resume operations once the DNS server
> is back up. If I could even mention a timeout for the PostAuthHook scripts
> response then it would be nice. 

A quick idea - you could just have your hook do something like the following

open OUT, ">/some/dir/.temp";
print OUT $status;
close OUT;
link('/some/dir/.temp', '/some/dir/'.$user);
unlink('/some/dir/.temp');

then have a little shell script that sits doing

while 1
do
  sleep 1
  for i in `ls /some/dir`
  do
    perl scriptname $i `cat /some/dir/$i` &
    rm $i
  done
done

so your perl script gets user, status in its @ARGV

put a line containing "alarm 30;" at the top of your script so it dies if
it hasn't got anywhere after 30 seconds, and you're sorted

I use a similar system to schedule open relay scans of static dial and DSL
users, although mine ignores any file less than 15 seconds old to ensure
they've had time to get properly connected before I scan them

This also has the advantage that even if one copy of the script hangs,
future requests will continue to be processed for DNS as well, but that can
never affect your radiator instance.

-- 
Matt S Trout
Network Programmer
Business Serve plc
===
Archive at http://www.open.com.au/archives/radiator/
Announcements on radiator-announce at open.com.au
To unsubscribe, email 'majordomo at open.com.au' with
'unsubscribe radiator' in the body of the message.


More information about the radiator mailing list