[comp.unix.questions] login

escott%deis.uci.edu@icsg.UCI.EDU (02/05/87)

Excuse me if this is obvious, but why is it that when there is no entry in
"/etc/ttys" for the terminal device you are logging in to, no record is made
of your login in "/etc/utmp"?  I've looked at the (4.2BSD) sources and it
seems as though this is being done on purpose.  I added a bunch of pty's
(ttyq*) to my (DYNIX 2.1 [really 4.2BSD]) system without remembering to put
them in "/etc/ttys", and every time somebody logged in to a ttyq* they were
invisible from programs like "u", "w", and "last"!  Seems funny...

+-------------------------------------------------------------------------+
 Scott Menter  UCI ICS Computing Support Group   Univ. of Calif. at Irvine
                     (714) 856 7552              Irvine, California  92717

 Internet:  escott@ics.uci.edu             UUCP:  ...!ucbvax!ucivax!escott
 Bitnet:    escott@uci               CSNet: escott%ics.uci.edu@csnet-relay
 Internet (with Name Server):  TBA
+-------------------------------------------------------------------------+

chris@mimsy.UUCP (02/05/87)

In article <4250@brl-adm.ARPA> escott%deis.uci.edu@icsg.UCI.EDU
(Scott Menter) writes:
>Excuse me if this is obvious, but why is it that when there is no entry in
>"/etc/ttys" for the terminal device you are logging in to, no record is made
>of your login in "/etc/utmp"?

login and init must agree on which entry to write.  They do this
by using ttyslot() to compute an offset.  ttyslot() returns
(essentially) the line number of the line in /etc/ttys containing
that tty name, or an error value if no slot is found.

Incidentally, this means that if you insert a line in /etc/ttys,
utmp will be scrambled.  It is therefore best to do this only in
single user mode.  Appending new entries, however, is safe.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP:	seismo!mimsy!chris	ARPA/CSNet:	chris@mimsy.umd.edu

guy@gorodish.UUCP (02/06/87)

>Excuse me if this is obvious, but why is it that when there is no entry in
>"/etc/ttys" for the terminal device you are logging in to, no record is made
>of your login in "/etc/utmp"?

Because without an entry in "/etc/ttys", it has no way of knowing
where the record should be made.  Each tty port is assumed to have an
entry in "/etc/utmp" at a fixed location; that location is defined by
the position of that port's entry in "/etc/ttys".  No entry in
"/etc/ttys", no location, and hence no entry.