[911] in Kerberos_V5_Development
seeking comments for exported interfaces from libpty
daemon@ATHENA.MIT.EDU (Sam Hartman)
Wed Jul 12 18:18:38 1995
Date: Wed, 12 Jul 1995 18:18:28 -0400
From: Sam Hartman <hartmans@MIT.EDU>
To: krbdev@MIT.EDU
The purpose of this note is to seek comments on the external
interfaces for libpty. Libpty is a library that will replace the PTY
and UTMP handling for both rlogind and telnetd. We have decided not
to maintain two different sets of PTY and UTMP handling code. Neither
rlogind nor telnetd work perfectly, and they have different bugs; it
would be easier to get things working if we were only faced with one
implementation.
Most of the code for libpty will come from Richard's changes
to the rlogind pty handling. I've looked at several pty
implementations including Telnet, Expect, a program called Pty, etc;
the code in Rlogind is the clearest and takes the most advantage of
Autoconf. I will be bringing in a few security fixes and bug fixes
I've picked up from other packages.
Unfortunately, the Rlogindcode doesn't support quite as much
as Telnetd. In particular, it doesn't have the hooks for secure
Unicos (Cray). The way this code is done for Telnetd is rather poor;
there is a rather excessive amount of #ifdef CRAY, and the comments
aren't sufficient to figure out what's going on without access to
Unicos man pages. In other words, we will probably break Unicos
enhanced security support. I've also already broken Convex because it
was poorly done, broke seveural abstraction layers, and didn't leave
enough information for me to understand how to do it right. In both
these cases, I only remove as much code as necessary to implement what
I'm implementing cleanly; it should be fairly easy for someone
familiar with the operating systems in question to cleanly implement
the code.
Anyway, I propose the following as interfaces to be used by applications:
(long is returned because that's what com_err takes; I don't want to use krb5_error_code as I don't want to depend on krb5.h.)
long pty_getpty ( int *fd, char *slave)
Find and initialize a clean master pty. This should open the
pty as fd, and return the name of the slave. All processes should be
cleared from the slave. The mode of the slave should be 0600 writable
only by root. It should return 0 or an error code.
long pty_open_slave (/*in */ char * slave, /* out*/ int *fd)
Initialize the slave side by dissociating the current terminal
and by setting process groups, etc. In addition, it will initialize
the terminal flags (termios or old BSD) appropriately; the application
may have to do additional customization, but this should sanitize
things.
long pty_update_utmp(struct utmp *ut, char *user, char *line, char *host)
Update the utmp information or return an error.
long pty_update_wtmpstruct utmp *ent)
Dito. Also, in krlogind's wtmp code is logwtmp(). Apparently, there is a test to see if the system already has the function. I can't find any platforms that actually do. I would appreciate any comments on where the function originally comes from; I'm not sure if it should be pty_logwtmp, or logwtmp, and if pty_logwtmp if pty_logwtmp should just call logwtmp if defined, etc, etc.
long pty_cleanup(char *slave, pid_t pid)
Clean up after the slave application has exited. Close down the pty, HUPing processes associated with it. (pid is the pid of the slave process that may have died, slave is the name of the slave terminal.)
Thanks for your comments,
--Sam