diff options
author | steve <steve@FreeBSD.org> | 1997-08-24 02:10:29 +0000 |
---|---|---|
committer | steve <steve@FreeBSD.org> | 1997-08-24 02:10:29 +0000 |
commit | 8a12554e3feaae9d38b395485b647f701a176e73 (patch) | |
tree | bed111e0359b7cf52094eee10b1da725f1806e06 /usr.sbin/chown | |
parent | 6c92f05ce572560fabb5d88ec63aa764c7ec1a47 (diff) | |
download | FreeBSD-src-8a12554e3feaae9d38b395485b647f701a176e73.zip FreeBSD-src-8a12554e3feaae9d38b395485b647f701a176e73.tar.gz |
Correct error message when the superuser tries to change
the group of immutable files.
PR: bin/3445
Submitted by: Pius Fischer <pius@ienet.com>
Diffstat (limited to 'usr.sbin/chown')
-rw-r--r-- | usr.sbin/chown/chown.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/usr.sbin/chown/chown.c b/usr.sbin/chown/chown.c index 2a24547..c7b171b 100644 --- a/usr.sbin/chown/chown.c +++ b/usr.sbin/chown/chown.c @@ -32,13 +32,18 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1988, 1993, 1994\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)chown.c 8.8 (Berkeley) 4/4/94"; +#else +static const char rcsid[] = + "$Id$"; +#endif #endif /* not lint */ #include <sys/param.h> @@ -244,25 +249,18 @@ chownerr(file) /* Check for chown without being root. */ if (errno != EPERM || - uid != -1 && euid == -1 && (euid = geteuid()) != 0) { - if (fflag) - exit(0); + (uid != -1 && euid == -1 && (euid = geteuid()) != 0)) err(1, "%s", file); - } /* Check group membership; kernel just returns EPERM. */ - if (gid != -1 && ngroups == -1) { + if (gid != -1 && ngroups == -1 && + euid == -1 && (euid = geteuid()) != 0) { ngroups = getgroups(NGROUPS, groups); while (--ngroups >= 0 && gid != groups[ngroups]); - if (ngroups < 0) { - if (fflag) - exit(0); + if (ngroups < 0) errx(1, "you are not a member of group %s", gname); - } } - - if (!fflag) - warn("%s", file); + warn("%s", file); } void |