From 7301a898a14ff6a8d4890a3de4af3683f9dee286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 15 Mar 2016 23:33:11 +0100 Subject: [PATCH] qubes.SuspendPreAll and qubes.SuspendPostAll services Those services are called just before/after host suspend. Thanks @adrelanos for help. Fixes QubesOS/qubes-issues#1663 --- Makefile | 7 +++++++ qubes-rpc/qubes.SuspendPostAll | 28 ++++++++++++++++++++++++++++ qubes-rpc/qubes.SuspendPreAll | 28 ++++++++++++++++++++++++++++ qubes-rpc/suspend-post.README | 2 ++ qubes-rpc/suspend-pre.README | 2 ++ rpm_spec/core-vm.spec | 6 ++++++ 6 files changed, 73 insertions(+) create mode 100755 qubes-rpc/qubes.SuspendPostAll create mode 100755 qubes-rpc/qubes.SuspendPreAll create mode 100644 qubes-rpc/suspend-post.README create mode 100644 qubes-rpc/suspend-pre.README diff --git a/Makefile b/Makefile index 2799f23..dd41dac 100644 --- a/Makefile +++ b/Makefile @@ -223,6 +223,8 @@ install-common: 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 + install -m 0755 qubes-rpc/qubes.SuspendPreAll $(DESTDIR)/etc/qubes-rpc + install -m 0755 qubes-rpc/qubes.SuspendPostAll $(DESTDIR)/etc/qubes-rpc install -m 0644 qubes-rpc/qubes.WaitForSession $(DESTDIR)/etc/qubes-rpc install -m 0644 qubes-rpc/qubes.DetachPciDevice $(DESTDIR)/etc/qubes-rpc install -m 0644 qubes-rpc/qubes.{Backup,Restore} $(DESTDIR)/etc/qubes-rpc @@ -231,6 +233,11 @@ install-common: install -m 0644 qubes-rpc/qubes.SetDateTime $(DESTDIR)/etc/qubes-rpc install -m 0755 qubes-rpc/qubes.InstallUpdatesGUI $(DESTDIR)/etc/qubes-rpc + install -d $(DESTDIR)/etc/qubes/suspend-pre.d + install -m 0644 qubes-rpc/suspend-pre.README $(DESTDIR)/etc/qubes/suspend-pre.d/README + install -d $(DESTDIR)/etc/qubes/suspend-post.d + install -m 0644 qubes-rpc/suspend-post.README $(DESTDIR)/etc/qubes/suspend-post.d/README + install -d $(DESTDIR)/usr/share/nautilus-python/extensions install -m 0644 qubes-rpc/*_nautilus.py $(DESTDIR)/usr/share/nautilus-python/extensions diff --git a/qubes-rpc/qubes.SuspendPostAll b/qubes-rpc/qubes.SuspendPostAll new file mode 100755 index 0000000..da92dda --- /dev/null +++ b/qubes-rpc/qubes.SuspendPostAll @@ -0,0 +1,28 @@ +#!/bin/sh +# +# The Qubes OS Project, http://www.qubes-os.org +# +# Copyright (C) 2016 Marek Marczykowski-Górecki +# +# +# 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. +# +# + +for script in /etc/qubes/suspend-post.d/*.sh; do + if [ -x "$script" ]; then + "$script" + fi +done diff --git a/qubes-rpc/qubes.SuspendPreAll b/qubes-rpc/qubes.SuspendPreAll new file mode 100755 index 0000000..7f132c0 --- /dev/null +++ b/qubes-rpc/qubes.SuspendPreAll @@ -0,0 +1,28 @@ +#!/bin/sh +# +# The Qubes OS Project, http://www.qubes-os.org +# +# Copyright (C) 2016 Marek Marczykowski-Górecki +# +# +# 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. +# +# + +for script in /etc/qubes/suspend-pre.d/*.sh; do + if [ -x "$script" ]; then + "$script" + fi +done diff --git a/qubes-rpc/suspend-post.README b/qubes-rpc/suspend-post.README new file mode 100644 index 0000000..a9278f8 --- /dev/null +++ b/qubes-rpc/suspend-post.README @@ -0,0 +1,2 @@ +All executable files with `.sh` suffix in this directory will be executed as +root just after host resume from suspend. diff --git a/qubes-rpc/suspend-pre.README b/qubes-rpc/suspend-pre.README new file mode 100644 index 0000000..f59b912 --- /dev/null +++ b/qubes-rpc/suspend-pre.README @@ -0,0 +1,2 @@ +All executable files with `.sh` suffix in this directory will be executed as +root just before host suspend. diff --git a/rpm_spec/core-vm.spec b/rpm_spec/core-vm.spec index 0372676..f000554 100644 --- a/rpm_spec/core-vm.spec +++ b/rpm_spec/core-vm.spec @@ -337,7 +337,9 @@ rm -f %{name}-%{version} %config(noreplace) /etc/qubes-rpc/qubes.VMShell %config(noreplace) /etc/qubes-rpc/qubes.SyncNtpClock %config(noreplace) /etc/qubes-rpc/qubes.SuspendPre +%config(noreplace) /etc/qubes-rpc/qubes.SuspendPreAll %config(noreplace) /etc/qubes-rpc/qubes.SuspendPost +%config(noreplace) /etc/qubes-rpc/qubes.SuspendPostAll %config(noreplace) /etc/qubes-rpc/qubes.WaitForSession %config(noreplace) /etc/qubes-rpc/qubes.DetachPciDevice %config(noreplace) /etc/qubes-rpc/qubes.Backup @@ -350,6 +352,10 @@ rm -f %{name}-%{version} %dir /etc/qubes/autostart /etc/qubes/autostart/README.txt %config /etc/qubes/autostart/*.desktop.d/30_qubes.conf +%dir /etc/qubes/suspend-pre.d +/etc/qubes/suspend-pre.d/README +%dir /etc/qubes/suspend-post.d +/etc/qubes/suspend-post.d/README %config(noreplace) /etc/sudoers.d/qubes %config(noreplace) /etc/sudoers.d/qt_x11_no_mitshm %config(noreplace) /etc/sysctl.d/20_tcp_timestamps.conf