]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
Prefer O_PATH to O_SEARCH on Linux kernels
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 9 Nov 2025 19:12:13 +0000 (11:12 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 15 Nov 2025 23:10:48 +0000 (15:10 -0800)
* src/tar.c (decode_options): Prefer O_PATH to an O_SEARCH that is
actually O_RDONLY.

NEWS
src/tar.c

diff --git a/NEWS b/NEWS
index 4a216758cf5440c38a42bd9fe3394bfe3ab1f54e..866edcee2bc81317e4478b6feeb398b9cd258175 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-GNU tar NEWS - User visible changes. 2025-10-19
+GNU tar NEWS - User visible changes. 2025-11-09
 Please send GNU tar bug reports to <bug-tar@gnu.org>
 \f
 version 1.35.90 (git)
@@ -49,6 +49,9 @@ option.
    not even temporarily.  This matches the documentation better and avoids
    some permissions glitches.
 
+** tar no longer fails merely if an extraction directory is unreadable
+   on Linux kernels.
+
 ** tar now works better in strict debugging environments that do not
    allow pointer arithmetic to escape from a sub-element of an array.
 
index 9be0d7f049952857bef5cc9da6dbfc9f9d4aadde..0911a9e1a4a14ebfe20df2fd93fb2402dfd6b52a 100644 (file)
--- a/src/tar.c
+++ b/src/tar.c
@@ -2701,7 +2701,12 @@ decode_options (int argc, char **argv)
        | (dereference_option ? 0 : O_NOFOLLOW)
        | (atime_preserve_option == system_atime_preserve ? O_NOATIME : 0));
     open_read_flags = O_RDONLY | base_open_flags;
-    open_searchdir_flags = O_SEARCH | O_DIRECTORY | base_open_flags;
+#if defined O_PATH && O_SEARCH == O_RDONLY
+    int open_search_flag = O_PATH;
+#else
+    int open_search_flag = O_SEARCH;
+#endif
+    open_searchdir_flags = open_search_flag | O_DIRECTORY | base_open_flags;
   }
   fstatat_flags = dereference_option ? 0 : AT_SYMLINK_NOFOLLOW;