From 1c09a2c77eb83029a284719dfd197ddabd9dacc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret=20=28fepitre=29?= Date: Tue, 7 May 2019 13:54:29 +0200 Subject: [PATCH] Rename and fix from Marek's comments --- Makefile | 6 ++--- ...erminal.policy => admin.vm.Console.policy} | 2 +- .../{admin.vm.Terminal => admin.vm.Console} | 0 qvm-tools/qvm-console-dispvm | 22 +++++++++++++++++++ qvm-tools/qvm-terminal-dispvm | 18 --------------- 5 files changed, 26 insertions(+), 22 deletions(-) rename qubes-rpc-policy/{admin.vm.Terminal.policy => admin.vm.Console.policy} (85%) rename qubes-rpc/{admin.vm.Terminal => admin.vm.Console} (100%) create mode 100755 qvm-tools/qvm-console-dispvm delete mode 100755 qvm-tools/qvm-terminal-dispvm diff --git a/Makefile b/Makefile index 7ff89ae0..f13167bb 100644 --- a/Makefile +++ b/Makefile @@ -184,7 +184,7 @@ endif cp qubes-rpc-policy/qubes.VMShell.policy $(DESTDIR)/etc/qubes-rpc/policy/qubes.VMShell cp qubes-rpc-policy/qubes.UpdatesProxy.policy $(DESTDIR)/etc/qubes-rpc/policy/qubes.UpdatesProxy cp qubes-rpc-policy/qubes.GetDate.policy $(DESTDIR)/etc/qubes-rpc/policy/qubes.GetDate - cp qubes-rpc-policy/admin.vm.Terminal.policy $(DESTDIR)/etc/qubes-rpc/policy/admin.vm.Terminal + cp qubes-rpc-policy/admin.vm.Console.policy $(DESTDIR)/etc/qubes-rpc/policy/admin.vm.Console cp qubes-rpc-policy/policy.RegisterArgument.policy $(DESTDIR)/etc/qubes-rpc/policy/policy.RegisterArgument cp qubes-rpc/qubes.FeaturesRequest $(DESTDIR)/etc/qubes-rpc/ cp qubes-rpc/qubes.GetDate $(DESTDIR)/etc/qubes-rpc/ @@ -196,13 +196,13 @@ endif install -m 0755 qvm-tools/qubes-bug-report $(DESTDIR)/usr/bin/qubes-bug-report install -m 0755 qvm-tools/qubes-hcl-report $(DESTDIR)/usr/bin/qubes-hcl-report install -m 0755 qvm-tools/qvm-sync-clock $(DESTDIR)/usr/bin/qvm-sync-clock - install -m 0755 qvm-tools/qvm-terminal-dispvm $(DESTDIR)/usr/bin/qvm-terminal-dispvm + install -m 0755 qvm-tools/qvm-console-dispvm $(DESTDIR)/usr/bin/qvm-console-dispvm for method in $(ADMIN_API_METHODS_SIMPLE); do \ ln -s ../../usr/libexec/qubes/qubesd-query-fast \ $(DESTDIR)/etc/qubes-rpc/$$method || exit 1; \ done install qubes-rpc/admin.vm.volume.Import $(DESTDIR)/etc/qubes-rpc/ - install qubes-rpc/admin.vm.Terminal $(DESTDIR)/etc/qubes-rpc/ + install qubes-rpc/admin.vm.Console $(DESTDIR)/etc/qubes-rpc/ PYTHONPATH=.:test-packages qubes-rpc-policy/generate-admin-policy \ --destdir=$(DESTDIR)/etc/qubes-rpc/policy \ --exclude admin.vm.Create.AdminVM \ diff --git a/qubes-rpc-policy/admin.vm.Terminal.policy b/qubes-rpc-policy/admin.vm.Console.policy similarity index 85% rename from qubes-rpc-policy/admin.vm.Terminal.policy rename to qubes-rpc-policy/admin.vm.Console.policy index a7092332..6ad595bd 100644 --- a/qubes-rpc-policy/admin.vm.Terminal.policy +++ b/qubes-rpc-policy/admin.vm.Console.policy @@ -3,7 +3,7 @@ ## Please use a single # to start your custom comments -# WARNING: The qubes.ShowTerminal service is dangerous and allows any +# WARNING: The admin.vm.Console service is dangerous and allows any # qube to access any other qube console. It should be restricted # only to management/admin qubes. This is why the default policy is 'deny' diff --git a/qubes-rpc/admin.vm.Terminal b/qubes-rpc/admin.vm.Console similarity index 100% rename from qubes-rpc/admin.vm.Terminal rename to qubes-rpc/admin.vm.Console diff --git a/qvm-tools/qvm-console-dispvm b/qvm-tools/qvm-console-dispvm new file mode 100755 index 00000000..61c5bb10 --- /dev/null +++ b/qvm-tools/qvm-console-dispvm @@ -0,0 +1,22 @@ +#!/bin/bash +print_usage() { +cat >&2 << USAGE +Usage: $0 vmname +Connects to VM console throught DispVM using the qubes.ShowInTerminal RPC service. +USAGE +} + +if [ $# -lt 1 ]; then + print_usage + exit 1 +fi + +QREXEC_REQUESTED_TARGET="$1" + +qvm-check --quiet --running "$QREXEC_REQUESTED_TARGET" > /dev/null 2>&1 || { echo "Error: domain '$QREXEC_REQUESTED_TARGET' does not exist or is not running"; exit 1; } + +DISPVM="$(qvm-prefs "$QREXEC_REQUESTED_TARGET" management_dispvm)" + +[[ "x$DISPVM" == "x" ]] && { echo "Error: cannot determine default DispVM to use"; exit 1; } + +sudo qvm-run -p --localcmd="QREXEC_REQUESTED_TARGET=$QREXEC_REQUESTED_TARGET /etc/qubes-rpc/admin.vm.Console" --service --dispvm="$DISPVM" -- qubes.ShowInTerminal diff --git a/qvm-tools/qvm-terminal-dispvm b/qvm-tools/qvm-terminal-dispvm deleted file mode 100755 index ec69324a..00000000 --- a/qvm-tools/qvm-terminal-dispvm +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -print_usage() { -cat >&2 << USAGE -Usage: $0 vmname -Connects to VM console throught DispVM using the admin.vm.TerminalDispVM RPC service. -USAGE -} - -if [ $# -lt 1 ]; then - print_usage - exit 1 -fi - -QREXEC_REQUESTED_TARGET="$1" - -qvm-check --quiet "$QREXEC_REQUESTED_TARGET" > /dev/null 2>&1 || { echo "Error: no such domain: '$QREXEC_REQUESTED_TARGET'"; exit 1; } - -sudo qvm-run -p --localcmd="QREXEC_REQUESTED_TARGET=$QREXEC_REQUESTED_TARGET /etc/qubes-rpc/admin.vm.Terminal" --service --dispvm="$(qubes-prefs management_dispvm)" -- admin.vm.TerminalDispVM