Bug 17875

Summary: [PATCH] /usr/bin/login logs errors in non-error situations
Product: Base System Reporter: Bjoern Fischer <bfischer>
Component: binAssignee: Sheldon Hearn <sheldonh>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.0-STABLE   
Hardware: Any   
OS: Any   

Description Bjoern Fischer 2000-04-09 08:10:01 UTC
If /dev/tty* is on a file system that does not support chflags(2) every
login procedure generates an error message in syslog.

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);
How-To-Repeat: 
See description.
Comment 1 Sheldon Hearn freebsd_committer freebsd_triage 2000-04-12 11:42:38 UTC
Responsible Changed
From-To: freebsd-bugs->sheldonh

I'll take this one. 
Comment 2 Sheldon Hearn freebsd_committer freebsd_triage 2000-04-13 10:35:42 UTC
State Changed
From-To: open->analyzed

Committed to -CURRENT in rev 1.52 of login.c and rev 1.7 of 
login_fbtab.c.  Merge to follow later. 
Comment 3 Sheldon Hearn freebsd_committer freebsd_triage 2000-04-13 11:02:26 UTC
State Changed
From-To: analyzed->closed

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.