Pino Toscano
2014-Sep-29 14:57 UTC
[Libguestfs] [PATCH] chroot: fix quoting in cp invocation
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
Richard W.M. Jones
2014-Sep-29 15:21 UTC
Re: [Libguestfs] [PATCH] chroot: fix quoting in cp invocation
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.3ACK. 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
Possibly Parallel Threads
- [PATCH 0/3] supermin: add --include-packagelist
- [PATCH 03/27] daemon: Reimplement ‘file’ API in OCaml.
- [supermin 1/2] chroot: Fix corner case introduced with dpkg-divert support
- [supermin 3/3] Use the file tuple up to the point where files are copied into the filesystem / chroot
- plotting border over map