From fe6453978903d6a2a4fc1003b635c44733bbb3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 24 Mar 2014 05:19:16 +0100 Subject: [PATCH] Implement "Move to VM" action (#725) --- Makefile | 6 ++-- qubes-rpc/qvm-move-gnome.desktop | 9 ++++++ qubes-rpc/qvm-move-to-vm | 44 ++++++++++++++++++++++++++++++ qubes-rpc/qvm-move-to-vm.gnome | 37 +++++++++++++++++++++++++ qubes-rpc/qvm-move-to-vm.kde | 47 ++++++++++++++++++++++++++++++++ qubes-rpc/qvm-move.desktop | 10 +++++++ rpm_spec/core-vm.spec | 5 ++++ 7 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 qubes-rpc/qvm-move-gnome.desktop create mode 100755 qubes-rpc/qvm-move-to-vm create mode 100755 qubes-rpc/qvm-move-to-vm.gnome create mode 100755 qubes-rpc/qvm-move-to-vm.kde create mode 100644 qubes-rpc/qvm-move.desktop diff --git a/Makefile b/Makefile index 67c0f95..de3fc63 100644 --- a/Makefile +++ b/Makefile @@ -123,10 +123,12 @@ install-vm: install -d $(DESTDIR)/usr/bin - install qubes-rpc/{qvm-open-in-dvm,qvm-open-in-vm,qvm-copy-to-vm,qvm-run,qvm-mru-entry} $(DESTDIR)/usr/bin + install qubes-rpc/{qvm-open-in-dvm,qvm-open-in-vm,qvm-copy-to-vm,qvm-move-to-vm,qvm-run,qvm-mru-entry} $(DESTDIR)/usr/bin install qubes-rpc/wrap-in-html-if-url.sh $(DESTDIR)/usr/lib/qubes install qubes-rpc/qvm-copy-to-vm.kde $(DESTDIR)/usr/lib/qubes install qubes-rpc/qvm-copy-to-vm.gnome $(DESTDIR)/usr/lib/qubes + install qubes-rpc/qvm-move-to-vm.kde $(DESTDIR)/usr/lib/qubes + install qubes-rpc/qvm-move-to-vm.gnome $(DESTDIR)/usr/lib/qubes install qubes-rpc/{vm-file-editor,qfile-agent,qopen-in-vm} $(DESTDIR)/usr/lib/qubes install qubes-rpc/tar2qfile $(DESTDIR)/usr/lib/qubes # Install qfile-unpacker as SUID - because it will fail to receive files from other vm @@ -135,7 +137,7 @@ install-vm: install qubes-rpc/sync-ntp-clock $(DESTDIR)/usr/lib/qubes install qubes-rpc/prepare-suspend $(DESTDIR)/usr/lib/qubes install -d $(DESTDIR)/$(KDESERVICEDIR) - install -m 0644 qubes-rpc/{qvm-copy.desktop,qvm-dvm.desktop} $(DESTDIR)/$(KDESERVICEDIR) + install -m 0644 qubes-rpc/{qvm-copy.desktop,qvm-move.desktop,qvm-dvm.desktop} $(DESTDIR)/$(KDESERVICEDIR) install -d $(DESTDIR)/etc/qubes-rpc install -m 0644 qubes-rpc/{qubes.Filecopy,qubes.OpenInVM,qubes.VMShell,qubes.SyncNtpClock} $(DESTDIR)/etc/qubes-rpc install -m 0644 qubes-rpc/{qubes.SuspendPre,qubes.SuspendPost,qubes.GetAppmenus} $(DESTDIR)/etc/qubes-rpc diff --git a/qubes-rpc/qvm-move-gnome.desktop b/qubes-rpc/qvm-move-gnome.desktop new file mode 100644 index 0000000..7ae9be7 --- /dev/null +++ b/qubes-rpc/qvm-move-gnome.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=Action +ToolbarLabel[C]=Move to other AppVM +Name[C]=Move to other AppVM +Profiles=profile-zero; + +[X-Action-Profile profile-zero] +Exec=/usr/lib/qubes/qvm-move-to-vm.gnome %F +Name[C]=Default profile diff --git a/qubes-rpc/qvm-move-to-vm b/qubes-rpc/qvm-move-to-vm new file mode 100755 index 0000000..80d456e --- /dev/null +++ b/qubes-rpc/qvm-move-to-vm @@ -0,0 +1,44 @@ +#!/bin/sh +# +# The Qubes OS Project, http://www.qubes-os.org +# +# Copyright (C) 2010 Rafal Wojtczuk +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# + +if [ $# -lt 2 ] ; then + echo usage: $0 '[--without-progress] dest_vmname file [file]+' + exit 1 +fi + +if [ x"$1" = "x--without-progress" ] ; then + export PROGRESS_TYPE=none + shift +else + export PROGRESS_TYPE=console +fi + + +VM="$1" +shift + +if [ $PROGRESS_TYPE = console ] ; then + export FILECOPY_TOTAL_SIZE=$(du --apparent-size -c -- "$@" 2> /dev/null | tail -1 | cut -f 1) +fi +set -e +/usr/lib/qubes/qrexec-client-vm $VM qubes.Filecopy /usr/lib/qubes/qfile-agent "$@" +rm -rf "$@" diff --git a/qubes-rpc/qvm-move-to-vm.gnome b/qubes-rpc/qvm-move-to-vm.gnome new file mode 100755 index 0000000..335194e --- /dev/null +++ b/qubes-rpc/qvm-move-to-vm.gnome @@ -0,0 +1,37 @@ +#!/bin/sh +# +# The Qubes OS Project, http://www.qubes-os.org +# +# Copyright (C) 2010 Rafal Wojtczuk +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# + +VM=$(qvm-mru-entry --title="File Copy" --text="Enter the destination domain name:" --mrufile "qvm-mru-filecopy") +if [ X$VM = X ] ; then exit 0 ; fi + +SIZE=$(du --apparent-size -c -- "$@" 2>/dev/null | tail -1 | cut -f 1) + +export PROGRESS_TYPE=gui + +set -o pipefail +set -e +/usr/lib/qubes/qrexec-client-vm $VM qubes.Filecopy /usr/lib/qubes/qfile-agent "$@" | +(while read sentsize ; do + CURRSIZE=$(($sentsize/1024)) + echo $((100*$CURRSIZE/$SIZE)) +done) | zenity --progress --text="Copying files to domain: $VM..." --auto-close +rm -rf "$@" diff --git a/qubes-rpc/qvm-move-to-vm.kde b/qubes-rpc/qvm-move-to-vm.kde new file mode 100755 index 0000000..0e4ed7b --- /dev/null +++ b/qubes-rpc/qvm-move-to-vm.kde @@ -0,0 +1,47 @@ +#!/bin/sh +# +# The Qubes OS Project, http://www.qubes-os.org +# +# Copyright (C) 2010 Rafal Wojtczuk +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# + +VM=$(kdialog -inputbox "Enter the VM name to send files to:") +if [ X$VM = X ] ; then exit 0 ; fi + +SIZE=$(du --apparent-size -c -- "$@" 2> /dev/null | tail -1 | cut -f 1) +REF=$(kdialog --progressbar "Copy progress") +qdbus $REF org.freedesktop.DBus.Properties.Set "" maximum $SIZE + +export PROGRESS_TYPE=gui + +set -o pipefail +/usr/lib/qubes/qrexec-client-vm $VM qubes.Filecopy \ + /usr/lib/qubes/qfile-agent "$@" | +(while read sentsize ; do + CURRSIZE=$(($sentsize/1024)) + qdbus $REF org.freedesktop.DBus.Properties.Set "" value $CURRSIZE +done) +if [ $? -eq 0 ]; then + rm -rf "$@" +fi + +qdbus $REF close +# we do not want a dozen error messages, do we +# if ! [ "x"$agentstatus = xDONE ] ; then +# kdialog --sorry 'Abnormal file copy termination; see /var/log/qubes/qrexec.xid.log in dom0 for more details' +# fi diff --git a/qubes-rpc/qvm-move.desktop b/qubes-rpc/qvm-move.desktop new file mode 100644 index 0000000..d7ca929 --- /dev/null +++ b/qubes-rpc/qvm-move.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Actions=QvmMove; +Type=Service +X-KDE-ServiceTypes=KonqPopupMenu/Plugin,inode/directory,all/allfiles + +[Desktop Action QvmMove] +Exec=/usr/lib/qubes/qvm-move-to-vm.kde %U +Icon=kget +Name=Move To VM + diff --git a/rpm_spec/core-vm.spec b/rpm_spec/core-vm.spec index d692314..8ad152f 100644 --- a/rpm_spec/core-vm.spec +++ b/rpm_spec/core-vm.spec @@ -283,6 +283,7 @@ rm -f %{name}-%{version} %dir /var/run/qubes %dir %attr(0775,user,user) /var/lib/qubes/dom0-updates %{kde_service_dir}/qvm-copy.desktop +%{kde_service_dir}/qvm-move.desktop %{kde_service_dir}/qvm-dvm.desktop /etc/NetworkManager/dispatcher.d/30-qubes-external-ip /etc/NetworkManager/dispatcher.d/qubes-nmhook @@ -327,6 +328,7 @@ rm -f %{name}-%{version} /etc/yum/post-actions/qubes-trigger-sync-appmenus.action /usr/sbin/qubes-serial-login /usr/bin/qvm-copy-to-vm +/usr/bin/qvm-move-to-vm /usr/bin/qvm-open-in-dvm /usr/bin/qvm-open-in-vm /usr/bin/qvm-run @@ -353,6 +355,8 @@ rm -f %{name}-%{version} /usr/lib/qubes/qubes-trigger-sync-appmenus.sh /usr/lib/qubes/qvm-copy-to-vm.gnome /usr/lib/qubes/qvm-copy-to-vm.kde +/usr/lib/qubes/qvm-move-to-vm.gnome +/usr/lib/qubes/qvm-move-to-vm.kde /usr/lib/qubes/setup-ip /usr/lib/qubes/tar2qfile /usr/lib/qubes/vm-file-editor @@ -364,6 +368,7 @@ rm -f %{name}-%{version} /usr/share/qubes/serial.conf /usr/share/glib-2.0/schemas/org.gnome.settings-daemon.plugins.updates.gschema.override /usr/share/file-manager/actions/qvm-copy-gnome.desktop +/usr/share/file-manager/actions/qvm-move-gnome.desktop /usr/share/file-manager/actions/qvm-dvm-gnome.desktop %dir /usr/share/qubes /usr/share/qubes/mime-override/globs