-/* $OpenBSD: ar_io.c,v 1.50 2015/03/22 03:15:00 guenther Exp $ */
+/* $OpenBSD: ar_io.c,v 1.51 2015/10/12 05:05:24 deraadt Exp $ */
/* $NetBSD: ar_io.c,v 1.5 1996/03/26 23:54:13 mrg Exp $ */
/*-
dup2(fds[0], fd);
close(fds[0]);
close(fds[1]);
+
+ if (pledge("stdio rpath wpath cpath fattr getpw ioctl proc",
+ NULL) == -1)
+ err(1, "pledge");
} else {
if (wr) {
dup2(fds[0], STDIN_FILENO);
-/* $OpenBSD: pax.c,v 1.41 2015/03/09 04:23:29 guenther Exp $ */
+/* $OpenBSD: pax.c,v 1.42 2015/10/12 05:05:24 deraadt Exp $ */
/* $NetBSD: pax.c,v 1.5 1996/03/26 23:54:20 mrg Exp $ */
/*-
if ((gen_init() < 0) || (tty_init() < 0))
return(exit_val);
+ /*
+ * pmode needs to restore setugid bits when extracting or copying,
+ * so can't tame at all then.
+ */
+ if (pmode == 0 || (act != EXTRACT && act != COPY)) {
+ if (pledge("stdio rpath wpath cpath fattr getpw ioctl proc exec",
+ NULL) == -1)
+ err(1, "pledge");
+
+ /* Copy mode, or no gzip -- don't need to fork/exec. */
+ if (gzip_program == NULL || act == COPY) {
+ if (pledge("stdio rpath wpath fattr cpath getpw ioctl",
+ NULL) == -1)
+ err(1, "pledge");
+ }
+ }
+
/*
* select a primary operation mode
*/