Add qvm-connect-tool to ease creating ad-hoc connections

This commit is contained in:
Frédéric Pierret (fepitre) 2019-08-08 15:12:26 +02:00
parent e27296da3c
commit 3c1381c29b
No known key found for this signature in database
GPG Key ID: 484010B5CDC576E2
4 changed files with 42 additions and 0 deletions

View File

@ -316,6 +316,7 @@ install-common: install-doc
install -m 0755 misc/tinyproxy-wrapper $(DESTDIR)/usr/lib/qubes/tinyproxy-wrapper
install -m 0755 misc/qvm-console $(DESTDIR)$(BINDIR)/qvm-console
install -m 0755 misc/qvm-connect-tcp $(DESTDIR)$(BINDIR)/qvm-connect-tcp
install -d $(DESTDIR)/var/run/qubes
install -d $(DESTDIR)/rw

View File

@ -102,6 +102,7 @@ usr/bin/qvm-move-to-vm
usr/bin/qvm-open-in-dvm
usr/bin/qvm-open-in-vm
usr/bin/qvm-run-vm
usr/bin/qvm-connect-tcp
usr/bin/qvm-console
usr/bin/qvm-sync-clock
usr/bin/xenstore-watch-qubes

39
misc/qvm-connect-tcp Executable file
View File

@ -0,0 +1,39 @@
#!/bin/bash --
set -e
[[ "$DEBUG" == "1" ]] && set -x
LOCALPORT="$(echo "$1" | cut -d ':' -f1)"
DOMAIN="$(echo "$1" | cut -d ':' -f2)"
PORT="$(echo "$1" | cut -d ':' -f3)"
print_usage() {
cat >&2 <<USAGE
Usage: $0 [localport]:[vmname]:[port]
Bind localport to another VM port using the qubes.ConnectTCP RPC service.
USAGE
}
check_port() {
[[ "$1" -ge 1 ]] && [[ "$1" -le 65535 ]]
}
if [ $# -lt 1 ] ; then
print_usage
exit 1
fi
[[ -z "$PORT" ]] && { echo "Please provide PORT"; exit 1; };
[[ -z "$LOCALPORT" ]] && LOCALPORT="$PORT"
if check_port "$PORT" && check_port "$LOCALPORT"; then
if [ -n "$DOMAIN" ]; then
msg="Binding TCP '$DOMAIN:$PORT' to 'localhost:$LOCALPORT'..."
else
msg="Binding TCP '@default:$PORT' to 'localhost:$LOCALPORT'..."
fi
echo "$msg"
sudo socat TCP-LISTEN:"$LOCALPORT",reuseaddr,fork EXEC:"qrexec-client-vm \'$DOMAIN\' qubes.ConnectTCP+$PORT" &
else
echo "Invalid port provided"
exit 1
fi

View File

@ -617,6 +617,7 @@ rm -f %{name}-%{version}
/usr/bin/qubes-open
/usr/bin/qubes-session-autostart
/usr/bin/qvm-console
/usr/bin/qvm-connect-tcp
%dir /usr/lib/qubes
/usr/lib/qubes/prepare-suspend
/usr/lib/qubes/qfile-agent