-/* $OpenBSD: ar_io.c,v 1.63 2019/06/28 13:34:59 deraadt Exp $ */
+/* $OpenBSD: ar_io.c,v 1.64 2023/11/09 18:54:15 kn Exp $ */
/* $NetBSD: ar_io.c,v 1.5 1996/03/26 23:54:13 mrg Exp $ */
/*-
close(fds[1]);
if (pmode == 0 || (act != EXTRACT && act != COPY)) {
- if (pledge("stdio rpath wpath cpath fattr dpath getpw proc tape",
- NULL) == -1)
- err(1, "pledge");
+ if (act == LIST) {
+ if (pledge("stdio rpath getpw proc tape",
+ NULL) == -1)
+ err(1, "pledge");
+ /* can not gzip while appending */
+ } else {
+ if (pledge("stdio rpath wpath cpath fattr dpath getpw proc tape",
+ NULL) == -1)
+ err(1, "pledge");
+ }
}
} else {
if (wr) {
-/* $OpenBSD: pax.c,v 1.55 2023/10/15 09:49:57 kn Exp $ */
+/* $OpenBSD: pax.c,v 1.56 2023/11/09 18:54:15 kn Exp $ */
/* $NetBSD: pax.c,v 1.5 1996/03/26 23:54:20 mrg Exp $ */
/*-
if (pmode == 0 || (act != EXTRACT && act != COPY)) {
/* Copy mode, or no gzip -- don't need to fork/exec. */
if (gzip_program == NULL || act == COPY) {
- if (pledge("stdio rpath wpath cpath fattr dpath getpw tape",
- NULL) == -1)
- err(1, "pledge");
+ /* List mode -- don't need to write/create/modify files. */
+ if (act == LIST) {
+ if (pledge("stdio rpath getpw tape",
+ NULL) == -1)
+ err(1, "pledge");
+ /* Append mode -- don't need to create/modify files. */
+ } else if (act == APPND) {
+ if (pledge("stdio rpath wpath getpw tape",
+ NULL) == -1)
+ err(1, "pledge");
+ } else {
+ if (pledge("stdio rpath wpath cpath fattr dpath getpw tape",
+ NULL) == -1)
+ err(1, "pledge");
+ }
} else {
- if (pledge("stdio rpath wpath cpath fattr dpath getpw proc exec tape",
- NULL) == -1)
- err(1, "pledge");
+ if (act == LIST) {
+ if (pledge("stdio rpath getpw proc exec tape",
+ NULL) == -1)
+ err(1, "pledge");
+ /* can not gzip while appending */
+ } else {
+ if (pledge("stdio rpath wpath cpath fattr dpath getpw proc exec tape",
+ NULL) == -1)
+ err(1, "pledge");
+ }
}
}