Path: utzoo!attcan!craig From: craig@attcan.UUCP (Craig Campbell) Newsgroups: comp.unix.admin Subject: Re: Program to log off idle users Summary: mail bounced, so I posted instead. Sorry Netters. Message-ID: <12742@vpk2.UUCP> Date: 12 Oct 90 21:50:52 GMT References: <10504@hacgate.UUCP> <9800001@hpbbi4.BBN.HP.COM> <1990Oct4.135333.19139@warwick.ac.uk> <94@dlss2.UUCP> Reply-To: craig@vpk2.ATT.COM (Craig Campbell) Organization: AT&T Canada Inc., Toronto Lines: 52 James, I tried to mail you this response, but it bounced. This may be of interest to you since you seem to be working on an idle user watchdog on a SYS-V unix. (Hope so...) In article <94@ dlss2.UUCP> you write: In article <1990Oct4.135333.19139@warwick.ac.uk> cudcv@warwick.ac.uk (Rob McMahon) writes: I'm guessing a bit at this script, because it's full of SystemV-ism's, and this article is not about critising code, but ... In article <9800001@hpbbi4.BBN.HP.COM> eugen@hpbbi4.BBN.HP.COM (#Eugen Bauknecht) writes: who -u | awk '{print $2,$6}' > /tmp/kltmp0 (Sorry what's who -u ? Is this a System-V ism ? I'll assume $2 is the terminal, and $6 is the `idle time', got by checking the mtime & atime of the tty). who -u is a shell method of finding not only who is on, but the amount of "idle" time and their process id, etc. System-V ism?? could be but I believe I've seen it on other systems also, not all but (again I think) some BSDs (newer versions maybe?). At anyrate it is NOT a sure fire way to gauge "idleness". I wrote, and haven't finished smoothing out some of the edges on, a C implementation that looks directly at the utmp file for struct utmp.ut_type equal to "7"(a USER_PROCESS) and guages time by calling stat() against the utmp.ut_line (tty line) for last modified time. As I understand it, the who -u shell command can be fooled(fact) by even a loop which echos a bell character to the screen, but this method requires(?) keyboard input to change the modify time. Systems that do not support the utmp file or don't allow access to it would have to take a totally different approach. I'd be interested, just for the knowledge, to know how this would be implemented without a utmp. Are you familiar with layers? This product has the side effect of making a terminal appear idle when it is not. Layers changes your tty device to something of the form /dev/xt??# where #={1,2,3,4,5,6,7}. Who will indicate that you are (by default) logged into /dev/xt??1. This can be changed, but the problem remains that you have 7 potential windows, each of which is a valid "terminal" which may be in use. If you log off the user on the /dev/tty?? device, layers will be killed, all the users windows will fail, and the terminal will probably need to a hard-reset. If you are unfamiliar with layers, please feel free to contact me and I will forward you any useful info I can. I beleive your auto log off program can account for layers (if it doesn't already). Good luck, craig