From 89183e9944f72f1a048156af5854402bad0cb79a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 20 May 2017 15:53:03 +0200 Subject: [PATCH] Ask for target VM for file-copy in dom0 This way: - VM prompt do know VM list, the list may be filtered based on policy - source VM don't learn name of target VM Fixes QubesOS/qubes-issues#910 --- Makefile | 2 +- archlinux/PKGBUILD | 2 +- debian/control | 1 - qubes-rpc/qvm-copy-to-vm.gnome | 7 +- qubes-rpc/qvm-copy-to-vm.kde | 5 +- qubes-rpc/qvm-move-to-vm.gnome | 7 +- qubes-rpc/qvm-mru-entry | 165 --------------------------------- rpm_spec/core-vm.spec | 2 - 8 files changed, 7 insertions(+), 184 deletions(-) delete mode 100755 qubes-rpc/qvm-mru-entry diff --git a/Makefile b/Makefile index 2715bcc..974be12 100644 --- a/Makefile +++ b/Makefile @@ -235,7 +235,7 @@ install-common: install -d $(DESTDIR)$(BINDIR) install -m 0755 misc/qubes-session-autostart $(DESTDIR)$(BINDIR)/qubes-session-autostart install -m 0755 misc/qvm-features-request $(DESTDIR)$(BINDIR)/qvm-features-request - 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-run} $(DESTDIR)/usr/bin ln -s qvm-copy-to-vm $(DESTDIR)/usr/bin/qvm-move-to-vm install qubes-rpc/qvm-copy-to-vm.kde $(DESTDIR)$(LIBDIR)/qubes install qubes-rpc/qvm-copy-to-vm.gnome $(DESTDIR)$(LIBDIR)/qubes diff --git a/archlinux/PKGBUILD b/archlinux/PKGBUILD index 9061a79..a239ff8 100644 --- a/archlinux/PKGBUILD +++ b/archlinux/PKGBUILD @@ -13,7 +13,7 @@ arch=("x86_64") url="http://qubes-os.org/" license=('GPL') groups=() -depends=("qubes-vm-utils>=3.1.3" python2 python3 python2-xdg ethtool ntp net-tools gnome-packagekit imagemagick fakeroot notification-daemon dconf pygtk zenity qubes-libvchan "qubes-db-vm>=3.2.1" haveged python2-gobject python2-dbus xdg-utils notification-daemon gawk sed procps-ng librsvg) +depends=("qubes-vm-utils>=3.1.3" python2 python3 python2-xdg ethtool ntp net-tools gnome-packagekit imagemagick fakeroot notification-daemon dconf zenity qubes-libvchan "qubes-db-vm>=3.2.1" haveged python2-gobject python2-dbus xdg-utils notification-daemon gawk sed procps-ng librsvg) makedepends=(gcc make pkg-config "qubes-vm-utils>=3.1.3" qubes-libvchan qubes-db-vm qubes-vm-xen libx11 python2 python3 lsb-release) checkdepends=() optdepends=(gnome-keyring gnome-settings-daemon networkmanager iptables tinyproxy python2-nautilus gpk-update-viewer) diff --git a/debian/control b/debian/control index 2e99614..bca2d97 100644 --- a/debian/control +++ b/debian/control @@ -45,7 +45,6 @@ Depends: python-gi, python-xdg, python-dbus, - python-gtk2, qubes-utils (>= 3.1.3), sudo, systemd, diff --git a/qubes-rpc/qvm-copy-to-vm.gnome b/qubes-rpc/qvm-copy-to-vm.gnome index 4b69c06..f8fcd8f 100755 --- a/qubes-rpc/qvm-copy-to-vm.gnome +++ b/qubes-rpc/qvm-copy-to-vm.gnome @@ -20,15 +20,12 @@ # # -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 -/usr/lib/qubes/qrexec-client-vm $VM qubes.Filecopy /usr/lib/qubes/qfile-agent "$@" | +/usr/lib/qubes/qrexec-client-vm '$default' 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 +done) | zenity --progress --text="Copying files..." --auto-close diff --git a/qubes-rpc/qvm-copy-to-vm.kde b/qubes-rpc/qvm-copy-to-vm.kde index d986a99..a87433b 100755 --- a/qubes-rpc/qvm-copy-to-vm.kde +++ b/qubes-rpc/qvm-copy-to-vm.kde @@ -20,16 +20,13 @@ # # if type kdialog 2> /dev/null; then - 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 - /usr/lib/qubes/qrexec-client-vm $VM qubes.Filecopy \ + /usr/lib/qubes/qrexec-client-vm '$default' qubes.Filecopy \ /usr/lib/qubes/qfile-agent "$@" | (while read sentsize ; do CURRSIZE=$(($sentsize/1024)) diff --git a/qubes-rpc/qvm-move-to-vm.gnome b/qubes-rpc/qvm-move-to-vm.gnome index 7c9341c..0750994 100755 --- a/qubes-rpc/qvm-move-to-vm.gnome +++ b/qubes-rpc/qvm-move-to-vm.gnome @@ -20,18 +20,15 @@ # # -VM=$(qvm-mru-entry --title="File Move" --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 "$@" | +/usr/lib/qubes/qrexec-client-vm '$default' qubes.Filecopy /usr/lib/qubes/qfile-agent "$@" | (while read sentsize ; do CURRSIZE=$(($sentsize/1024)) echo $((100*$CURRSIZE/$SIZE)) -done) | zenity --progress --text="Moving files to domain: $VM..." --auto-close +done) | zenity --progress --text="Moving files..." --auto-close rm -rf "$@" diff --git a/qubes-rpc/qvm-mru-entry b/qubes-rpc/qvm-mru-entry deleted file mode 100755 index 5fb4f2f..0000000 --- a/qubes-rpc/qvm-mru-entry +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/bin/python -# -# The Qubes OS Project, http://www.qubes-os.org -# -# Copyright (C) 2012 Bruce Downs -# -# 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. -# -# -import os -from optparse import OptionParser -import gtk - -class QubesMruDialog(gtk.Dialog): - entry = None - mrufile = None - - def __init__(self, title, text, mrufile): - self.mrufile = mrufile - - gtk.Dialog.__init__( - self, - title, - None, - 0, - (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, - gtk.STOCK_OK, gtk.RESPONSE_OK)) - - # setting the default response to 'ok' - # does not work as advertised - # using key-press-event instead - #self.set_default_response(gtk.RESPONSE_OK) - - self.connect("destroy", lambda *w: gtk.main_quit()) - self.connect("response", self.response_callback) - self.connect("key-press-event", self.key_press_callback) - - self.set_position(gtk.WIN_POS_CENTER) - self.set_resizable(True) - - vbox = gtk.VBox(True, 5) - self.vbox.pack_start(vbox, True, True, 0) - vbox.set_border_width(5) - - label = gtk.Label() - label.set_markup(text) - vbox.pack_start(label, False, False, 0) - - # Create our entry - self.entry = gtk.Entry() - vbox.pack_start(self.entry, False, False, 0) - - # Create the completion object - completion = gtk.EntryCompletion() - - # Assign the completion to the entry - self.entry.set_completion(completion) - - # Create a tree model and use it as the completion model - completion_model, firstline = self.create_completion_model() - completion.set_model(completion_model) - - # Use model column 0 as the text column - completion.set_text_column(0) - - if firstline: - self.entry.set_text(firstline) - - self.show_all() - - def create_completion_model(self): - store = gtk.ListStore(str) - firstline = None - - if self.mrufile and os.access(self.mrufile, os.R_OK): - # read lines from mru file - lines = [line.strip() for line in open(self.mrufile)] - for line in lines: - if not firstline: - firstline = line - - iter = store.append() - store.set(iter, 0, line) - - return store, firstline - - def handle_ok(self): - my_entry = self.entry.get_text() - - if len(my_entry) > 0: - linesorg = [] - linesorg.insert(0, my_entry) - - # calc mru lines - if os.access(self.mrufile, os.R_OK): - # read lines from existing mru file - fMru = open(self.mrufile, "r") - linesorg += [line.strip() for line in fMru] - fMru.close() - - #uniqify - linesuniq = [] - for lineuniq in linesorg: - if (len(lineuniq) > 0 and lineuniq not in linesuniq): - linesuniq.append(lineuniq) - - # write to mru - # up to 50 unique - fMru = file(self.mrufile, "w") - fMru.writelines( "%s\n" % line for line in linesuniq[:50] ) - fMru.close() - - # print entry to stdout - print my_entry - - def response_callback(self, button, response_id): - if response_id == gtk.RESPONSE_OK: - self.handle_ok() - self.destroy() - - def key_press_callback(self, button, event): - if event.keyval == gtk.keysyms.Return: - self.handle_ok() - self.destroy() - -def main(): - usage = "usage: %prog [--title 'Qubes Title'] [--text 'Qubes Text'] [--mrufile 'mru file name']" - parser = OptionParser (usage) - parser.add_option ("-l", "--title", - action="store", - dest="title", - default="Qubes MRU Dialog Entry", - help="Set the dialog title [%default]") - parser.add_option ("-x", "--text", - action="store", - dest="text", - default="Enter Qubes text:", - help="Set the dialog text [%default]") - parser.add_option ("-f", "--mrufile", - action="store", - dest="mrufile", - default='qvm-mru', - help="MRU file name [%default]") - (options, args) = parser.parse_args () - - mrudir = os.path.expanduser('~') + os.sep + '.config' - if not os.path.exists(mrudir): - os.makedirs(mrudir) - QubesMruDialog(options.title, options.text, mrudir + os.sep + options.mrufile) - gtk.main() - -main() - diff --git a/rpm_spec/core-vm.spec b/rpm_spec/core-vm.spec index 3456131..5549767 100644 --- a/rpm_spec/core-vm.spec +++ b/rpm_spec/core-vm.spec @@ -147,7 +147,6 @@ Requires: fakeroot Requires: desktop-notification-daemon # to show/hide nm-applet Requires: dconf -Requires: pygtk2 Requires: zenity Requires: qubes-libvchan Requires: qubes-db-vm @@ -469,7 +468,6 @@ rm -f %{name}-%{version} /usr/bin/qvm-open-in-dvm /usr/bin/qvm-open-in-vm /usr/bin/qvm-run -/usr/bin/qvm-mru-entry /usr/bin/qvm-features-request /usr/bin/xenstore-watch-qubes /usr/bin/qubes-desktop-run