Bug 1001875

Summary: Argument 'excludes' of tar-out does not work
Product: Red Hat Enterprise Linux 7 Reporter: bfan
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: leiwang, wshi
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.22.6-5.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 10:04:29 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 bfan 2013-08-28 02:53:34 UTC
Description of problem:
Argument 'excludes' of tar-out does not work


Version-Release number of selected component (if applicable):
libguestfs-1.22.6-4.el7.x86_64


How reproducible:
Always


Steps to Reproduce:
# guestfish -a test1.img -m /dev/sda1

><fs> ll /
total 17
drwxr-xr-x  3 root root  1024 Aug 22 11:05 .
drwxr-xr-x 23 root root  4096 Aug 22 11:02 ..
-rw-r--r--  1 root root     0 Aug 22 11:05 hello.c
-rw-r--r--  1 root root     0 Aug 22 11:05 helloworld.c
drwx------  2 root root 12288 Aug 21 16:39 lost+found
-rw-r--r--  1 root root     0 Aug 22 11:05 world.c

><fs> tar-out / /tmp/excludes1 excludes:"hello*"
><fs> tar-out / /tmp/excludes2 excludes:"hello.*"
><fs> tar-out / /tmp/excludes3 excludes:"hello.c"


# tar tvf /tmp/excludes1
drwxr-xr-x root/root         0 2013-08-22 11:05 ./
-rw-r--r-- root/root         0 2013-08-22 11:05 ./hello.c
-rw-r--r-- root/root         0 2013-08-22 11:05 ./helloworld.c
drwx------ root/root         0 2013-08-21 16:39 ./lost+found/
-rw-r--r-- root/root         0 2013-08-22 11:05 ./world.c

# tar tvf /tmp/excludes2
drwxr-xr-x root/root         0 2013-08-22 11:05 ./
-rw-r--r-- root/root         0 2013-08-22 11:05 ./hello.c
-rw-r--r-- root/root         0 2013-08-22 11:05 ./helloworld.c
drwx------ root/root         0 2013-08-21 16:39 ./lost+found/
-rw-r--r-- root/root         0 2013-08-22 11:05 ./world.c

# tar tvf /tmp/excludes3
drwxr-xr-x root/root         0 2013-08-28 10:37 ./
-rw-r--r-- root/root         0 2013-08-28 10:35 ./hello.c
-rw-r--r-- root/root         0 2013-08-28 10:35 ./helloworld.c
drwx------ root/root         0 2013-08-28 10:35 ./lost+found/
-rw-r--r-- root/root         0 2013-08-28 10:35 ./world.c


Actual results:
The matched files are still included in tar package


Expected results:
The matched files are not included in tar package


Additional info:
Has same issue in RHEL6, libguestfs-1.20.10-3.el6.x86_64

Comment 1 Richard W.M. Jones 2013-08-29 12:45:25 UTC
This is actually user error (it wasn't obvious, even to me).

If you write:

><fs> tar-out / /tmp/excludes1 excludes:"hello*"

then the list of strings passed to libguestfs is:

[ "\"hello*\"" ]

ie. the quotes are included in the string.  libguestfs
correctly passes this, quoting and everything, to the
tar command.

The correct command is:

><fs> tar-out / /tmp/excludes1 "excludes:hello*"

or you can omit the quotes (in this case).

Nevertheless, I've make the use of the optional excludes
pattern more robust, and also added a regression test:

https://github.com/libguestfs/libguestfs/commit/91c162586cc2170ea224016307016153f3d081b5
https://github.com/libguestfs/libguestfs/commit/1b34d6171bb4aaa1134a9d867918d7163cc7e069

Comment 2 Richard W.M. Jones 2013-08-29 14:22:40 UTC
Fix also included in libguestfs-1.20.10-4.el6 (note
there is no separate bug for RHEL 6, I just included
the fix in the routine build).

Comment 4 bfan 2013-12-04 05:46:31 UTC
Verified with libguestfs-1.22.6-16.el7.x86_64

><fs> ll /
total 4
drwxr-xr-x  2 root root   53 Dec  4 13:36 .
drwxr-xr-x 23 root root 4096 Dec  4 13:35 ..
-rw-r--r--  1 root root    0 Dec  4 13:36 hello.c
-rw-r--r--  1 root root    0 Dec  4 13:36 helloworld.c
-rw-r--r--  1 root root    0 Dec  4 13:36 world.c

><fs> tar-out / /tmp/excludes1 excludes:hello*
><fs> tar-out / /tmp/excludes2 "excludes:hello*"

[root@]# tar tvf /tmp/excludes1
drwxr-xr-x root/root         0 2013-12-04 13:36 ./
-rw-r--r-- root/root         0 2013-12-04 13:36 ./world.c
[root@]# tar tvf /tmp/excludes2
drwxr-xr-x root/root         0 2013-12-04 13:36 ./
-rw-r--r-- root/root         0 2013-12-04 13:36 ./world.c


It works with two ways

Comment 5 Ludek Smid 2014-06-13 10:04:29 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.