Autolog 0.2

Autolog is a version of autologout (idleout-mcm) modified by me to allow
a more detailed configuration file, and to accept command line parameters.
According to David Dickson, the code originally came from the "Wizard's
Grabbag" from the May 1990 Unix World.  He ported the code essentially
unchanged.

Mike Mitchell added some code to read a file "/etc/autologout.exempt"
listing those users which should not be subject to auto logout.

My system required a little more sophisticated approach.  I wanted some
users to be logged off more aggressively than others.  I wanted my own
sessions to remain on line only if they existed on certain ports.
I also wanted users coming in over the net to be subject to a little
different idle time than other users.

My configuration file consists of multiple lines, each of which describes
a class of processes subject (or not subject) to a certain auto logout
procedure.  The first parameter on the line is a username regular 
expression pattern.  The second parameter is a tty line regular expression
pattern.  These parameters are followed by the idle time, the grace
period, a mailer switch, and an idle/total time switch.

The program reads the utmp file, entry by entry.  The username for
each 'user process' is compared to the entries in the configuration file.
The first entry to match both the name and the tty line of the process
will be used to conduct the auto logout.  

If no entries are found matching the process, or if the configuration 
file is not present, the program will rely upon internal variables 
describing the idle time, the grace period, and the mailing option.
These defaults can be set from the command line or hard coded in the source.
Note that if no configuration entry matches the process, the default action
is to kill the process.
If the configuration file is not found, the default is to kill every
idle process.
If you want the default to be "not to kill," put this "cleanup" pattern at
the end of the config file matching any username and any line:

.* .* 0 0 no

See the sample file autolog.conf (which is commented) for an example setup.

Instructions:

	1.	Edit the TIMEMAX, GRACE, and DOMAIL defines to reflect 
		any changes you might want (generally not necessary).
		
		If you want the binary somewhere besides /usr/sbin, edit
		the Makefile accordingly.
	
	2.	Type 'make install'.
	
	3.	Copy autolog.conf to /etc and then edit it to make the
		changes needed by your system.
	
	4.	Wait until the system has a bunch of idle processes.
		Run "autolog -d -n |less" and examine the output to see
		that the desired processes are going to "get the axe."
		If it looks good, try running "autolog -d" to make sure.
		When you're happy with your configuration file, setup cron.
	
	5.	In your Crontab file place a line that invokes
		autolog about every few minutes, such as:
		
		0,10,20,30,40,50 * * * * /usr/sbin/autolog
		
		On my system cron only runs the process at night.
		This way, users sessions stay on uninterrupted during the 
		workday.  I use the lines:

		0 20 * * * /usr/sbin/autolog
		0 22 * * * /usr/sbin/autolog
		0  1 * * * /usr/sbin/autolog
		

COMMAND LINE PARAMETERS:

    -a	(all processes) Print information on ALL utmp entries--not just
        user processes.
        
    -d	(debug mode) This is helpful in setting up your configuration file.
        The program runs in foreground rather than forking and it prints 
        out verbose messages about what it is doing.

    -n  (nokill) Use this to prevent autolog from actually "killing"
        anyone.  Use -d and -n together when setting up a new
        configuration file.  
       
    -f  config_file_name
        Use this to override the default: "/etc/autolog.conf"
    
    -l  log_file_name
        Use this to override the default: "/usr/adm/logoutlog"
        
        Note that if this file doesn't exist, no logging will happen.
        Create the file (with touch) to enable logging.
    
    -t  idle_time
        Use this to override the internal default idle time (minutes)

    -g  grace_period
        Use this to override the internal default grace period (seconds)
    
    -m  do_mail
        Use this to override the internal mailing switch.  If "yes"
        the program will send mail to the users right after killing them.

    -h  (hard) Do timeouts based on total session time--not idle time.
       

I don't know if Mike is supporting this too.  For that reason, I've
changed the name of the tar file and the executable so they can be better
distinguished.

I've received enough response that I suppose I'll support the source for
a while until it is stable and has a useful set of features.
I'll call this version 0.2.
Please let me know if you find any bugs etc.  I've seen reports that
the original source used to leave "wedged" processes laying around.
I've fixed one thing that might solve this, but I'm not sure.  I've
never seen the problem on my system.

Have fun knocking off those 'delinquent' processes!

Kyle Bateman
kyle@wicat.com
