Christian Weisgerber wrote: > Stefan Hagen: >> portcheck, make port-lib-depends-check: ok >> make test: >> amd64 - up to test 165 all good, then I ran out of disk space >> sparc64 - passed > > Well, I get: > > 89: extracting even when . and .. are unreadable FAILED (extrac09.at:37)
Shame on me. When executed as root, this test is skipped. > Looking at tests/testsuite.dir/089/testsuite.log in the work directory > shows > > chmod a-r . .. > tar -xvf archive.tar -C extract f > [...] >+tar: .: Cannot getcwd: Permission denied >+tar: Error is not recoverable: exiting now > > I don't think our getcwd(3) fails this way. Which makes me think a > gnulib wrapper has been enabled. Ah, yes, from the configure output: > > checking whether getcwd succeeds when 4k < cwd_length < 16k... no This is a libc bug check and looks unrelated to the problem for me. What triggers the test to fail is an additional check of the getcwd return value. This check was introduced in this commit: https://git.savannah.gnu.org/cgit/tar.git/commit/?id=66162927ebdfe9dd4ef570a132663fd76217952f There is a getcwd wrapper in gnu/xgetcwd.c. But it's thin and still uses getcwd(3). The problem is, that after chmod a-r . .., getcwd(NULL,0) is called and it behaves differently than on other platforms. - OpenBSD returns a NULL pointer and errno=EACCES (code 13). - Linux returns a pointer and no error. A litte test program calling getcwd(NULL,0) shows: OpenBSD: $ chmod a-r . ..; ./a.out; BUF: >0x0< ERRNO: >13< Linux: $ chmod a-r . ..; ./a.out; BUF: >0x55be0709c260< ERRNO: >0< FreeBSD: $ chmod a-r . ..; ./a.out; BUF: >0x80064a000< ERRNO: >0< The manpages state: OpenBSD: [EACCES] Read or search permission was denied for a component of the pathname. Linux: EACCES Search permission was denied for the current directory, or read or search permission was denied for a directory above the current directory in the file hierarchy. FreeBSD: [EACCES] Read or search permission was denied for a component of the pathname. This is only checked in limited cases, depending on implementation details. To me it looks like the OpenBSD behavior is as documented while Linux's is wrong and FreeBSD leaves all options open. The diff below reverts the getcwd check in question and the testsuite will pass. Best Regards, Stefan Index: Makefile =================================================================== RCS file: /cvs/ports/archivers/gtar/Makefile,v retrieving revision 1.85 diff -u -p -u -p -r1.85 Makefile --- Makefile 16 Jul 2019 21:29:41 -0000 1.85 +++ Makefile 10 Jan 2021 17:59:00 -0000 @@ -2,9 +2,8 @@ COMMENT= GNU version of the traditional tape archiver -DISTNAME= tar-1.32 +DISTNAME= tar-1.33 PKGNAME= g${DISTNAME} -REVISION= 1 CATEGORIES= archivers HOMEPAGE= https://www.gnu.org/software/tar/ Index: distinfo =================================================================== RCS file: /cvs/ports/archivers/gtar/distinfo,v retrieving revision 1.26 diff -u -p -u -p -r1.26 distinfo --- distinfo 25 Feb 2019 21:01:58 -0000 1.26 +++ distinfo 10 Jan 2021 17:59:00 -0000 @@ -1,2 +1,2 @@ -SHA256 (tar-1.32.tar.xz) = 0NOuB/EDMjvoCbw+rA3MOG1SxSYkmf4FURrEeIrx/dg= -SIZE (tar-1.32.tar.xz) = 2103348 +SHA256 (tar-1.33.tar.xz) = Zqg0Sx3IOkEdMRvRVH4BduVswxHyjulKMPhNr7PZBn4= +SIZE (tar-1.33.tar.xz) = 2224824 Index: patches/patch-configure =================================================================== RCS file: /cvs/ports/archivers/gtar/patches/patch-configure,v retrieving revision 1.18 diff -u -p -u -p -r1.18 patch-configure --- patches/patch-configure 13 Jan 2019 15:34:55 -0000 1.18 +++ patches/patch-configure 10 Jan 2021 17:59:00 -0000 @@ -2,7 +2,31 @@ $OpenBSD: patch-configure,v 1.18 2019/01 Index: configure --- configure.orig +++ configure -@@ -36944,7 +36944,7 @@ fi +@@ -23623,7 +23623,6 @@ else + case "$host_os" in + # Guess yes on musl systems. + *-musl*) gl_cv_func_getcwd_succeeds_beyond_4k="guessing yes" ;; +- # Guess no otherwise, even on glibc systems. + *) gl_cv_func_getcwd_succeeds_beyond_4k="guessing no" + esac + +@@ -23747,6 +23746,7 @@ main () + } + + _ACEOF ++ + if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_getcwd_succeeds_beyond_4k=yes + else +@@ -23758,6 +23758,7 @@ else + fi + + fi ++gl_cv_func_getcwd_succeeds_beyond_4k=yes + rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext + fi +@@ -40537,7 +40538,7 @@ fi $as_echo "$acl_cv_rpath" >&6; } wl="$acl_cv_wl" acl_libext="$acl_cv_libext" Index: patches/patch-src_misc_c =================================================================== RCS file: patches/patch-src_misc_c diff -N patches/patch-src_misc_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_misc_c 10 Jan 2021 17:59:00 -0000 @@ -0,0 +1,18 @@ +$OpenBSD$ + +Ignore getcwd return value. Partial revert of commit 66162927ebdfe9dd4ef570a132663fd76217952f + +Index: src/misc.c +--- src/misc.c.orig ++++ src/misc.c +@@ -920,8 +920,8 @@ chdir_arg (char const *dir) + { + wd[wd_count].name = "."; + wd[wd_count].abspath = xgetcwd (); +- if (!wd[wd_count].abspath) +- call_arg_fatal ("getcwd", "."); ++// if (!wd[wd_count].abspath) ++// call_arg_fatal ("getcwd", "."); + wd[wd_count].fd = AT_FDCWD; + wd_count++; + }
