From bc29af7c0c5f1a48a17d2218e807497711af181d Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Sat, 13 Feb 2016 15:21:38 +0000 Subject: [PATCH 1/3] qvm-move-to-vm: Remove duplicated code --- file-copy-vm/qvm-move-to-vm | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/file-copy-vm/qvm-move-to-vm b/file-copy-vm/qvm-move-to-vm index 49f4d66..def8380 100644 --- a/file-copy-vm/qvm-move-to-vm +++ b/file-copy-vm/qvm-move-to-vm @@ -20,14 +20,6 @@ # # -if [ $# -lt 2 ] ; then - echo usage: $0 'dest_vmname file [file]+' - exit 1 -fi - -VM="$1" -shift - set -e -/usr/bin/qvm-run --pass-io --localcmd "/usr/lib/qubes/qfile-dom0-agent $@" "$VM" "QUBESRPC qubes.Filecopy dom0" +. qvm-copy-to-vm "$@" rm -rf -- "$@" From c177ae2c7a6160db376d3eabaf20ac9264ce34d5 Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Sat, 13 Feb 2016 15:21:39 +0000 Subject: [PATCH 2/3] qvm-copy-to-vm: Fix running with multiple file arguments --- file-copy-vm/qvm-copy-to-vm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/file-copy-vm/qvm-copy-to-vm b/file-copy-vm/qvm-copy-to-vm index 2091767..eee5e25 100644 --- a/file-copy-vm/qvm-copy-to-vm +++ b/file-copy-vm/qvm-copy-to-vm @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/bash +set -e -o pipefail # # The Qubes OS Project, http://www.qubes-os.org # @@ -28,4 +29,11 @@ fi VM="$1" shift -exec /usr/bin/qvm-run --pass-io --localcmd "/usr/lib/qubes/qfile-dom0-agent $@" "$VM" "QUBESRPC qubes.Filecopy dom0" +TMPDIR=`mktemp -d` +trap 'rm -rf -- "$TMPDIR"' EXIT +RESPONSE=$TMPDIR/response +mkfifo -- "$RESPONSE" + +# can't use $@ with --localcmd, and $* would fail on whitespace +/usr/lib/qubes/qfile-dom0-agent "$@" <"$RESPONSE" | +qvm-run --pass-io "$VM" "QUBESRPC qubes.Filecopy dom0" >"$RESPONSE" From 6e4d39c7b3bb2f1c80144d4eea8ff2a375ae1f06 Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Tue, 16 Feb 2016 08:33:54 +0000 Subject: [PATCH 3/3] Use #!/bin/bash and && in qvm-move-to-vm #!/bin/bash because qvm-move-to-vm sources qvm-copy-to-vm, which has a bashism (-o pipefail). && is safer in case qvm-*copy*-to-vm is ever changed to call 'set +e'. --- file-copy-vm/qvm-move-to-vm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/file-copy-vm/qvm-move-to-vm b/file-copy-vm/qvm-move-to-vm index def8380..475530f 100644 --- a/file-copy-vm/qvm-move-to-vm +++ b/file-copy-vm/qvm-move-to-vm @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # The Qubes OS Project, http://www.qubes-os.org # @@ -20,6 +20,5 @@ # # -set -e -. qvm-copy-to-vm "$@" +. qvm-copy-to-vm "$@" && rm -rf -- "$@"