Ultrix 4.1 (etc.) "who am i" wrong or null output
Ian! D. Allen [CGL]
idallen at watcgl.waterloo.edu
Mon Apr 15 05:35:23 AEST 1991
The Ultrix 4.1 who (and all previous versions) suffers from the following
ancient BSD bugs.
Ultrix who bug #1:
The first one will hit you if you run programs that use ptys without
making utmp entries, as in "script" or "screen" or "xterm":
Sample output:
Script started on Sun Apr 14 14:54:35 1991
% /bin/who am i
watcgl! ttype Apr 12 18:00 <- nonsense
Script started on Sun Apr 14 14:55:23 1991
% /bin/who am i
% <- no output!
The first nonsense output comes from who finding a utmp entry that
matches your tty, left over from a previous user of the tty. (When
someone logs out, the utmp userid field is zeroed, but not the tty
field.) Who blindly prints the userid field without checking it, and
since you have no userid entered in the utmp when you run script, who
blindly prints a null string. We fixed that in our BSD source in 1986.
Ultrix who bug #2:
If you understand the above, then you'll realize that since Ultrix
"who am i" only searches for a match on the tty field, without regard
for a non-null userid field, the output can be wrong because of old
entries in the utmp file. The entries in the utmp file are made in
one-to-one correspondence with the ttys in the /etc/ttys file, so if
you run your system with a particular set of ttys you get a utmp file
that has entries for a lot of the ttys (the userid fields being
zeroed out when people log out). If you then add or delete ttys in
/etc/ttys, the correspondence between ttys and utmp shifts and "who
am i" prints the wrong thing again. We fixed that in 1988:
* Revision 1.3 88/06/18 14:50:00 idallen
* No longer prints wrong utmp entry for "who am i".
* Used to find the first entry that matched the tty name, even if the
* userid was null; but, null-name entries can get created by changes
* in the /etc/ttys file causing a tty's ttyslot() number to shift.
* Must have a non-null name to get a match.
[...]
/* "who am i" mode:
* Have to have a non-null name on the line.
* As /etc/ttys changes, we can end up with
* duplicate ut_line entries for ttys (since
* the ttyslot() number of a tty may change).
* We must ignore all entries with null names.
* -IAN!
*/
Ultrix (and BSD) who inconsistency:
Look! No host name in the first example:
% rsh localhost /bin/who am i
idallen tty?? Apr 14 15:27 <- why no host name?
% /bin/who am i
watcgl!idallen tty01 Apr 14 15:28
--
-IAN! (Ian! D. Allen) idallen at watcgl.uwaterloo.ca idallen at watcgl.waterloo.edu
[129.97.128.64] Computer Graphics Lab/University of Waterloo/Ontario/Canada
More information about the Comp.unix.ultrix
mailing list