summaryrefslogtreecommitdiffstats
path: root/usr.sbin/chown/chown.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1997-03-31 13:03:49 +0000
committerpeter <peter@FreeBSD.org>1997-03-31 13:03:49 +0000
commit526a6977d3675629fedb81678eb4e6c86a7786c1 (patch)
tree890611ba35a01704fe15caa9ef7d6324de05cbfd /usr.sbin/chown/chown.c
parentc4807cce9044753a0d8a6a18f0434ced2fe46491 (diff)
downloadFreeBSD-src-526a6977d3675629fedb81678eb4e6c86a7786c1.zip
FreeBSD-src-526a6977d3675629fedb81678eb4e6c86a7786c1.tar.gz
Activate the -h flag which tells chown/chgrp to work on the symlink itself
using lchown(). Most of the code was already here, the option was recognised but ignored for SYSV/POSIX.2(?) compatability.
Diffstat (limited to 'usr.sbin/chown/chown.c')
-rw-r--r--usr.sbin/chown/chown.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/usr.sbin/chown/chown.c b/usr.sbin/chown/chown.c
index 9e01164..2a24547 100644
--- a/usr.sbin/chown/chown.c
+++ b/usr.sbin/chown/chown.c
@@ -64,7 +64,7 @@ void usage __P((void));
uid_t uid;
gid_t gid;
-int Rflag, ischown, fflag;
+int Rflag, ischown, fflag, hflag;
char *gname, *myname;
int
@@ -102,13 +102,6 @@ main(argc, argv)
fflag = 1;
break;
case 'h':
- /*
- * In System V (and probably POSIX.2) the -h option
- * causes chown/chgrp to change the owner/group of
- * the symbolic link. 4.4BSD's symbolic links don't
- * have owners/groups, so it's an undocumented noop.
- * Do syntax checking, though.
- */
hflag = 1;
break;
case '?':
@@ -175,13 +168,23 @@ main(argc, argv)
* don't point to anything and ones that we found
* doing a physical walk.
*/
- continue;
+ if (hflag)
+ break;
+ else
+ continue;
default:
break;
}
- if (chown(p->fts_accpath, uid, gid) && !fflag) {
- chownerr(p->fts_path);
- rval = 1;
+ if (hflag) {
+ if (lchown(p->fts_accpath, uid, gid) && !fflag) {
+ chownerr(p->fts_path);
+ rval = 1;
+ }
+ } else {
+ if (chown(p->fts_accpath, uid, gid) && !fflag) {
+ chownerr(p->fts_path);
+ rval = 1;
+ }
}
}
if (errno)
@@ -266,7 +269,7 @@ void
usage()
{
(void)fprintf(stderr,
- "usage: %s [-R [-H | -L | -P]] [-f] %s file ...\n",
+ "usage: %s [-R [-H | -L | -P]] [-f] [-h] %s file ...\n",
myname, ischown ? "[owner][:group]" : "group");
exit(1);
}
OpenPOWER on IntegriCloud