summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-06-04 04:56:27 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-06-04 04:56:27 +0000
commit74ceafe347b98458bf4b1df26ef21dd5d126a1c8 (patch)
tree9428c21b37c789bf1427b9bd809d788d2e3bbd7b /bin
parenta8283e6990fbda4b372638e47cd6d79ac9396f0c (diff)
Don't complain about not being able to set uid/gid in "tar -p"
(EPERM) unless the verbose flag is given or the user is root. Noted by Magnus Holmberg <mho@stacken.kth.se>.
Diffstat (limited to 'bin')
-rw-r--r--bin/pax/file_subs.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c
index 02c2408196d..f716e6131b6 100644
--- a/bin/pax/file_subs.c
+++ b/bin/pax/file_subs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file_subs.c,v 1.8 1997/04/09 01:59:00 deraadt Exp $ */
+/* $OpenBSD: file_subs.c,v 1.9 1997/06/04 04:56:26 millert Exp $ */
/* $NetBSD: file_subs.c,v 1.4 1995/03/21 09:07:18 cgd Exp $ */
/*-
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)file_subs.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: file_subs.c,v 1.8 1997/04/09 01:59:00 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: file_subs.c,v 1.9 1997/06/04 04:56:26 millert Exp $";
#endif
#endif /* not lint */
@@ -764,7 +764,13 @@ set_ids(fnm, uid, gid)
#endif
{
if (chown(fnm, uid, gid) < 0) {
- syswarn(1, errno, "Unable to set file uid/gid of %s", fnm);
+ /*
+ * ignore EPERM unless in verbose mode or being run by root.
+ * note that errno may get clobbered by geteuid(2).
+ */
+ if (errno == EPERM && (vflag || geteuid() == 0))
+ syswarn(1, EPERM, "Unable to set file uid/gid of %s",
+ fnm);
return(-1);
}
return(0);
@@ -789,7 +795,13 @@ set_lids(fnm, uid, gid)
#endif
{
if (lchown(fnm, uid, gid) < 0) {
- syswarn(1, errno, "Unable to set file uid/gid of %s", fnm);
+ /*
+ * ignore EPERM unless in verbose mode or being run by root.
+ * note that errno may get clobbered by geteuid(2).
+ */
+ if (errno == EPERM && (vflag || geteuid() == 0))
+ syswarn(1, EPERM, "Unable to set file uid/gid of %s",
+ fnm);
return(-1);
}
return(0);