Date: Fri, 27 Mar 2009 19:13:36 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r190474 - head/usr.bin/login Message-ID: <200903271913.n2RJDaSg069214@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903271913.n2RJDaSg069214>