Module Name: src
Committed By: riastradh
Date: Mon Aug 5 04:05:51 UTC 2024
Modified Files:
src/bin/pax: pax.c
src/tests/bin/pax: t_pax.sh
Log Message:
pax(1): Don't require open(".") or getcwd to work for list operation.
PR 44498: tar(1) unnecessarily demands that getcwd() work
To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/bin/pax/pax.c
cvs rdiff -u -r1.3 -r1.4 src/tests/bin/pax/t_pax.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/bin/pax/pax.c
diff -u src/bin/pax/pax.c:1.49 src/bin/pax/pax.c:1.50
--- src/bin/pax/pax.c:1.49 Wed Apr 24 17:27:08 2019
+++ src/bin/pax/pax.c Mon Aug 5 04:05:51 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: pax.c,v 1.49 2019/04/24 17:27:08 cheusov Exp $ */
+/* $NetBSD: pax.c,v 1.50 2024/08/05 04:05:51 riastradh Exp $ */
/*-
* Copyright (c) 1992 Keith Muller.
@@ -44,7 +44,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 19
#if 0
static char sccsid[] = "@(#)pax.c 8.2 (Berkeley) 4/18/94";
#else
-__RCSID("$NetBSD: pax.c,v 1.49 2019/04/24 17:27:08 cheusov Exp $");
+__RCSID("$NetBSD: pax.c,v 1.50 2024/08/05 04:05:51 riastradh Exp $");
#endif
#endif /* not lint */
@@ -260,15 +260,19 @@ main(int argc, char **argv)
return exit_val;
/*
- * Keep a reference to cwd, so we can always come back home.
+ * For any actions other than LIST, keep a reference to cwd, so
+ * we can always come back home.
*/
- cwdfd = open(".", O_RDONLY);
- if (cwdfd < 0) {
- syswarn(1, errno, "Can't open current working directory.");
- return exit_val;
+ if (act != LIST) {
+ cwdfd = open(".", O_RDONLY);
+ if (cwdfd < 0) {
+ syswarn(1, errno,
+ "Can't open current working directory.");
+ return exit_val;
+ }
+ if (updatepath() == -1)
+ return exit_val;
}
- if (updatepath() == -1)
- return exit_val;
/*
* Where should we put temporary files?
Index: src/tests/bin/pax/t_pax.sh
diff -u src/tests/bin/pax/t_pax.sh:1.3 src/tests/bin/pax/t_pax.sh:1.4
--- src/tests/bin/pax/t_pax.sh:1.3 Mon Aug 5 03:55:04 2024
+++ src/tests/bin/pax/t_pax.sh Mon Aug 5 04:05:51 2024
@@ -1,4 +1,4 @@
-# $NetBSD: t_pax.sh,v 1.3 2024/08/05 03:55:04 riastradh Exp $
+# $NetBSD: t_pax.sh,v 1.4 2024/08/05 04:05:51 riastradh Exp $
#
# Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -60,8 +60,6 @@ pr44498_body()
chmod 111 foo
touch baz/quux
atf_check pax -w -x ustar -f baz.tar baz
- atf_expect_fail 'PR bin/44498:' \
- 'tar(1) unnecessarily demands that getcwd() work'
atf_check -o 'inline:baz\nbaz/quux\n' \
sh -c '{ cd foo/bar && exec pax; } <baz.tar'
}