View Issue Details

IDProjectCategoryView StatusLast Update
0017715CentOS-7tarpublic2020-09-06 01:07
ReporterElliott 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionno change required 
Product Version7.4.1708 
Target VersionFixed in Version 
Summary0017715: tar does not preserve permissions when extracting from gz archive
DescriptionUsing the -p option is supposed to preserve permissions when extracting. This works for regular tar archives, but it fails when the archive is gzipped.
The -p option is supposed to be used by default when running as root, and this also has the same problem.
Steps To Reproduce[alt@osddatabase newdir]$ ls -l
total 0
[alt@osddatabase newdir]$ echo "something" > file
[alt@osddatabase newdir]$ sudo chown apache:apache file
[alt@osddatabase newdir]$ ls -l
total 4
-rw-rw-r--. 1 apache apache 10 Sep 5 17:48 file
[alt@osddatabase newdir]$ tar czpf archive.tar.gz file
[alt@osddatabase newdir]$ tar tvf archive.tar.gz
-rw-rw-r-- apache/apache 10 2020-09-05 17:48 file
[alt@osddatabase newdir]$ tar xzpf archive.tar.gz
[alt@osddatabase newdir]$ ls -l
total 8
-rw-rw-r--. 1 alt alt 129 Sep 5 17:49 archive.tar.gz
-rw-rw-r--. 1 alt alt 10 Sep 5 17:48 file
Additional InformationI'm using tar version 1.26 included in the base install.
TagsNo tags attached.
abrt_hash
URL

Activities

ManuelWolfshant

ManuelWolfshant

2020-09-06 01:07

manager   ~0037652

Just like you needed root priv to alter the ownership of the file prior to archiving it, you also need to run tar with root privs in order to restore permissions which are not the same as those of the user running tar. Otherwise you'd be creating a huge security problem since any user could create files owned by another user simply by untaring an archive created on a different system, where they have the privs needed to alter the owner of a file

Issue History

Date Modified Username Field Change
2020-09-06 00:51 Elliott New Issue
2020-09-06 01:07 ManuelWolfshant Status new => closed
2020-09-06 01:07 ManuelWolfshant Resolution open => no change required
2020-09-06 01:07 ManuelWolfshant Note Added: 0037652