RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 688567 - option -C (change directory) does not work in combination with -u (update archive)
Summary: option -C (change directory) does not work in combination with -u (update arc...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: tar
Version: 6.0
Hardware: Unspecified
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Pavel Raiskup
QA Contact: Branislav Blaškovič
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-03-17 11:37 UTC by Nicolas Mitsis
Modified: 2017-12-18 10:52 UTC (History)
3 users (show)

Fixed In Version: tar-1.23-5.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-06-20 13:49:21 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
strace log from tar -C / -upvf ... (10.72 KB, text/x-log)
2011-04-01 15:36 UTC, Nicolas Mitsis
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2012:0849 0 normal SHIPPED_LIVE tar bug fix and enhancement update 2012-06-19 20:48:42 UTC

Description Nicolas Mitsis 2011-03-17 11:37:20 UTC
Description of problem:

option -C (change directory) does not work in combination with -u (update archive)

Version-Release number of selected component (if applicable):

tar-1.23-3.el6.x86_64

How reproducible:

always

Steps to Reproduce:
1. create archive
2. update archive with options -C and -u
3. update fails
  
Actual results:

update fails

Expected results:

update to succeed

Additional info:

example follows:

[root@void ~]# ls -l /a/
total 0
-rw-r--r--. 1 root root 0 Mar 17 13:07 1
-rw-r--r--. 1 root root 0 Mar 17 13:07 2
[root@void ~]# tar -C / -cpvf a.tar a
a/
a/1
a/2
[root@void ~]# echo $RANDOM > /a/1
[root@void ~]# touch /a/3 
[root@void ~]# tar -C / -upvf a.tar a
tar: a/1: Cannot stat: No such file or directory
tar: a/3: Cannot stat: No such file or directory
tar: a/2: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
[root@void ~]# tar tvf a.tar 
drwxr-xr-x root/root         0 2011-03-17 13:07 a/
-rw-r--r-- root/root         0 2011-03-17 13:07 a/1
-rw-r--r-- root/root         0 2011-03-17 13:07 a/2

From strace it seems fchdir() is called for 2nd time with wrong arguments:

...................................................
open(".", O_RDONLY)                     = 4
dup(4)                                  = 5
close(5)                                = 0
chdir("/")                              = 0
lstat("a", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("a", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 5
fcntl(5, F_GETFD)                       = 0x1 (flags FD_CLOEXEC)
getdents(5, /* 6 entries */, 32768)     = 144
getdents(5, /* 0 entries */, 32768)     = 0
close(5)                                = 0
open(".", O_RDONLY)                     = 5
dup(5)                                  = 6
close(6)                                = 0
fchdir(4)                               = 0
....................................................

Comment 2 RHEL Program Management 2011-03-17 12:07:52 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unfortunately unable to
address this request at this time. Red Hat invites you to
ask your support representative to propose this request, if
appropriate and relevant, in the next release of Red Hat
Enterprise Linux. If you would like it considered as an
exception in the current release, please ask your support
representative.

Comment 3 Ondrej Vasik 2011-03-31 14:36:07 UTC
Works for me on ext4 and tar-1.23-3.el6.i686 ...

[root@dhcp-24-196 tmp]# ls -l /a/
total 0
-rw-r--r--. 1 root root 0 Mar 31 16:32 1
-rw-r--r--. 1 root root 0 Mar 31 16:30 2
[root@dhcp-24-196 tmp]# tar -C / -cpvf a.tar a
a/
a/2
a/1
[root@dhcp-24-196 tmp]# echo $RANDOM > /a/1
[root@dhcp-24-196 tmp]# touch /a/3
[root@dhcp-24-196 tmp]# tar -C / -upvf a.tar a
a/3
[root@dhcp-24-196 tmp]# tar tvf a.tar
drwxr-xr-x root/root         0 2011-03-31 16:32 a/
-rw-r--r-- root/root         0 2011-03-31 16:30 a/2
-rw-r--r-- root/root         0 2011-03-31 16:32 a/1
-rw-r--r-- root/root         0 2011-03-31 16:30 a/3

Maybe something specific on your side?

Comment 4 Nicolas Mitsis 2011-04-01 15:36:47 UTC
Created attachment 489424 [details]
strace log from tar -C / -upvf ...

Comment 5 Nicolas Mitsis 2011-04-01 15:40:39 UTC
I've tried this in 2 different production systems and 1 clean vmware installation all on 64bit. Maybe the bug is absent from 32 ?

This is the version I've tried:

# tar --version
tar (GNU tar) 1.23

# rpm -q tar
tar-1.23-3.el6.x86_64

I've added also an strace log which shows fchdir() is called twice.

Comment 6 Ondrej Vasik 2011-04-01 16:28:04 UTC
Maybe, I'll check 64bit next week ... thanks for strace...

Comment 7 Ondrej Vasik 2011-06-06 12:31:56 UTC
Sorry for delay, behaviour confirmed on 64-bit RHEL-6 ... strange.

Comment 8 Ondrej Vasik 2011-06-06 13:04:50 UTC
Well, not exactly true, it seems to be reproducible even on 32 bit (but not always) ...
Failed stats:
x86_64:
lstat("a/2", 0x7fff0dcc68b0)            = -1 ENOENT (No such file or directory)
lstat("a/1", 0x7fff0dcc68b0)            = -1 ENOENT (No such file or directory)
lstat("a/3", 0x7fff0dcc6748)            = -1 ENOENT (No such file or directory)
i386:
lstat64("a/2", {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
lstat64("a/1", {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
lstat64("a/4", 0xbf939b44)              = -1 ENOENT (No such file or directory)

Will try to find out what's broken there ...

Comment 11 RHEL Program Management 2011-07-06 00:07:04 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unfortunately unable to
address this request at this time. Red Hat invites you to
ask your support representative to propose this request, if
appropriate and relevant, in the next release of Red Hat
Enterprise Linux. If you would like it considered as an
exception in the current release, please ask your support
representative.

Comment 13 Pavel Raiskup 2012-02-23 10:20:34 UTC
Fix proposed to upstream:

    http://www.mail-archive.com/bug-tar@gnu.org/msg03545.html

Comment 21 errata-xmlrpc 2012-06-20 13:49:21 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0849.html

Comment 22 Pavel Raiskup 2017-12-18 10:52:04 UTC
In the end fixed through:
http://lists.gnu.org/archive/html/bug-tar/2016-09/msg00024.html


Note You need to log in before you can comment on or make changes to this bug.