From 0fd109b8f1e5f3f3dc51080aa18ffa90a32a7757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret?= Date: Fri, 17 Nov 2017 13:37:37 +0100 Subject: [PATCH 1/5] Add support for Thunar Qubes VM tools --- Makefile | 2 ++ misc/uca_qubes.xml | 72 ++++++++++++++++++++++++++++++++++++++++ qubes-rpc/qvm-actions.sh | 51 ++++++++++++++++++++++++++++ rpm_spec/core-agent.spec | 39 ++++++++++++++++++++++ 4 files changed, 164 insertions(+) create mode 100644 misc/uca_qubes.xml create mode 100755 qubes-rpc/qvm-actions.sh diff --git a/Makefile b/Makefile index 5a19bca..22b2891 100644 --- a/Makefile +++ b/Makefile @@ -247,6 +247,8 @@ endif install qubes-rpc/qvm-copy-to-vm.gnome $(DESTDIR)$(LIBDIR)/qubes install qubes-rpc/qvm-move-to-vm.kde $(DESTDIR)$(LIBDIR)/qubes install qubes-rpc/qvm-move-to-vm.gnome $(DESTDIR)$(LIBDIR)/qubes + install qubes-rpc/qvm-actions.sh $(DESTDIR)$(LIBDIR)/qubes + install -m 0644 misc/uca_qubes.xml $(DESTDIR)$(LIBDIR)/qubes install qubes-rpc/xdg-icon $(DESTDIR)$(LIBDIR)/qubes install qubes-rpc/{vm-file-editor,qfile-agent,qopen-in-vm} $(DESTDIR)$(LIBDIR)/qubes install qubes-rpc/qubes-open $(DESTDIR)$(BINDIR) diff --git a/misc/uca_qubes.xml b/misc/uca_qubes.xml new file mode 100644 index 0000000..f158e3c --- /dev/null +++ b/misc/uca_qubes.xml @@ -0,0 +1,72 @@ + + folder-copy + Copy to VM + 1507455450991127-4 + /usr/lib/qubes/qvm-actions.sh copy %F + + * + + + + + + + + + folder-move + Move to VM + 1507455437157027-3 + /usr/lib/qubes/qvm-actions.sh move %F + + * + + + + + + + + + document-open + Open in VM + 1507455471075266-5 + /usr/lib/qubes/qvm-actions.sh openvm %F + + * + + + + + + + + gtk-convert + Convert in DisposableVM + 1507455488971315-6 + /usr/lib/qubes/qvm-actions.sh p %F + + *.pdf + + + + gtk-convert + Convert in DisposableVM + 1507455503129941-7 + /usr/lib/qubes/qvm-actions.sh img %F + + * + + + + document-open + Open in DisposableVM + 1507455559234996-8 + /usr/lib/qubes/qvm-actions.sh opendvm %F + + * + + + + + + diff --git a/qubes-rpc/qvm-actions.sh b/qubes-rpc/qvm-actions.sh new file mode 100755 index 0000000..789dd12 --- /dev/null +++ b/qubes-rpc/qvm-actions.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# Allow us to handle filenames with spaces using newline separator from Thunar +IFS=' +' + +# Check if at least two arguments are provided: actions + file(s) +if [ "$#" -le 1 ]; then + echo "Not enough arguments provided. Aborting..." +fi + +# File(s) +files=${*:2} + +# copy and move handle a list of files where other actions don't +case $1 in + copy) + qvm-copy-to-vm '$default' $files | zenity --notification --text="Copying files..." --timeout 3 + ;; + move) + qvm-move-to-vm '$default' $files | zenity --notification --text="Moving files..." --timeout 3 + ;; + img) + for file in $files + do + /usr/lib/qubes/qvm-convert-img.gnome $file + done + ;; + pdf) + for file in $files + do + /usr/lib/qubes/qvm-convert-pdf.gnome $file + done + ;; + openvm) + for file in $files + do + qvm-open-in-vm '$default' $file | zenity --notification --text "Opening $file in VM..." --timeout 3 & + done + ;; + opendvm) + for file in $files + do + qvm-open-in-dvm $files | zenity --notification --text "Opening $file in DisposableVM..." --timeout 3 & + done + ;; + *) + echo "Unknown action. Aborting..." + exit 1 + ;; +esac diff --git a/rpm_spec/core-agent.spec b/rpm_spec/core-agent.spec index 76251e2..978e4f2 100644 --- a/rpm_spec/core-agent.spec +++ b/rpm_spec/core-agent.spec @@ -268,6 +268,13 @@ switching from user to root. Since all the user data in a VM is accessible already from normal user account, there is not much more to guard there. Qubes VM is a single user system. +%package thunar +Summary: Thunar support for Qubes VM tools +Requires: Thunar + +%description thunar +Thunar support for Qubes VM tools + %define _builddir %(pwd) %define kde_service_dir /usr/share/kde4/services @@ -463,6 +470,22 @@ sed 's/^net.ipv4.ip_forward.*/#\0/' -i /etc/sysctl.conf %post qrexec %systemd_post qubes-qrexec-agent.service +%post thunar +# There is no system-wide Thunar custom actions. There is only a default +# file and a user file created from the default one. Qubes actions need +# to be placed after all already defined actions and before +# the end of file. +if [ "$1" = 1 ]; then + if [ -f /etc/xdg/Thunar/uca.xml ] ; then + cp -p /etc/xdg/Thunar/uca.xml{,.bak} + sed -i '$e cat /usr/lib/qubes/uca_qubes.xml' /etc/xdg/Thunar/uca.xml + fi + if [ -f /home/user/.config/Thunar/uca.xml ] ; then + cp -p /home/user/.config/Thunar/uca.xml{,.bak} + sed -i '$e cat /usr/lib/qubes/uca_qubes.xml' /home/user/.config/Thunar/uca.xml + fi +fi + %preun if [ "$1" = 0 ] ; then # no more packages left @@ -484,6 +507,18 @@ fi %preun qrexec %systemd_preun qubes-qrexec-agent.service +%postun thunar +if [ "$1" = 0 ]; then + if [ -f /etc/xdg/Thunar/uca.xml ] ; then + mv /etc/xdg/Thunar/uca.xml{,.uninstall} + mv /etc/xdg/Thunar/uca.xml{.bak,} + fi + if [ -f /home/user/.config/Thunar/uca.xml ] ; then + mv /home/user/.config/Thunar/uca.xml{,.uninstall} + mv /home/user/.config/Thunar/uca.xml{.bak,} + fi +fi + %postun if [ $1 -eq 0 ] ; then /usr/bin/glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || : @@ -674,6 +709,10 @@ rm -f %{name}-%{version} /usr/share/nautilus-python/extensions/qvm_move_nautilus.py* /usr/share/nautilus-python/extensions/qvm_dvm_nautilus.py* +%files thunar +/usr/lib/qubes/qvm-actions.sh +/usr/lib/qubes/uca_qubes.xml + %files dom0-updates %dir %attr(0775,user,user) /var/lib/qubes/dom0-updates /usr/lib/qubes/qubes-download-dom0-updates.sh From 82656bb5dfb9f75bc145aadf5314d73b424dab58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret?= Date: Fri, 17 Nov 2017 18:47:39 +0100 Subject: [PATCH 2/5] Disable Thunar thumbnails --- Makefile | 2 ++ misc/thunar.xml | 5 +++++ rpm_spec/core-agent.spec | 9 +++++---- 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 misc/thunar.xml diff --git a/Makefile b/Makefile index 22b2891..6113427 100644 --- a/Makefile +++ b/Makefile @@ -249,6 +249,8 @@ endif install qubes-rpc/qvm-move-to-vm.gnome $(DESTDIR)$(LIBDIR)/qubes install qubes-rpc/qvm-actions.sh $(DESTDIR)$(LIBDIR)/qubes install -m 0644 misc/uca_qubes.xml $(DESTDIR)$(LIBDIR)/qubes + mkdir -p $(DESTDIR)/etc/xdg/xfce4/xfconf/xfce-perchannel-xml + install -m 0644 misc/thunar.xml $(DESTDIR)/etc/xdg/xfce4/xfconf/xfce-perchannel-xml install qubes-rpc/xdg-icon $(DESTDIR)$(LIBDIR)/qubes install qubes-rpc/{vm-file-editor,qfile-agent,qopen-in-vm} $(DESTDIR)$(LIBDIR)/qubes install qubes-rpc/qubes-open $(DESTDIR)$(BINDIR) diff --git a/misc/thunar.xml b/misc/thunar.xml new file mode 100644 index 0000000..71bfd6c --- /dev/null +++ b/misc/thunar.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/rpm_spec/core-agent.spec b/rpm_spec/core-agent.spec index 978e4f2..ca2065a 100644 --- a/rpm_spec/core-agent.spec +++ b/rpm_spec/core-agent.spec @@ -471,11 +471,11 @@ sed 's/^net.ipv4.ip_forward.*/#\0/' -i /etc/sysctl.conf %systemd_post qubes-qrexec-agent.service %post thunar -# There is no system-wide Thunar custom actions. There is only a default -# file and a user file created from the default one. Qubes actions need -# to be placed after all already defined actions and before -# the end of file. if [ "$1" = 1 ]; then + # There is no system-wide Thunar custom actions. There is only a default + # file and a user file created from the default one. Qubes actions need + # to be placed after all already defined actions and before + # the end of file. if [ -f /etc/xdg/Thunar/uca.xml ] ; then cp -p /etc/xdg/Thunar/uca.xml{,.bak} sed -i '$e cat /usr/lib/qubes/uca_qubes.xml' /etc/xdg/Thunar/uca.xml @@ -712,6 +712,7 @@ rm -f %{name}-%{version} %files thunar /usr/lib/qubes/qvm-actions.sh /usr/lib/qubes/uca_qubes.xml +/etc/xdg/xfce4/xfconf/xfce-perchannel-xml/thunar.xml %files dom0-updates %dir %attr(0775,user,user) /var/lib/qubes/dom0-updates From 3dc294f3bb756b06f1026731fd77e1633010425f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret?= Date: Wed, 22 Nov 2017 13:06:51 +0100 Subject: [PATCH 3/5] Add debian package support --- debian/control | 10 +++++ debian/qubes-core-agent-thunar.install | 3 ++ debian/qubes-core-agent-thunar.postinst | 56 ++++++++++++++++++++++++ debian/qubes-core-agent-thunar.postrm | 57 +++++++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 debian/qubes-core-agent-thunar.install create mode 100755 debian/qubes-core-agent-thunar.postinst create mode 100755 debian/qubes-core-agent-thunar.postrm diff --git a/debian/control b/debian/control index 3ec505a..aa58554 100644 --- a/debian/control +++ b/debian/control @@ -97,6 +97,16 @@ Breaks: qubes-core-agent (<< 4.0.0-1) Description: Qubes integration for Nautilus Nautilus addons for inter-VM file copy/move/open. +Package: qubes-core-agent-thunar +Architecture: any +Depends: + thunar, + qubes-core-agent-qrexec, +Replaces: qubes-core-agent (<< 4.0.0-1) +Breaks: qubes-core-agent (<< 4.0.0-1) +Description: Qubes integration for Thunar + Thunar addons for inter-VM file copy/move/open. + Package: qubes-core-agent-dom0-updates Architecture: any Depends: diff --git a/debian/qubes-core-agent-thunar.install b/debian/qubes-core-agent-thunar.install new file mode 100644 index 0000000..388f13b --- /dev/null +++ b/debian/qubes-core-agent-thunar.install @@ -0,0 +1,3 @@ +usr/lib/qubes/qvm-actions.sh +usr/lib/qubes/uca_qubes.xml +etc/xdg/xfce4/xfconf/xfce-perchannel-xml/thunar.xml diff --git a/debian/qubes-core-agent-thunar.postinst b/debian/qubes-core-agent-thunar.postinst new file mode 100755 index 0000000..2751d1a --- /dev/null +++ b/debian/qubes-core-agent-thunar.postinst @@ -0,0 +1,56 @@ +#!/bin/bash +# postinst script for core-agent-linux +# +# see: dh_installdeb(1) + +set -e + +# The postinst script may be called in the following ways: +# * 'configure' +# * 'abort-upgrade' +# * 'abort-remove' 'in-favour' +# +# * 'abort-remove' +# * 'abort-deconfigure' 'in-favour' +# 'removing' +# +# +# For details, see http://www.debian.org/doc/debian-policy/ or +# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html or +# the debian-policy package + + +case "${1}" in + configure) + # There is no system-wide Thunar custom actions. There is only a default + # file and a user file created from the default one. Qubes actions need + # to be placed after all already defined actions and before + # the end of file. + if [ -f /etc/xdg/Thunar/uca.xml ] ; then + cp -p /etc/xdg/Thunar/uca.xml{,.bak} + sed -i '$e cat /usr/lib/qubes/uca_qubes.xml' /etc/xdg/Thunar/uca.xml + fi + if [ -f /home/user/.config/Thunar/uca.xml ] ; then + cp -p /home/user/.config/Thunar/uca.xml{,.bak} + sed -i '$e cat /usr/lib/qubes/uca_qubes.xml' /home/user/.config/Thunar/uca.xml + fi + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + exit 0 + ;; + + *) + echo "postinst called with unknown argument \`${1}'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + +# vim: set ts=4 sw=4 sts=4 et : diff --git a/debian/qubes-core-agent-thunar.postrm b/debian/qubes-core-agent-thunar.postrm new file mode 100755 index 0000000..d19a93a --- /dev/null +++ b/debian/qubes-core-agent-thunar.postrm @@ -0,0 +1,57 @@ +#!/bin/sh +# postrm script for core-agent-linux +# +# see: dh_installdeb(1) + +set -e + +# The prerm script may be called in the following ways: +# * 'remove' +# * 'purge' +# * 'upgrade' +# * 'disappear' +# +# The postrm script is called after the package's files have been removed +# or replaced. The package whose postrm is being called may have previously been +# deconfigured and only be "Unpacked", at which point subsequent package changes +# do not consider its dependencies. Therefore, all postrm actions may only rely +# on essential packages and must gracefully skip any actions that require the +# package's dependencies if those dependencies are unavailable.[48] +# +# * 'failed-upgrade' +# +# Called when the old postrm upgrade action fails. The new package will be +# unpacked, but only essential packages and pre-dependencies can be relied on. +# Pre-dependencies will either be configured or will be "Unpacked" or +# "Half-Configured" but previously had been configured and was never removed. +# +# * 'abort-install' +# * 'abort-install' +# * 'abort-upgrade' +# +# Called before unpacking the new package as part of the error handling of +# preinst failures. May assume the same state as preinst can assume. +# +# For details, see http://www.debian.org/doc/debian-policy/ or +# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html or +# the debian-policy package + +if [ "${1}" = "remove" ] ; then + if [ -f /etc/xdg/Thunar/uca.xml ] ; then + mv /etc/xdg/Thunar/uca.xml{,.uninstall} + mv /etc/xdg/Thunar/uca.xml{.bak,} + fi + if [ -f /home/user/.config/Thunar/uca.xml ] ; then + mv /home/user/.config/Thunar/uca.xml{,.uninstall} + mv /home/user/.config/Thunar/uca.xml{.bak,} + fi +fi + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + +# vim: set ts=4 sw=4 sts=4 et : From 6226531bd54d6d87fcaf83abeabb33d06f97bb8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret?= Date: Wed, 22 Nov 2017 13:31:33 +0100 Subject: [PATCH 4/5] Fix ShellCheck comments --- debian/qubes-core-agent-thunar.postinst | 6 ++++-- debian/qubes-core-agent-thunar.postrm | 8 ++++---- qubes-rpc/qvm-actions.sh | 15 +++++++++------ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/debian/qubes-core-agent-thunar.postinst b/debian/qubes-core-agent-thunar.postinst index 2751d1a..b4e829d 100755 --- a/debian/qubes-core-agent-thunar.postinst +++ b/debian/qubes-core-agent-thunar.postinst @@ -27,11 +27,13 @@ case "${1}" in # to be placed after all already defined actions and before # the end of file. if [ -f /etc/xdg/Thunar/uca.xml ] ; then - cp -p /etc/xdg/Thunar/uca.xml{,.bak} + cp -p /etc/xdg/Thunar/uca.xml /etc/xdg/Thunar/uca.xml.bak + #shellcheck disable=SC2016 sed -i '$e cat /usr/lib/qubes/uca_qubes.xml' /etc/xdg/Thunar/uca.xml fi if [ -f /home/user/.config/Thunar/uca.xml ] ; then - cp -p /home/user/.config/Thunar/uca.xml{,.bak} + cp -p /home/user/.config/Thunar/uca.xml /home/user/.config/Thunar/uca.xml.bak + #shellcheck disable=SC2016 sed -i '$e cat /usr/lib/qubes/uca_qubes.xml' /home/user/.config/Thunar/uca.xml fi ;; diff --git a/debian/qubes-core-agent-thunar.postrm b/debian/qubes-core-agent-thunar.postrm index d19a93a..afcd82c 100755 --- a/debian/qubes-core-agent-thunar.postrm +++ b/debian/qubes-core-agent-thunar.postrm @@ -38,12 +38,12 @@ set -e if [ "${1}" = "remove" ] ; then if [ -f /etc/xdg/Thunar/uca.xml ] ; then - mv /etc/xdg/Thunar/uca.xml{,.uninstall} - mv /etc/xdg/Thunar/uca.xml{.bak,} + mv /etc/xdg/Thunar/uca.xml /etc/xdg/Thunar/uca.xml.uninstall + mv /etc/xdg/Thunar/uca.xml.bak /etc/xdg/Thunar/uca.xml fi if [ -f /home/user/.config/Thunar/uca.xml ] ; then - mv /home/user/.config/Thunar/uca.xml{,.uninstall} - mv /home/user/.config/Thunar/uca.xml{.bak,} + mv /home/user/.config/Thunar/uca.xml /home/user/.config/Thunar/uca.xml.uninstall + mv /home/user/.config/Thunar/uca.xml.bak /home/user/.config/Thunar/uca.xml fi fi diff --git a/qubes-rpc/qvm-actions.sh b/qubes-rpc/qvm-actions.sh index 789dd12..7d76231 100755 --- a/qubes-rpc/qvm-actions.sh +++ b/qubes-rpc/qvm-actions.sh @@ -15,33 +15,36 @@ files=${*:2} # copy and move handle a list of files where other actions don't case $1 in copy) - qvm-copy-to-vm '$default' $files | zenity --notification --text="Copying files..." --timeout 3 + #shellcheck disable=SC2016 + qvm-copy-to-vm '$default' "$files" | zenity --notification --text="Copying files..." --timeout 3 ;; move) - qvm-move-to-vm '$default' $files | zenity --notification --text="Moving files..." --timeout 3 + #shellcheck disable=SC2016 + qvm-move-to-vm '$default' "$files" | zenity --notification --text="Moving files..." --timeout 3 ;; img) for file in $files do - /usr/lib/qubes/qvm-convert-img.gnome $file + /usr/lib/qubes/qvm-convert-img.gnome "$file" done ;; pdf) for file in $files do - /usr/lib/qubes/qvm-convert-pdf.gnome $file + /usr/lib/qubes/qvm-convert-pdf.gnome "$file" done ;; openvm) for file in $files do - qvm-open-in-vm '$default' $file | zenity --notification --text "Opening $file in VM..." --timeout 3 & + #shellcheck disable=SC2016 + qvm-open-in-vm '$default' "$file" | zenity --notification --text "Opening $file in VM..." --timeout 3 & done ;; opendvm) for file in $files do - qvm-open-in-dvm $files | zenity --notification --text "Opening $file in DisposableVM..." --timeout 3 & + qvm-open-in-dvm "$files" | zenity --notification --text "Opening $file in DisposableVM..." --timeout 3 & done ;; *) From c34a0a9e074da62c47490892b0784b554f7333fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret?= Date: Sun, 10 Dec 2017 11:19:34 +0100 Subject: [PATCH 5/5] Fix UCA mistake and qvm-actions script --- misc/uca_qubes.xml | 2 +- qubes-rpc/qvm-actions.sh | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/misc/uca_qubes.xml b/misc/uca_qubes.xml index f158e3c..2e4ad8d 100644 --- a/misc/uca_qubes.xml +++ b/misc/uca_qubes.xml @@ -43,7 +43,7 @@ gtk-convert Convert in DisposableVM 1507455488971315-6 - /usr/lib/qubes/qvm-actions.sh p %F + /usr/lib/qubes/qvm-actions.sh pdf %F *.pdf diff --git a/qubes-rpc/qvm-actions.sh b/qubes-rpc/qvm-actions.sh index 7d76231..691b3f2 100755 --- a/qubes-rpc/qvm-actions.sh +++ b/qubes-rpc/qvm-actions.sh @@ -1,50 +1,48 @@ #!/bin/bash -# Allow us to handle filenames with spaces using newline separator from Thunar -IFS=' -' - # Check if at least two arguments are provided: actions + file(s) if [ "$#" -le 1 ]; then echo "Not enough arguments provided. Aborting..." fi -# File(s) -files=${*:2} +# Action +action="$1" + +shift # copy and move handle a list of files where other actions don't -case $1 in +case "$action" in copy) #shellcheck disable=SC2016 - qvm-copy-to-vm '$default' "$files" | zenity --notification --text="Copying files..." --timeout 3 + qvm-copy-to-vm '$default' "$@" | zenity --notification --text="Copying files..." --timeout 3 ;; move) #shellcheck disable=SC2016 - qvm-move-to-vm '$default' "$files" | zenity --notification --text="Moving files..." --timeout 3 + qvm-move-to-vm '$default' "$@" | zenity --notification --text="Moving files..." --timeout 3 ;; img) - for file in $files + for file in "$@" do /usr/lib/qubes/qvm-convert-img.gnome "$file" done ;; pdf) - for file in $files + for file in "$@" do /usr/lib/qubes/qvm-convert-pdf.gnome "$file" done ;; openvm) - for file in $files + for file in "$@" do #shellcheck disable=SC2016 qvm-open-in-vm '$default' "$file" | zenity --notification --text "Opening $file in VM..." --timeout 3 & done ;; opendvm) - for file in $files + for file in "$@" do - qvm-open-in-dvm "$files" | zenity --notification --text "Opening $file in DisposableVM..." --timeout 3 & + qvm-open-in-dvm "$file" | zenity --notification --text "Opening $file in DisposableVM..." --timeout 3 & done ;; *)