ca9a496e42
- use `/run` instead of deprecated symlink `/var/run` - add `--autostart` option to automatically start the qube - check for invalid qube name before querying qubesd - use `--fail` option of qubesd-query instead of parsing its output file - add `--` and double quotes in various places - allow `--` to be passed to `qvm-console-dispvm` to mark end of options
23 lines
701 B
Bash
Executable File
23 lines
701 B
Bash
Executable File
#!/bin/bash --
|
|
set -euo pipefail
|
|
|
|
lock="/run/qubes/$QREXEC_REQUESTED_TARGET.terminal.lock"
|
|
|
|
# use temporary file, because env variables deal poorly with \0 inside
|
|
tmpfile=$(mktemp)
|
|
trap 'rm -f -- "$tmpfile"' EXIT
|
|
# exit if qubesd returned an error
|
|
if ! qubesd-query -e --fail -- \
|
|
"$QREXEC_REMOTE_DOMAIN" \
|
|
"admin.vm.Console" \
|
|
"$QREXEC_REQUESTED_TARGET" \
|
|
${1+"$1"} >"$tmpfile"; then
|
|
cat -- "$tmpfile"
|
|
exit 1
|
|
fi
|
|
path=$(tail -c +3 -- "$tmpfile")
|
|
|
|
# Create an exclusive lock to ensure that multiple qubes cannot access to the same socket
|
|
# In the case of multiple qrexec calls it returns a specific exit code
|
|
sudo flock -n -E 200 -x "$lock" socat - OPEN:"$path"
|