[Libguestfs] [PATCH] chroot: fix quoting in cp invocation

Richard W.M. Jones rjones at redhat.com
Mon Sep 29 15:21:24 UTC 2014


On Mon, Sep 29, 2014 at 04:57:42PM +0200, Pino Toscano wrote:
> Make sure to quote source and destination, to avoid failures when
> dealing with paths with e.g. spaces, brackets, etc.
> ---
>  src/chroot.ml | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/chroot.ml b/src/chroot.ml
> index 63a5a79..d0ee4c3 100644
> --- a/src/chroot.ml
> +++ b/src/chroot.ml
> @@ -60,7 +60,7 @@ let build_chroot debug files outputdir =
>  
>          | S_REG | S_CHR | S_BLK | S_FIFO | S_SOCK ->
>            if debug >= 2 then printf "supermin: chroot: copy %s\n%!" opath;
> -          let cmd = sprintf "cp -p %s %s" path opath in
> +          let cmd = sprintf "cp -p %s %s" (quote path) (quote opath) in
>            ignore (Sys.command cmd)
>        with Unix_error _ -> ()
>    ) files;
> -- 
> 1.9.3

ACK.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top




More information about the Libguestfs mailing list