ttyname(bug)
Jerry Carlin
jmc at ptsfa.UUCP
Tue Jan 14 08:58:55 AEST 1986
On the 3B2 (and maybe other computers), ttyname(3C) has a bug. When
you 'shutdown' the system from other than the console, /dev/syscon is
linked to the /dev/tty from which you are running shutdown.
ttyname() will return /dev/syscon after the system is rebooted if
'syscon' is before the tty in /dev. This is a problem since
ttyslot(3C) uses the name returned by ttyname() to find the utmp
entry. There will be no utmp entry for /dev/syscon and ttyslot() will
return -1 (not 0 as the manual incorrectly states).
Since getlogin(3C) uses ttyslot() (which uses ttyname()), it will
erroneously return NULL (process not attached to a terminal). This is
a classic "for want of a nail the shoe was lost; for want of a shoe
the horse was lost...".
If you are just looking for the login name, cuserid(3C) works fine as
it does not go thru this process. Alternatively, one could either
diddle /etc/rc to relink /dev/syscon or you could 'rm' and 'mknod' as
necessary to force syscon to come after all the regular tty's in /dev.
Or, for those with source, change ttyname.c to check for multiple
links and take some sane action (like checking if any of them are in
utmp) if such a condition is found.
--
voice= 415 823-2441
uucp={ihnp4,dual,qantel}!ptsfa!jmc
More information about the Net.bugs.usg
mailing list