Subject: Re: trouble writing utmp entries in 2.3

From: [email-masked] (Arne J. Ludwig)
Date: 10 May 1994 19:33:38 GMT

warren.a.montgomery ([email-masked]) wrote:
: like sometimes when I rlogin, "who" shows me as another user!

Which is particularly annoying when somebody legitimate types su, and
a message saying "su root succeeded for <joe-hacker>" ruins your day.

: SIGCLD resulting from the death of that process was fouling up my
: emulator, and again I can find no warnings about what is going on.

Sigh. Everybody can mess things up, but it takes Sunsoft to .... ;-)
And finger uses utmpx instead of utmp, isn't that great?

Because after a few weeks we have several screenfuls of leftover users
in the who, we wrote a little script to replace who. Of course, we run
all our xterm to not update utmp at all, but still get an unacceptable
number of leftover users. Here is the script, use at your own risk:

#!/bin/sh
#
# who replacement to filter out users that are not really logged in
#
# 94/05/06	Joseph Lo and Arne Ludwig, DUMC Radiology
#		{jyl,[email-masked]
#
temp=/tmp/whos$$
ps -ef | grep sh >$temp
who | sort | {
	while read line
	do
		set -- $line
		uid=$1
		term=$2
		IFS=/
		set -- $term
		term=$1.$2
		IFS=' '

		# check to see if actually logged on by grepping for term&uid
		if ( [ "`nawk 'BEGIN { x = 0; } /'$uid'/ && /'$term'/ { x++; } END { if (x > 0) print "x"; }' $temp`" = x ] ); then
			echo "$line"
		fi
	done
}
rm -f $temp

--
Arne Ludwig	Duke University Medical Center		[email-masked]
Hugs not drugs