From: downsj Date: Sun, 26 Jan 1997 05:54:26 +0000 (+0000) Subject: Enable -h for calling lchown(2) instead of chown(2), and fix rcs ids. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e438ed80d11a4202cc251acb926674ea84569440;p=openbsd Enable -h for calling lchown(2) instead of chown(2), and fix rcs ids. --- diff --git a/usr.sbin/chown/Makefile b/usr.sbin/chown/Makefile index 5ddbaf35f65..bdfa6810b2f 100644 --- a/usr.sbin/chown/Makefile +++ b/usr.sbin/chown/Makefile @@ -1,5 +1,5 @@ +# $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 diff --git a/usr.sbin/chown/chgrp.1 b/usr.sbin/chown/chgrp.1 index 0090e26e319..55da5a5899a 100644 --- a/usr.sbin/chown/chgrp.1 +++ b/usr.sbin/chown/chgrp.1 @@ -1,3 +1,5 @@ +.\" $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. .\" @@ -33,11 +35,10 @@ .\" 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 @@ -48,6 +49,7 @@ .Op Fl H | Fl L | Fl P .Oc .Op Fl f +.Op Fl h .Ar group .Ar files ... .Sh DESCRIPTION @@ -78,15 +80,14 @@ 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 +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 @@ -113,12 +114,6 @@ or be the super-user. 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 diff --git a/usr.sbin/chown/chown.8 b/usr.sbin/chown/chown.8 index 5c499166599..ebc9d6be82c 100644 --- a/usr.sbin/chown/chown.8 +++ b/usr.sbin/chown/chown.8 @@ -1,3 +1,5 @@ +.\" $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. .\" @@ -30,11 +32,10 @@ .\" 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 @@ -45,6 +46,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 +55,7 @@ .Op Fl H | Fl L | Fl P .Oc .Op Fl f +.Op Fl h .Ar :group .Ar file ... .Sh DESCRIPTION @@ -80,15 +83,14 @@ 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 +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 @@ -132,12 +134,6 @@ Previous versions of the 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 , diff --git a/usr.sbin/chown/chown.c b/usr.sbin/chown/chown.c index f227b174959..194c0b74312 100644 --- a/usr.sbin/chown/chown.c +++ b/usr.sbin/chown/chown.c @@ -1,3 +1,5 @@ +/* $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. @@ -39,7 +41,7 @@ static char copyright[] = #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 @@ -103,13 +105,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 '?': @@ -169,19 +164,17 @@ main(argc, argv) 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; }