Bug 31997

Summary: login: chmod(/dev/tty??): No such file or directory
Product: Base System Reporter: brian <brian>
Component: binAssignee: Dag-Erling Smørgrav <des>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.4-STABLE   
Hardware: Any   
OS: Any   

Description brian 2001-11-15 01:10:00 UTC
As seen on security@freebsd.org:

Date: 15 Nov 2001 01:04:14 +0100
From: Dag-Erling Smorgrav <des@ofug.org>
To: cperciva@sfu.ca
Cc: Brian Behlendorf <brian@hyperreal.org>, security@FreeBSD.ORG
Subject: Re: login: chmod(/dev/tty??): No such file or directory

Colin Percival <colin.percival@wadham.ox.ac.uk> writes:
> At 15:42 14/11/2001 -0800, Brian Behlendorf wrote:
> >Saw this in last night's logs:
> >
> >Nov 13 15:56:13 taz3 login: chmod(/dev/tty??): No such file or directory
> >Nov 13 15:56:13 taz3 login: chmod(/dev/tty??): No such file or directory
> >
> >... anyone else seen this kind of thing?
>    This happens if login is run without being bound to a pty; the most
> common example of this is using scp to a machine which has 'UseLogin
> yes' set in sshd_config.

This is clearly a bug in login(8) (albeit a minor one).  Brian, could
you please file a PR about this and notify me when you get the PR
number back from GNATS?

DES
-- 
Dag-Erling Smorgrav - des@ofug.org
Comment 1 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2001-11-15 01:29:07 UTC
Responsible Changed
From-To: freebsd-bugs->des

I'll take this.
Comment 2 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2001-11-27 13:55:37 UTC
State Changed
From-To: open->analyzed

I know what the problem is, I just haven't gotten around to fixing it yet. 
It might make sense to incorporate this into pam_unix(8) session management.
Comment 3 des 2002-01-23 11:14:03 UTC
Please try this patch:

Index: login.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/login/login.c,v
retrieving revision 1.78
diff -u -r1.78 login.c
--- login.c	21 Jan 2002 16:19:38 -0000	1.78
+++ login.c	23 Jan 2002 11:07:50 -0000
@@ -525,9 +525,9 @@
 	 * Since it isn't clear that flags are useful on character
 	 * devices, we just clear them.
 	 */
-	if (chflags(ttyn, 0) && errno != EOPNOTSUPP)
-		syslog(LOG_ERR, "chmod(%s): %m", ttyn);
-	if (chown(ttyn, pwd->pw_uid,
+	if (ttyn != tname && chflags(ttyn, 0) && errno != EOPNOTSUPP)
+		syslog(LOG_ERR, "chflags(%s): %m", ttyn);
+	if (ttyn != tname && chown(ttyn, pwd->pw_uid,
 	    (gr = getgrnam(TTYGRPNAME)) ? gr->gr_gid : pwd->pw_gid))
 		syslog(LOG_ERR, "chmod(%s): %m", ttyn);
 

DES
-- 
Dag-Erling Smorgrav - des@ofug.org
Comment 4 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2002-03-13 18:45:52 UTC
State Changed
From-To: analyzed->closed

Fixed, thanks.