Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!genrad!decvax!harpo!floyd!cmcl2!philabs!seismo!hao!hplabs!sri-unix!dbj.rice@rand-relay From: dbj.rice%rand-relay@sri-unix.UUCP Newsgroups: net.unix-wizards Subject: Re: question about getpass Message-ID: <2081@sri-arpa.UUCP> Date: Sun, 12-Jun-83 23:12:09 EDT Article-I.D.: sri-arpa.2081 Posted: Sun Jun 12 23:12:09 1983 Date-Received: Thu, 16-Jun-83 00:58:13 EDT Lines: 39 From: Dave JohnsonAn easy way to make /dev/tty unopenable is for someone to open it exclusive mode. 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. The source for the ioctl routine for /dev/tty from sys.c clears this question up exactly (as looking at the source for the kernel does for so many other questions, too; why do we have to read the kernel source rather than just putting it all in the manual?). This routine is called for an ioctl on /dev/tty and just calls the ioctl routine for your control terminal, giving it the device id for your control terminal rather than the one for /dev/tty itself. This routine then translates the device id to the address of the struct tty for that terminal and sets the exclusive use bit there. /*ARGSUSED*/ syioctl(dev, cmd, addr, flag) caddr_t addr; { if (u.u_procp->p_flag&SDETACH) { u.u_error = ENXIO; return; } (*cdevsw[major(u.u_ttyd)].d_ioctl)(u.u_ttyd, cmd, addr, flag); } Dave Johnson Dept. of Math Science Rice University dbj.rice@Rand-Relay