This is the mail archive of the libc-alpha@cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: ut_id questions


   Date: Tue, 27 Apr 1999 23:59:17 -0400
   From: Daniel Jacobowitz <drow@false.org>

   Even if there is no "right answer" currently, I believe that there
   should somewhere be a standard, especially if it is ever to function
   for Unix98 PTYs.

Here is my try at giving the right answer.  This is what I have always
kept in mind when I was (re)implementing the utmp functions in glibc.

For all processes that are started by `init' the `ut_id' member should
be set to the id field (the first field) of the corresponding entry in
/etc/inittab.  The most widely used `init', sysvinit, does this.  It
has the following note in the inittab(5) man page:

   Note:  For  gettys or other login processes, the id
   field should be the tty suffix of the corresponding
   tty,   e.g.  1  for  tty1.   Otherwise,  the  login
   accounting might not work correctly.

Children of the origional process started by `init' should reuse the
origional entry that was set up by `init', and only change those
fields that it needs to change.  For example if you have the line

   3:234:respawn:/libexec/getty 9600 tty3

in your `/etc/inittab', `init' will set up an `INIT_PROCESS' entry with
`ut_id' set to "3", `ut_line' set "tty3", and fill in all other
aproprtiate entries.  `getty' should now search for this entry with
getutxid() by giving it an `INIT_PROCESS' entry with the `ut_id'
member set to "3" on input.  If getutxid() returns a valid entry it
should change it into a `LOGIN_PROCESS' entry, and update all other
information, and write t back with pututxline().  When the user types
his/her login name, `login' is started which should use a similar
procedure.

Another large class of processes that add entries to the user
accounting database, are processes that use pseudo terminals, for
example xterm and telnetd.  For BSD pseudo terminals the
``tty-suffix'' rule has been used for a long time.  This makes sense
since BSD pseudo terminals have names like `ttyp1', which fit nicely
into this scheme.

However the new Unix98 pseudo terminal names do not fit in.  We should
probably look at Solaris at how to handle these, but I could not
discover a ``rule''.  For example, `telnetd' seems to behave
differently from `xterm'.  But maybe somebody else could have a look
at it and discover a the ``rule'' that Solaris uses.

Since a lot of programs implement the ``tty-suffix'' rule by stripping
the first six characters from the device name, the Unix98 names often
end up like "/23" (/dev/pts/23).  However this breaks down if one uses
more than 999 pseudo terminals, since `ut_id' is only four characters
long.

I should add, that for compatibility with BSD (which does not have an
`ut_id' field) the glibc version of getutxid() is a bit more
forgiving, and if `ut_id' is not set, it searches for a matching
`ut_line' instead.

This makes it possible to leave `ut_id' empty for devices that do not
start with '/dev/tty', and set `ut_line' instead when using
getutxid(), and makes your programs less vulnerable if other people
make the wrong choices.

Hope this rather long message helps.

Mark


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]