From 573414e0c17b0c97f1f8f660a0aa73fbb7443078 Mon Sep 17 00:00:00 2001 From: Steve Price Date: Sun, 24 Aug 1997 02:10:29 +0000 Subject: [PATCH] Correct error message when the superuser tries to change the group of immutable files. PR: bin/3445 Submitted by: Pius Fischer --- usr.sbin/chown/chown.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/usr.sbin/chown/chown.c b/usr.sbin/chown/chown.c index 2a24547f1055..c7b171b1c605 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 @@ -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