svn commit: r190474 - head/usr.bin/login

Ed Schouten ed at FreeBSD.org
Fri Mar 27 12:13:37 PDT 2009


Author: ed
Date: Fri Mar 27 19:13:36 2009
New Revision: 190474
URL: http://svn.freebsd.org/changeset/base/190474

Log:
  Don't strip TTY device name to the last '/'.
  
  We've seen this bug in other applications before: we have some
  applications that use strrchr(tty, '/') on the TTY device name. This
  isn't valid when using pts(4), because the device name will be stripped
  to "0" instead of "pts/0".
  
  This fixes issues with login(1) ignoring /etc/ttys and missing utmp
  records.
  
  Reported by:	Barney Cordoba <barney_cordoba yahoo com>
  Reviewed by:	rwatson

Modified:
  head/usr.bin/login/login.c

Modified: head/usr.bin/login/login.c
==============================================================================
--- head/usr.bin/login/login.c	Fri Mar 27 19:08:15 2009	(r190473)
+++ head/usr.bin/login/login.c	Fri Mar 27 19:13:36 2009	(r190474)
@@ -245,8 +245,8 @@ main(int argc, char *argv[])
 		(void)snprintf(tname, sizeof(tname), "%s??", _PATH_TTY);
 		ttyn = tname;
 	}
-	if ((tty = strrchr(ttyn, '/')) != NULL)
-		++tty;
+	if (strncmp(ttyn, _PATH_DEV, sizeof _PATH_DEV - 1) == 0)
+		tty = ttyn + sizeof _PATH_DEV - 1;
 	else
 		tty = ttyn;
 


More information about the svn-src-all mailing list