[Bug 16102] New: tar doesn't preserver original file permissions

bugzilla at busybox.net bugzilla at busybox.net
Mon Jun 10 12:28:21 UTC 2024


https://bugs.busybox.net/show_bug.cgi?id=16102

            Bug ID: 16102
           Summary: tar doesn't preserver original file permissions
           Product: Busybox
           Version: 1.36.x
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Other
          Assignee: unassigned at busybox.net
          Reporter: glasswalk3r at yahoo.com.br
                CC: busybox-cvs at busybox.net
  Target Milestone: ---

The tar program included in the Busybox is not compliant regarding preserving
the original permissions of files inside a tarball.

I'm the maintainer of the Perl module Archive::Tar::Wrapper, and getting
multiple failures of testing inside the Alpine Linux distribution, which
failures can be seen in the link
http://matrix.cpantesters.org/?dist=Archive-Tar-Wrapper%200.40;os=linux;perl=5.39.11;reports=1.

Since is a wrapper, applying the command line option -p is not working as
expected. I also made several attempts of achieving the same result manually,
following the available manpage:

localhost:~$ tar --help
BusyBox v1.36.1 (2023-11-07 18:53:09 UTC) multi-call binary.

Usage: tar c|x|t [-ZzJjahmvokO] [-f TARFILE] [-C DIR] [-T FILE] [-X FILE]
[LONGOPT]... [FILE]...

Create, extract, or list files from a tar file

    c    Create
    x    Extract
    t    List
    -f FILE    Name of TARFILE ('-' for stdin/out)
    -C DIR    Change to DIR before operation
    -v    Verbose
    -O    Extract to stdout
    -m    Don't restore mtime
    -o    Don't restore user:group
    -k    Don't replace existing files
    -Z    (De)compress using compress
    -z    (De)compress using gzip
    -J    (De)compress using xz
    -j    (De)compress using bzip2
    --lzma    (De)compress using lzma
    -a    (De)compress based on extension
    -h    Follow symlinks
    -T FILE    File with names to include
    -X FILE    File with glob patterns to exclude
    --exclude PATTERN    Glob pattern to exclude
    --overwrite        Replace existing files
    --strip-components NUM    NUM of leading components to strip
    --no-recursion        Don't descend in directories
    --numeric-owner        Use numeric user:group
    --no-same-permissions    Don't restore access permissions

Nothing there about "-p", but "--no-same-permissions" tells me it should do it
by default, which doesn't work either.

After some effort to have manpages installed on Alpine, I got this:

       -p, --preserve-permissions, --same-permissions
              Set permissions of extracted files to those recorded in the
              archive (default for superuser).

Then I tried all the three variations, with the following results:

    -p and --same-permissions are ignored
    --preserve-permissions is not accepted as a valid argument

localhost:~/.cpan/build/Archive-Tar-Wrapper-0.40-0$ tar --same-permissions -xvf
t/data/bar.tar 
bar/
bar/bar.dat
bar/foo.dat
localhost:~/.cpan/build/Archive-Tar-Wrapper-0.40-0$ ls -l bar/
total 8
-rw-r--r--    1 goku     goku            11 Jul 24  2005 bar.dat
-rw-r--r--    1 goku     goku            11 Jul 24  2005 foo.dat
localhost:~/.cpan/build/Archive-Tar-Wrapper-0.40-0$ rm -rf bar/
localhost:~/.cpan/build/Archive-Tar-Wrapper-0.40-0$ tar --preserve-permissions
-xvf t/data/bar.tar
tar: unrecognized option: preserve-permissions
BusyBox v1.36.1 (2023-11-07 18:53:09 UTC) multi-call binary.

Usage: tar c|x|t [-ZzJjahmvokO] [-f TARFILE] [-C DIR] [-T FILE] [-X FILE]
[LONGOPT]... [FILE]...

localhost:~/.cpan/build/Archive-Tar-Wrapper-0.40-0$ tar -x -v -p -f
t/data/bar.tar 
bar/
bar/bar.dat
bar/foo.dat
localhost:~/.cpan/build/Archive-Tar-Wrapper-0.40-0$ ls -l bar/
total 8
-rw-r--r--    1 goku     goku            11 Jul 24  2005 bar.dat
-rw-r--r--    1 goku     goku            11 Jul 24  2005 foo.dat

As a reminder, Archive::Tar::Wrapper is expecting to get the group with "rw"
permissions:

localhost:~/.cpan/build/Archive-Tar-Wrapper-0.40-0$ tar -tvf t/data/bar.tar 
drwxrwxr-x mschilli/mschilli         0 2005-07-24 16:15:34 bar/
-rw-rw-r-- mschilli/mschilli        11 2005-07-24 16:15:27 bar/bar.dat
-rw-rw-r-- mschilli/mschilli        11 2005-07-24 16:15:34 bar/foo.dat

Please let me know if you need additional information.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the busybox-cvs mailing list