From bfischer@Techfak.uni-bielefeld.de  Sun Apr  9 00:07:30 2000
Return-Path: <bfischer@Techfak.uni-bielefeld.de>
Received: from mail.uni-bielefeld.de (mail.uni-bielefeld.de [129.70.4.90])
	by hub.freebsd.org (Postfix) with ESMTP id 3743737B652
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  9 Apr 2000 00:07:29 -0700 (PDT)
	(envelope-from bfischer@Techfak.uni-bielefeld.de)
Received: from frolic.no-support.loc (ppp36-234.hrz.uni-bielefeld.de)
 by mail.uni-bielefeld.de
 (Sun Internet Mail Server sims.3.5.1999.05.24.18.28.p7)
 with ESMTP id <0FSQ00EN1MGAN9@mail.uni-bielefeld.de> for
 FreeBSD-gnats-submit@freebsd.org; Sun,  9 Apr 2000 09:07:25 +0200 (MET DST)
Received: (from bjoern@localhost) by frolic.no-support.loc (8.9.3/8.9.3)
 id JAA24395 for FreeBSD-gnats-submit@freebsd.org; Sun,
 09 Apr 2000 09:06:36 +0200 (CEST envelope-from bjoern)
Received: (from bjoern@localhost) by broccoli.no-support.loc (8.9.3/8.9.3)
 id FAA09601; Fri, 07 Apr 2000 05:22:44 +0200 (CEST envelope-from bjoern)
Message-Id: <200004070322.FAA09601@broccoli.no-support.loc>
Date: Fri, 07 Apr 2000 05:22:44 +0200 (CEST)
From: Bjoern Fischer <bfischer@Techfak.Uni-Bielefeld.DE>
Reply-To: bfischer@Techfak.Uni-Bielefeld.DE
To: FreeBSD-gnats-submit@freebsd.org
Subject: [PATCH] /usr/bin/login logs errors in non-error situations
X-Send-Pr-Version: 3.2

>Number:         17875
>Category:       bin
>Synopsis:       [PATCH] /usr/bin/login logs errors in non-error situations
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    sheldonh
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Apr  9 00:10:01 PDT 2000
>Closed-Date:    Thu Apr 13 03:02:26 PDT 2000
>Last-Modified:  Thu Apr 13 03:03:20 PDT 2000
>Originator:     Bjoern Fischer
>Release:        FreeBSD 4.0-STABLE i386
>Organization:
No-Support
>Environment:

Any out-of-the-box FreeBSD 4.0 with /dev on a non FFS file system.

>Description:

If /dev/tty* is on a file system that does not support chflags(2) every
login procedure generates an error message in syslog.

>How-To-Repeat:

See description.

>Fix:

To fix this errno is checked if it is EOPNOTSUPP. No errors will be logged
in that case. See this patch:

--- ./usr.bin/login/login.c	2000/04/07 02:55:10	1.1
+++ ./usr.bin/login/login.c	2000/04/07 02:59:35
@@ -492,8 +492,11 @@
 	 * user sets them otherwise, this can cause the chown to fail.
 	 * Since it isn't clear that flags are useful on character
 	 * devices, we just clear them.
+	 *
+	 * chflags may fail due to lack of support on file system. In
+	 * this case we ignore the error silently.
 	 */
-	if (chflags(ttyn, 0))
+	if (chflags(ttyn, 0) && (errno != EOPNOTSUPP))
 		syslog(LOG_ERR, "chmod(%s): %m", ttyn);
 	if (chown(ttyn, pwd->pw_uid,
 	    (gr = getgrnam(TTYGRPNAME)) ? gr->gr_gid : pwd->pw_gid))
--- ./usr.bin/login/login_fbtab.c	2000/04/07 02:55:10	1.1
+++ ./usr.bin/login/login_fbtab.c	2000/04/07 03:02:46
@@ -132,8 +132,12 @@
     DIR    *dir;
 
     if (strcmp("/*", path + pathlen - 2) != 0) {
-	/* clear flags of the device */
-        if (chflags(path, 0) && errno != ENOENT)
+	/* clear flags of the device
+	 *
+	 * chflags may fail due to lack of support on file system. In
+	 * this case we ignore the error silently.
+	 */
+        if (chflags(path, 0) && (errno != ENOENT) && (errno != EOPNOTSUPP))
 	    syslog(LOG_ERR, "%s: chflags(%s): %m", table, path);
 	if (chmod(path, mask) && errno != ENOENT)
 	    syslog(LOG_ERR, "%s: chmod(%s): %m", table, path);

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->sheldonh 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Wed Apr 12 03:42:38 PDT 2000 
Responsible-Changed-Why:  
I'll take this one. 
State-Changed-From-To: open->analyzed 
State-Changed-By: sheldonh 
State-Changed-When: Thu Apr 13 02:35:42 PDT 2000 
State-Changed-Why:  
Committed to -CURRENT in rev 1.52 of login.c and rev 1.7 of 
login_fbtab.c.  Merge to follow later. 
State-Changed-From-To: analyzed->closed 
State-Changed-By: sheldonh 
State-Changed-When: Thu Apr 13 03:02:26 PDT 2000 
State-Changed-Why:  
Merged onto the RELENG_4 branch in rev 1.51.2.1 of login.c and 
rev 1.6.2.1 of login_fbtab.c.  The problem did not exist in 
RELENG_3. 
>Unformatted:
