RADIUS: adding daily time limits

Kevin Kadow (radius@msg.net)
Sun, 3 Nov 1996 01:30:05 -0600 (CST)

I've figured out a reasonable method for providing a daily total time
limit on a per-user basis. It adds one value to the RADIUS dictionary
(how do I get an 'official' value?). It's simple, reasonably foolproof,
and doesn't require a big external database or other horrible kludges.

THIS IS NOT AN ANNOUNCEMENT.
THIS IS NOT AN OFFICIAL RADIUS FEATURE...

The code is about 90% finished and 10% tested.

Basically, my idea is to have radius accounting maintain an additional
directory 'daily_limit' under the 'radacct' directory. In here is one
file for each user who has logged _OFF_ today, containing one line with
two fields, like this:

1D0002EA 3712

The first field is their most recent Session-Id, the second the total seconds
used today. The session ID is recorded to prevent 'double billing' in the
case where multiple STOP records are received. Nasty, but unavoidable.

In order to reset the limits at midnight, you'll have to add a cron job
to wipe out the directory and it's contents, something like this:

0 0 * * * cd /var/radius/radacct; mv daily_limit daily_old; rm -rf daily_old

Of course, if you'd rather have a monthly limit instead, just remove the
'seconds since midnight' code and run the cron monthly instead of daily :-)

I've got the algorithm down, but there are still 5 things to be done
to actually get the daily time limit solution working-

1. It only works if you have another mechanism to prevent
simultaneous logins (such as my modified pmwhoall.pl).

2. It requires that you also set a Session-Limit in the 'users' file
so it can enforce the daily limit. This is a good thing if you
want to limit users to say, 30 minutes per call, 2 hours per day,
and can easily be fixed with a bit of code in 'radiusd.c'.

3. It should tell the user their minutes used and time remaining.

4. I'd really like to add code to make the primary Unix group-ID
a check item, so time limits can be set on a user group basis,
but that can wait.

5. I don't have the time to finish and test it this week.

If you'd like to give it a try and/or finish it off (you can have top billing),
what I've hacked up so far is available as source 'diffs' at:

http://www.msg.net/utility/PM/daily/

If you pick it up and make some use of it, or just want to take it over
entirely, my radius patch code is under the GNU license.