[comp.bugs.4bsd] A couple of improvements to "getty"

guy%gorodish@Sun.COM (Guy Harris) (01/14/87)

Index:	etc/getty/main.c 4.3BSD

Description:
	1) "getty" should reset non-blocking and asynchronous mode on
	   a port when it starts the port up, just in case the last
	   user of that port didn't leave the water closet in the
	   same state that it found it.
	2) "getty" should also log an error if the "exec" of the
	   "login" program fails.
Repeat-By:
	1) Put a port with non-blocking or asynchronous mode and log
	   off, then watch the fun when the next person tries to use it.
	2) Put in a bogus "lo=" entry in "/etc/gettytab" for a port and
	   note that the failure to exec the program is not noted.
Fix:
*** /arch/4.3/usr/src/etc/getty/main.c	Sat Feb  1 13:52:26 1986
--- main.c	Wed Jan 14 02:05:56 1987
***************
*** 166,171 ****
--- 166,172 ----
  		tname = argv[1];
  	for (;;) {
  		int ldisp = OTTYDISC;
+ 		int off = 0;
  
  		gettable(tname, tabent, tabstrs);
  		if (OPset || EPset || APset)
***************
*** 172,177 ****
--- 173,180 ----
  			APset++, OPset++, EPset++;
  		setdefaults();
  		ioctl(0, TIOCFLUSH, 0);		/* clear out the crap */
+ 		ioctl(0, FIONBIO, &off);	/* turn off non-blocking mode */
+ 		ioctl(0, FIOASYNC, &off);	/* ditto for asynchronous mode */
  		if (IS)
  			tmode.sg_ispeed = speed(IS);
  		else if (SP)
***************
*** 236,241 ****
--- 239,245 ----
  				env[i] = environ[i];
  			makeenv(&env[i]);
  			execle(LO, "login", "-p", name, (char *) 0, env);
+ 			syslog(LOG_ERR, "%s: %m", LO);
  			exit(1);
  		}
  		alarm(0);