bugGNU tar - Bugs: bug #66774, extract: permissions for...

 
 

bug #66774: extract: permissions for auto-created directory not applied in combination with --skip-old-files

Submitter:  Fiona Ebner <febner>
Submitted:  Mon 10 Feb 2025 03:58:53 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  gray
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 14 Mar 2025 01:12:18 PM UTC, comment #1: 

Fixed in commit cd1f6624f7.  Please, pull.  Notice, that you will need the --delay-directory-restore option in order to extract, e.g.:

  tar -xf archive.tar --skip-old-files --delay-directory-restore

Sergey Poznyakoff <gray>
Group administrator
Mon 10 Feb 2025 03:58:53 PM UTC, original submission:  

When using the '--skip-old-files' flag, tar will also skip applying metadata for directories that it auto-created itself during extraction. This can be seen in the following example:

[I] febner@dev8 ~/repos/tar/src/test (master)> ../tar cpf archive.tar dir/put-me-first-for-fast-extraction
[I] febner@dev8 ~/repos/tar/src/test (master)> ../tar rpf archive.tar --exclude dir/put-me-first-for-fast-extraction dir
[I] febner@dev8 ~/repos/tar/src/test (master)> ../tar tvf archive.tar
-rw-r--r-- febner/febner     4 2025-02-10 16:35 dir/put-me-first-for-fast-extraction
drwx------ febner/febner     0 2025-02-10 16:35 dir/
-rw-r--r-- febner/febner     4 2025-02-10 16:35 dir/other
[I] febner@dev8 ~/repos/tar/src/test (master)> rm -r dir
[I] febner@dev8 ~/repos/tar/src/test (master)> ../tar xpf archive.tar --skip-old-files
[I] febner@dev8 ~/repos/tar/src/test (master)> ls -l
total 16
-rw-r--r-- 1 febner febner 10240 Feb 10 16:36 archive.tar
drwxr-xr-x 2 febner febner  4096 Feb 10 16:36 dir/


The permissions are as in the archive when extracting without the '--skip-old-files' flag of course:

[I] febner@dev8 ~/repos/tar/src/test (master)> rm -r dir
[I] febner@dev8 ~/repos/tar/src/test (master)> ../tar xpf archive.tar
[I] febner@dev8 ~/repos/tar/src/test (master)> ls -l
total 16
-rw-r--r-- 1 febner febner 10240 Feb 10 16:36 archive.tar
drwx------ 2 febner febner  4096 Feb 10 16:35 dir/


The use case for putting a file before its containing directory is fast/cheap extraction of just that file which for my use case is needed more often than full extraction of the whole archive.

Of course, the issue can be worked around outside of tar, but it still seems surprising that the permissions for the created directory are not as in the archive.

Would keeping a list of auto-created directories during extraction and still updating metadata for those (for the first time they appear in the archive) be a possible approach? Or would that be too wasteful just for this edge case?

Another approach might be to allow '--overwrite-dir' together with '--skip-old-files'. With the latter option only applying to non-directories then. While the original behavior would remain, this would at least provide an escape hatch.

Fiona Ebner <febner>

 

(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 gray (Posted a comment)
  • -email is unavailable- added by febner (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.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-03-14 gray StatusNone Fixed
        Assigned toNone gray

    Back to the top

    Powered by Savane 3.14-430a.
    Corresponding source code