tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: login(1) vs "dialout ttys"



On 11 Nov, 2014, at 03:00 , Aymeric Vincent <aymericvincent%free.fr@localhost> wrote:
> while looking at usr.bin/login/login.c, I noticed the following strange
> test:
> 
> 	if (tty[sizeof("tty")-1] == 'd')
> 		syslog(LOG_INFO, "DIALUP %s, %s", tty, pwd->pw_name);
> 
> The intent seems obvious (if the name contains a 'd' in a position which
> would agree with "ttyd", syslog that we have a dialup login) but it
> seems to be a sloppy test which is furthermore incoherent with the
> current naming of our devices.  (It can't currently lead to an out of
> bounds access because ttyname(3) returns a static PATH_MAX-length array)

There's an explanation of that at the end of section 4.4 of this

    http://minnie.tuhs.org/PUPS/Setup/2.11bsd_setup.pdf

which says

        Finally note that you should change the names of any dialup terminals
     to ttyd? where ? is in [0-9a-zA-Z], as some programs use this property of
     the names to determine if a terminal is a dialup. Shell commands to do
     this should be put in the /dev/MAKEDEV.local script.

Apparently at Berkeley they renamed the device file for any serial port
connected to a modem (on a vax ports on a DZ11 were normally named tty0?,
while ports on DH11s were tty[hijk][0-f]) to ttyd? to allow extra logging
for logins on a modem that wasn't done for hardwired terminals.  I guess
the above is the extra logging.

> Out of curiosity, I'm also interested to know if /dev/dtyxx is the new
> incarnation of /dev/ttydxx or if they serve different purposes.

No, /dev/ttydX apparently just meant "attached to a modem" (we didn't do
this).  Through 4.3 BSD at least the BSD terminal driver did not have a
separate device for dial out.  If you wanted to use a modem for dial out
you would open the same device file as was used for dial in, but with a
O_NONBLOCK flag given to open() followed by some other magic (my memory is
dim) that was supposed to lock out pending opens waiting for carrier.  This
was very buggy and full of race conditions, so we avoided trying to share
modems for both dial-in and dial-out use.  The /dev/dtyXX thing may have
come from System V (or the System V-based SunOS) and was supposed to fix
the races.

Dennis Ferguson


Home | Main Index | Thread Index | Old Index