Hello all, I am trying to determine if I'm encountering a bug or expected behavior with Archive::Tar. I've noticed that if I archive a directory such as /usr/include/sys/*.h that permissions are retained only for files underneath the sys directory. The permissions for /usr/include/sys change to the user that is extracting the files, including root. If the directory(/usr/include/sys) is owned by someone other than root it is not retained even if root does the extraction. If I use tar standalone to archive the directory then the permissions are retained for all directories. Is this to be expected? Additionally I've noticed that I cannot archive named pipes at all. The process will attempt to open the pipe and remain hung waiting on a response. This is the basic code I am using.
use Archive::Tar; $tar = Archive::Tar->new(); $tar->add_files(<"/usr/include/sys/*.h">) or die("Failed $!\n"); $tar->write("files.tar") or die("Failed $!\n");
These are the permissions on the original directories: ls -ld /usr drwxr-xr-x 54 root sys 69 Apr 9 2018 /usr ls -ld /usr/include drwxr-xr-x 117 root bin 436 Sep 25 22:10 /usr/include ls -ld /usr/include/sys drwxr-xr-x 25 root bin 628 Sep 25 22:09 /usr/include/sys When I extract the archive(as root) generated from my code I see these permissions: ls -ld usr drwxr-xr-x 3 root root 512 Jan 20 13:06 usr ls -ld usr/include drwxr-xr-x 3 root root 512 Jan 20 13:06 usr/include ls -ld usr/include/sys drwxr-xr-x 2 root root 11776 Jan 20 13:07 usr/include/sys Thank you for any assistance!

In reply to Archive::Tar directory permissions by LiveandLearn2021

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.