Skip to content

Commit

Permalink
A wrapper for starting a process conditionally on qvm-service
Browse files Browse the repository at this point in the history
Add a generic wrapper that starts a given process only if specific
qvm-service is enabled. This can be used in desktop files for example
(in Exec= line). Note that systemd units have this functionality built
in (ConditionExists=).

QubesOS/qubes-issues#8161
  • Loading branch information
marmarek committed May 7, 2023
1 parent dcfc936 commit 5cf9c87
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions debian/qubes-core-agent.install
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ 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/qvm-service-wrapper
usr/lib/qubes/resize-rootfs
usr/lib/qubes/tar2qfile
usr/lib/qubes/update-proxy-configs
Expand Down
4 changes: 4 additions & 0 deletions misc/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
BINDIR ?= /usr/bin
DATADIR ?= /usr/share
SYSLIBDIR ?= /lib
LIBDIR ?= /usr/lib
QUBESLIBDIR := $(LIBDIR)/qubes
UDEVRULESDIR := $(SYSLIBDIR)/udev/rules.d
QUBESDATADIR := $(DATADIR)/qubes
QUBESMIMEDIR := $(QUBESDATADIR)/xdg-override
Expand Down Expand Up @@ -39,6 +41,8 @@ install:
umask 022 && cp -r applications mime '$(DESTDIR)$(QUBESMIMEDIR)'
install -m 0755 -d $(DESTDIR)$(BINDIR)
install -m 0755 -t $(DESTDIR)$(BINDIR) qvm-features-request
install -m 0755 -d $(DESTDIR)$(QUBESLIBDIR)
install -m 0755 -t $(DESTDIR)$(QUBESLIBDIR) qvm-service-wrapper

marker-vm: marker-vm.in
printf "$(VERSION)" | cut -f 1,2 -d . | cat $< - > marker-vm
12 changes: 12 additions & 0 deletions misc/qvm-service-wrapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

# Start an application given as $2 only if qvm-service $1 is enabled

service="$1"
shift
if ! [ -r "/run/qubes-service/$service" ]; then
echo "Not starting '$1', qvm-service '$service' is not enabled" >&2
exit 0
fi

exec "$@"
1 change: 1 addition & 0 deletions rpm_spec/core-agent.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,7 @@ rm -f %{name}-%{version}
/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/qvm-service-wrapper
/usr/lib/qubes/tar2qfile
/usr/lib/qubes/vm-file-editor
/usr/lib/qubes/xdg-icon
Expand Down

0 comments on commit 5cf9c87

Please sign in to comment.