From nobody@FreeBSD.org  Wed Nov 14 17:05:27 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 5F98337B50B
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Nov 2001 17:05:24 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.4/8.11.4) id fAF15Op15058;
	Wed, 14 Nov 2001 17:05:24 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200111150105.fAF15Op15058@freefall.freebsd.org>
Date: Wed, 14 Nov 2001 17:05:24 -0800 (PST)
From: Brian Behlendorf <brian@hyperreal.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: login: chmod(/dev/tty??): No such file or directory
X-Send-Pr-Version: www-1.0

>Number:         31997
>Category:       bin
>Synopsis:       login: chmod(/dev/tty??): No such file or directory
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Nov 14 17:10:00 PST 2001
>Closed-Date:    Wed Mar 13 10:45:52 PST 2002
>Last-Modified:  Wed Mar 13 10:45:53 PST 2002
>Originator:     Brian Behlendorf
>Release:        4.4-STABLE as of Oct 24
>Organization:
>Environment:
FreeBSD taz3.hyperreal.org 4.4-STABLE FreeBSD 4.4-STABLE #8: Wed Oct 24 22:19:32 PDT 2001     brian@taz3.hyperreal.org:/usr/obj/usr/src/sys/taz3  i386

>Description:
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

>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: des 
Responsible-Changed-When: Wed Nov 14 17:29:07 PST 2001 
Responsible-Changed-Why:  
I'll take this. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=31997 
State-Changed-From-To: open->analyzed 
State-Changed-By: des 
State-Changed-When: Tue Nov 27 05:55:37 PST 2001 
State-Changed-Why:  
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. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=31997 

From: Dag-Erling Smorgrav <des@ofug.org>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: bin/31997
Date: 23 Jan 2002 12:14:03 +0100

 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
State-Changed-From-To: analyzed->closed 
State-Changed-By: des 
State-Changed-When: Wed Mar 13 10:45:52 PST 2002 
State-Changed-Why:  
Fixed, thanks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=31997 
>Unformatted:
