Bug 1303702

Summary: tar --diff always report mode differ
Product: [Fedora] Fedora Reporter: Pavel Alexeev <pahan>
Component: tarAssignee: Pavel Raiskup <praiskup>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 23CC: kdudka, ovasik, pahan, praiskup
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-02-09 07:08:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pavel Alexeev 2016-02-01 17:18:59 UTC
Description of problem:
$ wget http://archive.apache.org/dist/activemq/5.13.0/apache-activemq-5.13.0-bin.tar.gz

$ sudo /usr/bin/tar -C "/opt/activemq" --extract -zf apache-activemq-5.13.0-bin.tar.gz ; echo $?
0

$ sudo /usr/bin/tar -C "/opt/activemq" --diff -zf apache-activemq-5.13.0-bin.tar.gz ; echo $?
apache-activemq-5.13.0/webapps-demo/demo/js: Mode differs
1

Version-Release number of selected component (if applicable):
$ rpm -q tar
tar-1.28-6.fc23.x86_64

That same in CentOS box:
rpm -q tar
tar-1.26-29.el7.x86_64

How reproducible:
Always

Comment 1 Pavel Raiskup 2016-02-02 14:55:02 UTC
Hi Pavel, this is not a bug (at least not in --diff).

# tar -vv --diff -f apache-activemq-5.13.0-bin.tar.gz -C /opt/activemq/ | grep -e 'Mode differs' -e 'demo/js/$'
drwx------ clshann/users        0 2015-11-30 13:53 apache-activemq-5.13.0/webapps-demo/demo/js/
apache-activemq-5.13.0/webapps-demo/demo/js: Mode differs
drwxr-xr-x 0/0                  0 2015-11-30 13:53 apache-activemq-5.13.0/webapps-demo/demo/js/

You can see that the directory is duplicated within tarball, each time it has
different mode.

This is valid tarball -- but you must expect that if if you extract, the
former mode is replaced with the later (last record wins).

Comment 2 Pavel Alexeev 2016-02-05 09:31:09 UTC
That bug not only in --diff, but in --extract inconsistent.

Why they are use it in different order? Result should be reproducible.
If extract can't extract archive properly (at least owner, rights, attributes) - why it report 0 exit code? If it threat it done correctly - then --diff should not complain it is not.

Comment 3 Pavel Raiskup 2016-02-05 09:47:15 UTC
Can you please elaborate what goes wrong?  IMO the extraction works fine.
When you extract the tarball, the last
apache-activemq-5.13.0/webapps-demo/demo/js/ record will succeed.  At least on
my box, after the tarball extraction:

drwxr-xr-x. 4 root root 4096 Nov 30 13:53 apache-activemq-5.13.0/webapps-demo/demo/js/

This is the "status" of the directory after successful extraction.  If you try
to compare this "status" by --diff with archive contents, it will show error
for the "first" record in the archive, because that has:

drwx------ clshann/users        0 2015-11-30 13:53 apache-activemq-5.13.0/webapps-demo/demo/js/

Comment 4 Pavel Alexeev 2016-02-08 17:14:05 UTC
How it may be twice in archive? I assume it can't be then extracted correctly to any filesystem, is not? If it legitimate case for some way, it should be then checked as extracted. So, if status of extract returned by last entrance - it also should be compared on make difference. I am wrong?

Comment 5 Pavel Raiskup 2016-02-09 07:08:35 UTC
(In reply to Pavel Alexeev from comment #4)
> How it may be twice in archive?

tar (ustar/pax) archive formats do not limit you in this case -- you may even
append to existing tar archive:

  $ touch a
  $ tar cf a.tar a a a
  $ tar tf a.tar 
  a
  a
  a

> I assume it can't be then extracted correctly to any filesystem, is not?

The last record wins during extraction.  All archive members are extracted,
consecutively from beginning of the archive to the end.  This means that if
there is some file twice, the later record in archive will replace the former
records.

> If it legitimate case for some way, it should be then checked as extracted.

There is no issue from tar's POV - so there is no need to complain.  This is
responsibility of archive creator.

> So, if status of extract returned by last entrance - it also should be
> compared on make difference. I am wrong?

All archive records are extracted (and with --diff compared).

Comment 6 Pavel Alexeev 2016-02-09 12:52:57 UTC
Ok, thanks for the detailed explanations. I'll continue search more info how it intended to be used in that case.