summaryrefslogtreecommitdiffstats
path: root/usr.sbin/chown
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/chown')
-rw-r--r--usr.sbin/chown/chgrp.117
-rw-r--r--usr.sbin/chown/chown.821
-rw-r--r--usr.sbin/chown/chown.c29
3 files changed, 29 insertions, 38 deletions
diff --git a/usr.sbin/chown/chgrp.1 b/usr.sbin/chown/chgrp.1
index c6e486b..9abff11 100644
--- a/usr.sbin/chown/chgrp.1
+++ b/usr.sbin/chown/chgrp.1
@@ -47,6 +47,7 @@
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl f
+.Op Fl h
.Ar group
.Ar files ...
.Sh DESCRIPTION
@@ -77,15 +78,11 @@ in the files instead of just the files themselves.
.It Fl f
The force option ignores errors, except for usage errors and doesn't
query about strange modes (unless the user does not have proper permissions).
+.It Fl h
+If the file is a symbolic link, the group ID of the link itself is changed
+rather than the file that is pointed to.
.El
.Pp
-Symbolic links don't have groups, so unless the
-.Fl H
-or
-.Fl L
-option is set,
-.Nm chgrp
-on a symbolic link always succeeds and has no effect.
The
.Fl H ,
.Fl L
@@ -113,11 +110,7 @@ The
.Nm chgrp
utility exits 0 on success, and >0 if an error occurs.
.Sh COMPATIBILITY
-Previous versions of the
-.Nm chgrp
-utility changed the group of symbolic links specified on the command
-line.
-In this system, symbolic links do not have groups.
+In previous versions of this system, symbolic links did not have groups.
.Sh FILES
.Bl -tag -width /etc/group -compact
.It Pa /etc/group
diff --git a/usr.sbin/chown/chown.8 b/usr.sbin/chown/chown.8
index a2cb5c2..7546a4e 100644
--- a/usr.sbin/chown/chown.8
+++ b/usr.sbin/chown/chown.8
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)chown.8 8.3 (Berkeley) 3/31/94
-.\" $Id$
+.\" $Id: chown.8,v 1.4 1997/02/22 16:04:35 peter Exp $
.\"
.Dd March 31, 1994
.Dt CHOWN 8
@@ -45,6 +45,7 @@
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl f
+.Op Fl h
.Ar owner Op Ar :group
.Ar file ...
.Nm chown
@@ -53,6 +54,7 @@
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl f
+.Op Fl h
.Ar :group
.Ar file ...
.Sh DESCRIPTION
@@ -80,15 +82,11 @@ in the files instead of just the files themselves.
.It Fl f
Don't report any failure to change file owner or group, nor modify
the exit status to reflect such failures.
+.It Fl h
+If the file is a symbolic link, change the user ID and/or the group ID
+of the link itself rather than the file that the link points to.
.El
.Pp
-Symbolic links don't have owners, so unless the
-.Fl H
-or
-.Fl L
-option is set,
-.Nm chown
-on a symbolic link always succeeds and has no effect.
The
.Fl H ,
.Fl L
@@ -133,11 +131,8 @@ utility used the dot (``.'') character to distinguish the group name.
This has been changed to be a colon (``:'') character so that user and
group names may contain the dot character.
.Pp
-Previous versions of the
-.Nm chown
-utility changed the owner of symbolic links specified on the command
-line.
-In this system, symbolic links do not have owners.
+On previous versions of this system, symbolic links did not have
+owners.
.Sh SEE ALSO
.Xr chgrp 1 ,
.Xr find 1 ,
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