brian@apollo.COM (Brian Holt) (08/23/88)
If xterm is invoked with -L (such as from /etc/ttys by init), just before it execs getty, it does an ioctl(TIOCNOTTY) to disassociate itself from the controlling tty. Since getty is invoked as '+', it does not do an open, but just writes 'login:' to its stdout, and reads a login name from stdin. Then it execs /bin/login with that string. login tries to get the password by calling getpass() which reads from /dev/tty. Here is the problem: at the time of the exec, getty does not have a controlling tty. Since it does not open any terminal devices, but just uses already open file descriptors, it does not acquire a controlling tty. Same with /bin/login. When getpass() tries to read from /dev/tty, then, there is still no controlling terminal, and getpass() fails! On some machines (a vax, at least), getty seems to acquire a controlling terminal when it does the write, even though it does not do an open. On Domain/OS, you only acquire a controlling tty on open (this is the way POSIX does things as well). The simple fix seems to be to remove the ioctl(TIOCNOTTY). This results in identical behaviour to that on the Vax and everything works fine. Can anybody tell me why this ioctl() is there in the first place, and whether there might be some side effects of removing it? =brian -- Internet: brian@apollo.COM UUCP: {decvax,mit-erl,yale}!apollo!brian NETel: Apollo: 508-256-6600 x5694 Home: 617-332-3073 FISA: 617-964-8938 USPS: Apollo Computer, Chelmsford MA Home: 29 Trowbridge St. Newton MA (Copyright 1988 by author. All rights reserved. Free redistribution allowed.)
jg@jumbo.dec.com (Jim Gettys) (08/23/88)
I believe the right answer is "No, no one can tell you why." The right description of what was done there is "The code was hacked on until it worked". I'm sure any number of theories of what is needed and why can be generated, and one explanation might even be correct, but I'm sceptical anyone really understands the code fully (or even understood it when it was hacked into existance; I sure know that Mark Vandevoorde and I didn't fully understand at the time, and its been hacked by others since). - Jim Gettys