+# $OpenBSD: Makefile,v 1.3 1997/01/26 05:54:26 downsj Exp $
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $Id: Makefile,v 1.2 1996/11/14 15:04:52 mickey Exp $
PROG= chown
CFLAGS+=-DSUPPORT_DOT
+.\" $OpenBSD: chgrp.1,v 1.2 1997/01/26 05:54:27 downsj Exp $
+.\"
.\" Copyright (c) 1983, 1990, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
.\" SUCH DAMAGE.
.\"
.\" from: @(#)chgrp.1 8.3 (Berkeley) 3/31/94
-.\" $Id: chgrp.1,v 1.1.1.1 1995/10/18 08:47:29 deraadt Exp $
.\"
-.Dd March 31, 1994
+.Dd January 25, 1997
.Dt CHGRP 1
-.Os BSD 4.2
+.Os
.Sh NAME
.Nm chgrp
.Nd change group
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl f
+.Op Fl h
.Ar group
.Ar files ...
.Sh DESCRIPTION
.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
+Change the group ID of the specified symbolic link. The
+.Fl h
+and
+.Fl R
+options are mutually exclusive.
.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
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.
.Sh FILES
.Bl -tag -width /etc/group -compact
.It Pa /etc/group
+.\" $OpenBSD: chown.8,v 1.2 1997/01/26 05:54:28 downsj Exp $
+.\"
.\" Copyright (c) 1990, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
.\" SUCH DAMAGE.
.\"
.\" from: @(#)chown.8 8.3 (Berkeley) 3/31/94
-.\" $Id: chown.8,v 1.1.1.1 1995/10/18 08:47:29 deraadt Exp $
.\"
-.Dd March 31, 1994
+.Dd January 25, 1997
.Dt CHOWN 8
-.Os BSD 4
+.Os
.Sh NAME
.Nm chown
.Nd change file owner and group
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl f
+.Op Fl h
.Ar owner Op Ar :group
.Ar file ...
.Nm chown
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl f
+.Op Fl h
.Ar :group
.Ar file ...
.Sh DESCRIPTION
.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
+Change the user ID and/or the group ID on symbolic links. The
+.Fl R
+and
+.Fl h
+options are mutually exclusive.
.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
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.
.Sh SEE ALSO
.Xr chgrp 1 ,
.Xr find 1 ,
+/* $OpenBSD: chown.c,v 1.4 1997/01/26 05:54:28 downsj Exp $ */
+
/*
* Copyright (c) 1988, 1993, 1994
* The Regents of the University of California. All rights reserved.
#ifndef lint
/* from: static char sccsid[] = "@(#)chown.c 8.8 (Berkeley) 4/4/94"; */
-static char *rcsid = "$Id: chown.c,v 1.3 1997/01/17 07:13:57 millert Exp $";
+static char *rcsid = "$Id: chown.c,v 1.4 1997/01/26 05:54:28 downsj Exp $";
#endif /* not lint */
#include <sys/param.h>
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 '?':
warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
rval = 1;
continue;
- case FTS_SL: /* Ignore. */
+ case FTS_SL:
case FTS_SLNONE:
- /*
- * The only symlinks that end up here are ones that
- * don't point to anything and ones that we found
- * doing a physical walk.
- */
- continue;
+ if (!hflag)
+ continue;
+ /*FALLTHROUGH*/
default:
break;
}
- if (chown(p->fts_accpath, uid, gid) && !fflag) {
+ if ((hflag ? lchown(p->fts_accpath, uid, gid) :
+ chown(p->fts_accpath, uid, gid)) && !fflag) {
warn("%s", p->fts_path);
rval = 1;
}