[Libguestfs] [PATCH] guestfish -i and virt-inspector work on filenames containing spaces (RHBZ#507810).
Richard W.M. Jones
rjones at redhat.com
Thu May 13 15:20:57 UTC 2010
On Thu, May 13, 2010 at 03:17:56PM +0100, Matthew Booth wrote:
> > + //fprintf (fp, "virt-inspector");
> > + fprintf (fp, "inspector/run-inspector-locally");
>
> I don't think ^^^ is still supposed to be there.
Good catch!
> > - r = system (cmd);
> > + int r = system (cmd2);
>
> Incidentally, why don't we just exec() here?
The reason is we have to build this command up from strings (the plain
text output of virt-inspector --fish). This is in fact the reason why
we have the quoting problem in the first place.
> > +static int
> > +print_shell_quote (FILE *stream, const char *str)
> > +{
> > +#define SAFE(c) (c_isalnum((c)) || \
> > + (c) == '/' || (c) == '-' || (c) == '_' || (c) == '.')
> > + int i, len;
> > +
> > + for (i = len = 0; str[i]; ++i) {
> > + if (!SAFE(str[i])) {
> > + putc ('\\', stream);
> > + len ++;
> > + }
> > + putc (str[i], stream);
> > + len ++;
> > + }
> > +
> > + return len;
> > +}
>
> The return value of print_shell_quote isn't used. No need to track len.
Yup, this was copied and pasted from some other code in the daemon.
I'll fix this.
> > +use String::ShellQuote qw(shell_quote);
>
> String::ShellQuote isn't in RHEL 5. Are you really sure you want this?
This patch is quite invasive, so it's not a candidate for the stable
branch, which means we won't have it in RHEL 5. RHEL 5 users will
just have to support with guestfish -i not working for filenames
containing spaces ...
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://et.redhat.com/~rjones/libguestfs/
See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
More information about the Libguestfs
mailing list