diff options
author | Klemens Nanni <kn@cvs.openbsd.org> | 2023-10-15 09:49:58 +0000 |
---|---|---|
committer | Klemens Nanni <kn@cvs.openbsd.org> | 2023-10-15 09:49:58 +0000 |
commit | fed9ccaa67899f7e0a63c6b486804466d15c17b5 (patch) | |
tree | ad5fb794aeabe673fb313e954a615336470640e9 /bin/pax | |
parent | eb1423a808c12859131c859c10abc9ddbcc8e824 (diff) |
Pledge once with or without "proc exec", not twice
Spotted while comparing ktraces between 'tar -z' and 'gzcat | tar -f-'.
Only the former runs, e.g. gzip(1), but the latter also pledges theses promises
just to pledge again immediately afterwards without them.
Make the calls mutually exclusive so 'tar -f-' et al. skip the first pledge
and thus never have "proc exec" to begin wth.
"looks good to me" mbuhl
OK millert
Diffstat (limited to 'bin/pax')
-rw-r--r-- | bin/pax/pax.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/bin/pax/pax.c b/bin/pax/pax.c index cd5fcd69021..f86ba6d7ceb 100644 --- a/bin/pax/pax.c +++ b/bin/pax/pax.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pax.c,v 1.54 2023/07/05 18:45:14 guenther Exp $ */ +/* $OpenBSD: pax.c,v 1.55 2023/10/15 09:49:57 kn Exp $ */ /* $NetBSD: pax.c,v 1.5 1996/03/26 23:54:20 mrg Exp $ */ /*- @@ -271,15 +271,15 @@ main(int argc, char **argv) * so can't pledge at all then. */ if (pmode == 0 || (act != EXTRACT && act != COPY)) { - if (pledge("stdio rpath wpath cpath fattr dpath getpw proc exec tape", - 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 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"); } } |