Skip to content

Commit

Permalink
Accept only files for qvm-open-in-(d)vm
Browse files Browse the repository at this point in the history
fixes: QubesOS/qubes-issues#9360
(cherry picked from commit aad2b39)
  • Loading branch information
alimirjamali authored and marmarek committed Aug 23, 2024
1 parent 7548a38 commit 8abb535
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions qubes-rpc/qvm-open-in-vm
Original file line number Diff line number Diff line change
Expand Up @@ -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:*)
Expand Down

0 comments on commit 8abb535

Please sign in to comment.