1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-11 09:50:12 +00:00

Don't exit immediately if an error occurs, continue but exit non-zero.

This commit is contained in:
Tim J. Robbins 2002-06-02 09:32:39 +00:00
parent ee6712f2f9
commit dcafd7c96a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=97732

View File

@ -255,17 +255,21 @@ chownerr(file)
gid_t groups[NGROUPS_MAX];
/* Check for chown without being root. */
if (errno != EPERM ||
(uid != (uid_t)-1 && euid == (uid_t)-1 && (euid = geteuid()) != 0))
err(1, "%s", file);
if (errno != EPERM || (uid != (uid_t)-1 &&
euid == (uid_t)-1 && (euid = geteuid()) != 0)) {
warn("%s", file);
return;
}
/* Check group membership; kernel just returns EPERM. */
if (gid != (gid_t)-1 && ngroups == -1 &&
euid == (uid_t)-1 && (euid = geteuid()) != 0) {
ngroups = getgroups(NGROUPS_MAX, groups);
while (--ngroups >= 0 && gid != groups[ngroups]);
if (ngroups < 0)
errx(1, "you are not a member of group %s", gname);
if (ngroups < 0) {
warnx("you are not a member of group %s", gname);
return;
}
}
warn("%s", file);
}