From c600b1b39c22a18e06a27560a80c8b095b5aee68 Mon Sep 17 00:00:00 2001 From: 3hhh Date: Wed, 15 Jan 2020 15:38:28 +0100 Subject: [PATCH] Proper argument escaping for special characters. Fixes side note of QubesOS/qubes-issues#5562 --- dom0-updates/qubes-dom0-update | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dom0-updates/qubes-dom0-update b/dom0-updates/qubes-dom0-update index 1d489b8..3ebeac8 100755 --- a/dom0-updates/qubes-dom0-update +++ b/dom0-updates/qubes-dom0-update @@ -1,13 +1,13 @@ #!/bin/bash -quote_args() { - local quoted_args="" +escape_args() { + local eargs="" - for arg in "${@}"; do - quoted_args="${quoted_args} \"${arg}\"" + for arg in "$@"; do + printf -v eargs '%s%q ' "$eargs" "$arg" done - echo "${quoted_args}" + echo "${eargs%?}" } find_regex_in_args() { @@ -201,7 +201,7 @@ qvm-run --nogui -q $UPDATEVM 'rm -rf /var/lib/qubes/dom0-updates/etc' || exit 1 tar c /var/lib/rpm /etc/yum.repos.d /etc/yum.conf /etc/dnf/dnf.conf 2>/dev/null | \ qvm-run --nogui -q --pass-io "$UPDATEVM" 'LC_MESSAGES=C tar x -C /var/lib/qubes/dom0-updates 2>&1 | grep -v -E "s in the future"' -qvm-run $QVMRUN_OPTS --pass-io $UPDATEVM "script --quiet --return --command '/usr/lib/qubes/qubes-download-dom0-updates.sh --doit --nogui $(quote_args "${ALL_OPTS[@]}")' /dev/null" < /dev/null +qvm-run $QVMRUN_OPTS --pass-io $UPDATEVM "script --quiet --return --command '/usr/lib/qubes/qubes-download-dom0-updates.sh --doit --nogui $(escape_args "${ALL_OPTS[@]}")' /dev/null" < /dev/null RETCODE=$? if [ "$CHECK_ONLY" == "1" ]; then exit $RETCODE