Bug 1351000 - virt-customize --commands-from-file will fail if there is an extra blank in the file
Summary: virt-customize --commands-from-file will fail if there is an extra blank in t...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libguestfs
Version: 8.0
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: rc
: 8.1
Assignee: Pino Toscano
QA Contact: YongkuiGuo
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-06-29 02:00 UTC by Xianghua Chen
Modified: 2020-05-05 09:45 UTC (History)
7 users (show)

Fixed In Version: libguestfs-1.40.2-21.module+el8.2.0+5851+8d6a931b
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-05-05 09:43:16 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2020:2017 0 None None None 2020-05-05 09:45:46 UTC

Description Xianghua Chen 2016-06-29 02:00:18 UTC
Description of problem:
virt-customize --commands-from-file will fail if there is an extra blank in the file.

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

How reproducible:
Always

Steps to Reproduce:
1. Prepare a RHEL guest image:
RHEL-Server-7.2-64-hvm.raw

2. Create a script file as following (Note that there is a blank between the arg and the command or before the command line):
# cat test.sh
install   git
 mkdir /root/dir1
write /root/dir1/fiel1:"test file1"

3.
# virt-customize -a RHEL-Server-7.2-64-hvm.raw --commands-from-file test.sh
virt-customize: error: command '' not valid, see the man page

If reporting bugs, run virt-customize with debugging enabled and include
the complete output:

  virt-customize -v -x [...]



There is no difference when using -v -x.


Actual results:
As above output.

Expected results:
It should ignore the blank and finish the commands successfully.

Additional info:

Comment 1 Martin Kletzander 2020-01-23 13:05:35 UTC
Patch posted upstream:

https://www.redhat.com/archives/libguestfs/2020-January/msg00180.html

Comment 5 YongkuiGuo 2020-02-25 08:55:20 UTC
Try to verify this bug with package:
libguestfs-1.40.2-21.module+el8.2.0+5851+8d6a931b.x86_64

Steps:

1. Create a script file and there are whitespaces before the first command line
# cat test.sh
  mkdir /root/dir1
write /root/dir1/file1:"test file1"

2.
# virt-customize -a RHEL-Server-8.2.0-64-20191203.0-hvm.raw --commands-from-file test.sh
[   0.0] Examining the guest ...
[   8.4] Setting a random seed
[   8.4] Making directory: /root/dir1
[   8.4] Writing: /root/dir1/file1
[   8.5] Finishing off

It works.

3. Change the test.sh and add whitespace between the install command and its argument.
# cat test.sh
install  git          
  mkdir /root/dir1
write /root/dir1/file1:"test file1"

4.
# virt-customize -a RHEL-Server-8.2.0-64-20191203.0-hvm.raw --commands-from-file test.sh
[   0.0] Examining the guest ...
[   8.0] Setting a random seed
[   8.1] Installing packages:  git
...
No match for argument:  git
Error: Unable to find a match:  git
virt-customize: error: dnf -y install ' git': command exited with an error

If reporting bugs, run virt-customize with debugging enabled and include 
the complete output:

  virt-customize -v -x [...]

It failed due to the extra whitespace before the argument.

Comment 6 Pino Toscano 2020-02-25 09:49:33 UTC
(In reply to YongkuiGuo from comment #5)
> 3. Change the test.sh and add whitespace between the install command and its
> argument.
> # cat test.sh
> install  git          
>   mkdir /root/dir1
> write /root/dir1/file1:"test file1"
> 
> 4.
> # virt-customize -a RHEL-Server-8.2.0-64-20191203.0-hvm.raw
> --commands-from-file test.sh
> [   0.0] Examining the guest ...
> [   8.0] Setting a random seed
> [   8.1] Installing packages:  git
> ...
> No match for argument:  git
> Error: Unable to find a match:  git
> virt-customize: error: dnf -y install ' git': command exited with an error

This was not what this bug was about, and indeed it was not covered by the fix.
The fix is only about the whitespaces before the command.

Comment 7 YongkuiGuo 2020-02-25 10:14:57 UTC
(In reply to Pino Toscano from comment #6)
> (In reply to YongkuiGuo from comment #5)
> > 3. Change the test.sh and add whitespace between the install command and its
> > argument.
> > # cat test.sh
> > install  git          
> >   mkdir /root/dir1
> > write /root/dir1/file1:"test file1"
> > 
> > 4.
> > # virt-customize -a RHEL-Server-8.2.0-64-20191203.0-hvm.raw
> > --commands-from-file test.sh
> > [   0.0] Examining the guest ...
> > [   8.0] Setting a random seed
> > [   8.1] Installing packages:  git
> > ...
> > No match for argument:  git
> > Error: Unable to find a match:  git
> > virt-customize: error: dnf -y install ' git': command exited with an error
> 
> This was not what this bug was about, and indeed it was not covered by the
> fix.
> The fix is only about the whitespaces before the command.

I saw this type of whitespace is included in the reproducible steps of the reporter(comment 0). Should we open a new bug for tracking this issue?

Comment 8 Pino Toscano 2020-02-25 16:54:47 UTC
(In reply to YongkuiGuo from comment #7)
> I saw this type of whitespace is included in the reproducible steps of the
> reporter(comment 0). Should we open a new bug for tracking this issue?

Martin?

Comment 9 Martin Kletzander 2020-02-26 09:36:54 UTC
Even though it is almost the same thing from the users' perspective, it is slightly different thing in the code.  I don't have a preference of whether we need another BZ or not, but it is not going to be fixed anyway.  I would say if you want that fixed than file another BZ with some reasoning behind that change.  Otherwise just leave it as it is and we can close this one.  The whitespace is just treated as part of the argument and I did not find any mention about them being supported in a way that would allow indentation or anything else.  The original problem was good to get fixed since it did not provide a useful error message.  This one, however, feels pointless to spent time on IMNSHO.  But thanks for trying it out.

Comment 10 YongkuiGuo 2020-03-02 03:46:42 UTC
According to comment 5 and comment 9, i will verify this bug. Thanks pino and martin for the explanation.

Comment 12 errata-xmlrpc 2020-05-05 09:43:16 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.

https://access.redhat.com/errata/RHBA-2020:2017


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