question about getpass

mark.umcp-cs%udel-relay at sri-unix.UUCP mark.umcp-cs%udel-relay at sri-unix.UUCP
Tue Jun 14 13:10:03 AEST 1983


From:  Mark Weiser <mark.umcp-cs at udel-relay>

	From: Dave Johnson <dbj.rice at Rand-Relay>
	

	WRONG!  You can't open /dev/tty "exclusive mode" (I assume
	you mean the TIOCEXCL ioctl).  The device /dev/tty simply
	indirects to the specific tty that is you control terminal
	(usually the one you are logged on to) and has no struct
	tty of its own within the kernel.  If you TIOCEXCL /dev/tty,
	you really end up setting the exclusive use bit on your
	own terminal, NOT on /dev/tty itself.  This will not prevent
	some OTHER user from opening /dev/tty.  It will only prevent
	you (or some other user or process) from opening the specific
	terminal that is your control terminal...

Whoops, I didn't realize my answer would be misunderstood.  Of
course dave is right, /dev/tty is essentially a different device
for everyone who opens it.  I assumed this was understood, and
was thinking of a context in which one wished to run something
like 'su' but wanted it to read from stdin (e.g. to have a shell
script to become super-user or some other horrible thing).  In
this case you somehow want the getpasswd call in su to fail
to be able to open /dev/tty and so use stdin.

My own context was a window system I built in which stdin and
stdout had been redirected to the windows, and everything worked
great except for silly little programs like su which INSISTED
on opening /dev/tty.  But of course, that's what its there for...



More information about the Comp.unix.wizards mailing list