bugGNU tar - Bugs: bug #64589, [regression] tar -C fails to...

 
 

bug #64589: [regression] tar -C fails to unpack files in directory which it cannot read

Submitter:  kdevel <kdevel>
Submitted:  Thu 24 Aug 2023 11:37:59 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 24 Aug 2023 11:37:59 AM UTC, original submission:  

Back in 2018 I reported the current issue in

   bug #54108: tar -C: directory without read permission: use
   openat with O_PATH/O_SEARCH

which contains a reproducer but unfortunately lacks a texttual
elucidation of the error. The reproducer must be executed as
unprivileged user (non-root).

In order to reproduce this error a directory dir without read
permission (e.g, chmod 0311) is required an then tar is
asked to extract its files into that directory using
tar -C dir. Please find the details in bug #54108

Supposedly that the bug was introduced with tar 1.24.

As Sergey Poznyakoff recently pointed out to me this bug is
most likely caused by a bug in gnulib:

Quote:

> > The problem can be fixed by utilizing O_PATH/O_SEARCH (whatever is
> > available on the system). I could not find any fixes in the code.


As a matter if fact, O_SEARCH is used in the code, see src/tar.c:2650
[1]. The open_searchdir_flags variable is then passed to open(1) when
processing the -C option in src/misc.c:989 [2].  The use of O_SEARCH
dates back to commit q8da503cad6 [3], which predates the commit {1}
you mentioned by several days.

The problem with this approach is that tar uses gnulib [4] for
portability fixes, one of which is supplying the definition of
O_SEARCH for systems lacking it. And it is this definition [5], which is
the cause of the problem.  Clearly, at least on GNU/Linux systems, it
should have been defined to O_PATH instead.

[...]

[1] http://git.savannah.gnu.org/cgit/tar.git/tree/src/tar.c#n2650
[2] http://git.savannah.gnu.org/cgit/tar.git/tree/src/misc.c#n989
[3] http://git.savannah.gnu.org/cgit/tar.git/commit/?id=8da503cad6e883b30c05749149084d24319063b4
[4] https://www.gnu.org/software/gnulib/
[5] https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/fcntl.in.h#n372

End Quote

{1} commit 4bde4f39d08f000f7e63a832b08a2525c1262f84
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Sat Sep 18 23:37:45 2010 -0700

kdevel <kdevel>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by kdevel (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code