Subject: chmod/chown and symlinks
To: None <tech-userlevel@netbsd.org>
From: Ben Harris <bjh21@netbsd.org>
List: tech-userlevel
Date: 06/30/2002 11:28:35
I'd like to fix PR standards/563.  The actual fix is a two-line change,
but I'd like to check it wih other people first.

The problem is that "chmod g+w slink", where slink is a symlink, does
nothing.  On Solaris and GNU, and in IEEE Std 1003.1-2001, it changes the
mode of the target.  symlink(7) agrees that acting on the target of the
link is correct.

So, does anyone have any problem with my changing chmod's behaviour (and
chown's, by the same logic) to follow symlinks on the command-line by
default?  A week's silence will be taken as assent.

Index: bin/chmod/chmod.c
===================================================================
RCS file: /cvsroot/basesrc/bin/chmod/chmod.c,v
retrieving revision 1.27
diff -u -r1.27 chmod.c
--- bin/chmod/chmod.c	2002/05/31 18:54:01	1.27
+++ bin/chmod/chmod.c	2002/06/30 10:27:36
@@ -142,7 +142,8 @@
 			fts_options &= ~FTS_PHYSICAL;
 			fts_options |= FTS_LOGICAL;
 		}
-	}
+	} else if (!hflag)
+		fts_options |= FTS_COMFOLLOW;
 	if (hflag)
 		change_mode = lchmod;
 	else
Index: usr.sbin/chown/chown.c
===================================================================
RCS file: /cvsroot/basesrc/usr.sbin/chown/chown.c,v
retrieving revision 1.25
diff -u -r1.25 chown.c
--- usr.sbin/chown/chown.c	2000/12/17 22:47:14	1.25
+++ usr.sbin/chown/chown.c	2002/06/30 10:27:36
@@ -142,7 +142,8 @@
 			fts_options &= ~FTS_PHYSICAL;
 			fts_options |= FTS_LOGICAL;
 		}
-	}
+	} else if (!hflag)
+		fts_options |= FTS_COMFOLLOW;

 	uid = (uid_t)-1;
 	gid = (gid_t)-1;

-- 
Ben Harris                                                   <bjh21@netbsd.org>
Portmaster, NetBSD/acorn26           <URL:http://www.netbsd.org/Ports/acorn26/>