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 957796 - tar-out and base64-out quoting error
Summary: tar-out and base64-out quoting error
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libguestfs
Version: 7.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Richard W.M. Jones
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 957772
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-04-29 14:33 UTC by Richard W.M. Jones
Modified: 2014-06-18 01:59 UTC (History)
5 users (show)

Fixed In Version: libguestfs-1.22.4-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of: 957772
Environment:
Last Closed: 2014-06-13 09:29:34 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Richard W.M. Jones 2013-04-29 14:33:15 UTC
+++ This bug was initially created as a clone of Bug #957772 +++

Description of problem:

(Found by infernix on IRC)

The 'tar-out' command does not quote the directory name properly,
meaning that if it contains spaces (or worse, shell meta-characters)
those are not handled properly.

Reproducer:

guestfish -v -N fs -m /dev/sda1 <<EOF
mkdir "/foo bar"
tar-out "/foo bar" /tmp/test.tar
EOF

The command will fail, and in the verbose messages you will see:

  .....
  tar -C /sysroot/foo bar -cf - .
  tar: /sysroot/foo: Cannot chdir: No such file or directory
  tar: Error is not recoverable: exiting now
  pclose: /foo bar: Success
  guestfsd: mainlibguestfs: error: file receive cancelled by daemon
  libguestfs: error: /tmp/test.tar: error in chunked encoding
  .....

Notice that the tar -C option is not properly quoted, so it is
passed as two parameters to tar.

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

1.16 - not able to test, but based on code inspection: no
1.18 - no
1.20 - YES
1.21 - YES

--- Additional comment from Richard W.M. Jones on 2013-04-29 09:51:32 EDT ---

The commit which introduced this error was:

https://github.com/libguestfs/libguestfs/commit/c78ec7e085e99bfddd0509dece72bf6a8d0188ce

which was also backported to the stable-1.20 branch:

https://github.com/libguestfs/libguestfs/commit/1bd81388e02be2e46c24f700217be32786d3ae1a

The error was introduced as part of the fix for RHBZ#908322.

--- Additional comment from Richard W.M. Jones on 2013-04-29 09:54:27 EDT ---

The fix for bug 908322 also broke the base64-out command
in the same way:

guestfish -v -N fs -m /dev/sda1 <<EOF
touch "/foo bar"
base64-out "/foo bar" /tmp/test.b64
EOF

In the verbose output for this command you will see:

  .....
  base64 /sysroot/foo bar
  base64: extra operand '/sysroot/foo'
  Try 'base64 --help' for more information.
  pclose: /foo bar: Success
  guestfsd: main_loop: proc 243 (base64_out) took 0.00 seconds
  libguestfs: error: file receive cancelled by daemon
  libguestfs: error: /tmp/test.b64: error in chunked encoding
  .....

which is the same kind of problem as for tar.

--- Additional comment from Richard W.M. Jones on 2013-04-29 10:31:58 EDT ---

Fixed upstream:
https://github.com/libguestfs/libguestfs/commit/c5f356a60351dd51cbd3a9aabcac2cd40562f36a (fix)
https://github.com/libguestfs/libguestfs/commit/cc93840d31e440e64e27ee13df3afd134ef2e68f (regression test)

Comment 3 Can Zhang 2013-11-07 07:59:01 UTC
I reproduced the bug using libguestfs-1.20.2-1.el7 and verified it with libguestfs-1.22.6-15.el7.

In the buggy version, I catched

...
tar -C /sysroot/foo bar -cf - .
libguestfs: recv_from_daemon: 40 bytes: 20 00 f5 f5 | 00 00 00 04 | 00 00 00 46 | 00 00 00 01 | 00 12 34 04 | ...
tar: /sysroot/foo: Cannot chdir: No such file or directory
tar: Error is not recoverable: exiting now
pclose: /foo bar: Success
...


and in the latest version, it works well.

Comment 4 Ludek Smid 2014-06-13 09:29:34 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.


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