Auto-logoff facility in Unix

ebk at iedl02.UUCP ebk at iedl02.UUCP
Sun Apr 29 09:25:05 AEST 1984


> Does anyone know about or have a facility implemented on Unix Version 7
> or System V to Auto-logoff users in the system who have been idle for a
> period of time? Suggestions on how to implement such a facility would
> be very welcome also.

A number of auto-logoff mechanisms were written at ODU as undergraduate
projects. The most common mechanism was to check the difference between the
accessed and modified dates of the tty file. This has the unfortunate effect
of killing anyone running a long computation. One version peeked around
in the kernel data and watched the accumulated runtime or some such nonsense.
This is similar to trying to do something whenever anyone logs off - UNIX
wasn't set up for administrative overseeing like this.

The best, and certainly safest way of doing this is to add a couple
lines to the shell(s). Before the read for the command line, say
alarm(MAXIDLETIME);
You might want to catch SIGALRM and print a message or something.
This has the advantage that you never kill anyone who is computing without
using the terminal, but is easy to get around - just type `ed'.

Any check on tty use (kill the process if its wchan is a tty and it's
been idle for x seconds) is just as easy to get around: `sleep 3600'.
If you try and get too clever, someone is going to resort to:
main() {for(;;);}
and kill your load average.

I was going to digress on how non-UNIX-like this type of thing was,
but I suppose that there are times where this is necessary (overcrowded
terminal room at a university, for instance.) Just be sure that you
and your users know exactly why you are doing it. Chances are you
have at least one hacker-type there who will figure out how to get
around it, and if it's perceived as "administrative oppression",
pretty soon everyone will know except you.  A practical guideline:
only run it during whatever hours and days are "prime time" for you,
and don't exempt anyone except the operator, if you have one.

------------------------------------------------------------------------
John Owens		    (804) 978-5826
...!decvax!mcnc!uvacs!icase!oducs1!owens_j



More information about the Comp.unix.wizards mailing list