pttyd, The Pseudo-tty Daemon, copyright May 1997, Greg Alexander.  To be
distributed under the terms of the GNU General Public License, included in
the file COPYING.


INSTALLATION:

	Run make.  Make some init script run pttyd.  Install the patches in
the manner described at the end of this file.  Newbie-proof rating -1.


WHAT IT DOES:

	You run pttyd as root, it waits for connections on port 666.  When
it receives a connection, it forks off a copy of itself to do a rather
simple job.  It grabs 7 bytes from the socket.  The first 5 are the pid of
the process that is requesting a tty, and the final 2 bytes are the last 2
bytes of the name of the tty device it's requesting.  For example, if my
process with pid 12345 were requesting rights to /dev/ttyp1, it would give
me the string "12345p1".  If the pid is 1, it can be specified as "00001p1"
or "1    p1", it doesn't matter.  
	If the process already has the pty master (i.e. /dev/ptyp1) open,
pttyd will set the uid for /dev/ttyp1 to be the same uid as the uid for the
given pid.  I don't think there are any security problems here.  Since only
one process can open a /dev/pty at a time, you can only do good things.  I
think.


HOW TO MAKE IT WORK WITH OTHER CLIENTS:

	Copy the pttyc.c file into the thing you want to add this securify
to and make sure that it is linked in.  This worked for rxvt, xterm, and
screen -- find where it has a for loop going through all of the available
pty's, opening each one to check for i/o error, and then seeing if it can
open the associated tty.  Right before the open for the associated tty, add
a call to get_ptty(x) where x is the string for the pty (i.e. "/dev/ptyp1"
or "ptyp1" or merely "p1").
	This only works on Linux.  I don't really want to port it anywhere,
but it would be sane to port it to almost any architecture with an even
moderately useful /proc filesystem.
	It might be useful to make this handle utmp, too.  I didn't feel
like finishing this properly because that would desimplify my simple loop. 
If anyone wants to do this, they are welcome to.
	A patch, in rxvt.patch, is included for rxvt.  Apply it from the
directory above the rxvt directory (i.e. /usr/X11/src if your rxvt dir is
/usr/X11/src/rxvt-2.20).  I've only tested it with rxvt 2.20, but it should
probably work on others if you fudge the dirs in the patch.  Don't forget to
copy the ttypc.c file into rxvt-2.20/src/.
	Another patch, in screen.patch, is included for screen.  Basically
the same patch.  Do the same things.
	Another patch, in xterm.patch, is included for xterm.  Basically the
same patch.  Do the same things.  It was made against a modified xterm
(because that's what I could find easily).  Should still work, though.  You
never know. :)
	Oh yeah, you probably want to patch /etc/services with the enclosed
services.patch.  You can change the port number if you want, both the client
and server read their portnumber from this file.

Questions?  Comments?  galexand@sietch.bloomington.in.us
