chroot(2) and ttyname(3) problem - (nf)

olson at fortune.UUCP olson at fortune.UUCP
Wed Apr 4 06:08:33 AEST 1984


#N:fortune:11600081:000:1487
fortune!olson    Apr  3 10:20:00 1984

I am in the process of setting up some restricted logins (using
chroot(2), a modified login, etc.).  (This is on a V7/4.1 BSD hybrid)
I have just run into an annoying problem, and would appreciate any
solutions you can suggest.

The problem is that (for space reasons) I am setting up the restricted
root on a different device than the root pack.  For most programs,
this is not a problem.  However, any program which uses ttyname(3) can
not get the tty name.  The problem is that ttyname checks NOT the real
device number, but the device number AND the inode number OF THE FILE
/dev/tty*.  Why did they not simply check for the REAL device number?

Since my root is on a different device, the inode numbers of the tty's
are different, and hence, ttyname(), and the programs which use it
(tty(1), who am i (1), etc.) all come back with 'not a tty', or '??',
etc.

While this is certainly not fatal, it is annoying.  Does anyone have
any ideas, other than fixing ttyname(), and recompiling everything
that uses it?

Parenthetically, does anyone know why ttyname was written this way,
given the fact that chroot(2) has been around in one form or another
for quite a while?  (I suspect the main reason was so a tty device
could have several names (NOT links!) and have the correct one
reported.  If this was the case, it appears that the impact of chroot()
was not thought through.

	Dave Olson, Fortune Systems
	UUCP: {ihnp4,ucbvax!amd70}!fortune!olson
	ARPA: amd70!fortune!olson at BERKELEY



More information about the Comp.unix.wizards mailing list