From owner-svn-src-head@FreeBSD.ORG Fri Mar 27 19:13:36 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C5228106566B; Fri, 27 Mar 2009 19:13:36 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B33768FC17; Fri, 27 Mar 2009 19:13:36 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2RJDapb069215; Fri, 27 Mar 2009 19:13:36 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2RJDaSg069214; Fri, 27 Mar 2009 19:13:36 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200903271913.n2RJDaSg069214@svn.freebsd.org> From: Ed Schouten Date: Fri, 27 Mar 2009 19:13:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190474 - head/usr.bin/login X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Mar 2009 19:13:37 -0000 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 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;