summaryrefslogtreecommitdiffstats
path: root/inspector
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2010-05-12 15:58:00 +0100
committerRichard Jones <rjones@redhat.com>2010-05-13 16:22:05 +0100
commit1c6ed48bd3cd471dc6e4613ede9151631e19f55a (patch)
tree5362b4fbb95e91dfa6b1811df9b9f0105309071f /inspector
parent72324580801f2c0e2b702b430b90eb141618c7f4 (diff)
downloadlibguestfs-1c6ed48bd3cd471dc6e4613ede9151631e19f55a.tar.gz
libguestfs-1c6ed48bd3cd471dc6e4613ede9151631e19f55a.tar.xz
libguestfs-1c6ed48bd3cd471dc6e4613ede9151631e19f55a.zip
guestfish -i and virt-inspector work on filenames containing spaces (RHBZ#507810).
This commit fixes a long-standing bug which prevented guestfish -i and virt-inspector from working on disk images which had a space in the filename (or other unsafe characters). It works by ensuring that the strings passed between guestfish -i and virt-inspector are quoted correctly in both directions. Note that this commit adds a dependency from virt-inspector to the perl module String::ShellQuote. We have previously used this module in virt-make-fs.
Diffstat (limited to 'inspector')
-rwxr-xr-xinspector/virt-inspector9
1 files changed, 7 insertions, 2 deletions
diff --git a/inspector/virt-inspector b/inspector/virt-inspector
index 4428ecda..f62d21fc 100755
--- a/inspector/virt-inspector
+++ b/inspector/virt-inspector
@@ -27,6 +27,7 @@ use Pod::Usage;
use Getopt::Long;
use Data::Dumper;
use XML::Writer;
+use String::ShellQuote qw(shell_quote);
use Locale::TextDomain 'libguestfs';
# Optional:
@@ -298,13 +299,17 @@ if ($output eq "fish" || $output eq "ro-fish") {
print "--ro ";
}
- print "-a $_ " foreach @images;
+ foreach (@images) {
+ printf "-a %s ", shell_quote ($_);
+ }
my $mounts = $oses->{$root_dev}->{mounts};
# Have to mount / first. Luckily '/' is early in the ASCII
# character set, so this should be OK.
foreach (sort keys %$mounts) {
- print "-m $mounts->{$_}:$_ " if $_ ne "swap" && $_ ne "none";
+ if ($_ ne "swap" && $_ ne "none") {
+ printf "-m %s ", shell_quote ("$mounts->{$_}:$_");
+ }
}
print "\n"
}