From aad2b39b1a1025a889568f0b3aa3052d3799e2ae Mon Sep 17 00:00:00 2001 From: Ali Mirjamali Date: Thu, 18 Jul 2024 23:31:51 +0330 Subject: [PATCH] Accept only files for qvm-open-in-(d)vm fixes: https://github.com/QubesOS/qubes-issues/issues/9360 --- qubes-rpc/qvm-open-in-vm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/qubes-rpc/qvm-open-in-vm b/qubes-rpc/qvm-open-in-vm index ea677ed3..a5349ac9 100755 --- a/qubes-rpc/qvm-open-in-vm +++ b/qubes-rpc/qvm-open-in-vm @@ -64,6 +64,18 @@ if [ -z "$target" ] || [ -z "$filename" ]; then usage fi +if [ -d "$filename" ]; then + printf 'Error! "%s" is a directory.\n' "$filename" + usage +elif [ ! -f "$filename" ]; then + expr "@$filename" : '@[A-Za-z][A-Za-z0-9+]*://'>/dev/null + # shellcheck disable=SC2181 + if [ $? -ne 0 ]; then + printf 'Error! "%s" is not a valid file or URL.\n' "$filename" + usage + fi +fi + prompt_text='Are you sure you want to create another disposable VM?' case $target in (@dispvm|@dispvm:*)