Skip to content

Commit

Permalink
Add qvm-connect-tool to ease creating ad-hoc connections
Browse files Browse the repository at this point in the history
(cherry picked from commit 3c1381c)
  • Loading branch information
fepitre authored and marmarek committed Sep 7, 2019
1 parent 5364885 commit 9493388
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,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
Expand Down
1 change: 1 addition & 0 deletions debian/qubes-core-agent.install
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions misc/qvm-connect-tcp
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions rpm_spec/core-agent.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,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
Expand Down

0 comments on commit 9493388

Please sign in to comment.