Home | About Me | Photos | My Blog | Movies | Academic | Ideas | Computers | Online Magazines | Clubs & Organizations | Bookmarks
 
 

Logoutd

Under SunOS 4.x there was a program called idledaemon. One of the functions of this daemon was to scan for idle users and log them out. This program was not available under Solaris 2.x. I had several options in order to obtain similar functionality under Solaris 2. One option was to port idledaemon. After taking a brief look at the source code I decided to write my own version since idledaemon was too dependent on SunOS 4.x and had too many assumptions. The idea of logoutd was born.

Logoutd is not meant to be a clone of idledaemon. In fact it is much less than that. It only performs one thing, whereas idledaemon had a few other features.

What does logoutd do?

Logoutd takes one argument in the command line. This argument must be an integer specifying how long a user must be idle to be classified by logoutd as an idle user. Since it is possible that a user may be idle because the user is waiting for a process to finish, or the process the user is running has not yet produced any output for a long period of time, we cannot simply look at idle times. An idle user according to logoutd's definition has the following properties:

  1. A user who has no tty activity for a specified period of time
  2. No process belonging to that user is using the particular tty besides the idle shell

How does logoutd determine if a user is idle

  1. Check utmp for users that are logged on and determine which tty they are using.
  2. Determine the last access time on the tty
  3. Subtract last access time from current time. This is our idle time
  4. If idle time is greater or equal to the time specified at the command line do the following:
    1. Check for processes owned by the user and whose controlling tty matches this user's controlling tty.
    2. If there is only one process (it must be the shell -- I know it's a big assumption! The assumption fails in this example: xterm -ls -e /usr/bin/elm -display :0.0 ) then we can kill it.
    3. Send a SIGHUP to it. If it is a shell, the shell will exit gracefully.

Logoutd spends most of it's time sleeping. It wakes up at intervals specified in minutes in the command line. It then scans for idle users, kills those that it finds and goes back to sleep.

Logoutd must be run as root.

You may obtain logoutd source code and a Solaris 2.5 binary here.

If you like it and find it useful, don't hesitate to let me know, and thank me while you're at it. :)

Wish List

  1. Capability to specify an exception list of users -- users that won't be logged out
  2. Capability to specify processes that use the tty which are OK to kill.
  3. Capability to specify processes that use the tty which are not OK to kill.
  4. Capability to detect "idle su" to root sessions (not just the side effect).

If you find bugs or have problems with it or if you don't like its design, let me know too. You may reach me at edsel at adap dot org or adap at andrews dot edu


Back to the Sysadmin page

 
 
Send me feedback about my website at edsel at adap dot org.