Implement dropins for /etc/xdg/autostart (#1151)
Usage of _static_ files (dropins) to override some of autostart entries (enable/disable them in appropriate VM types) is much simpler and less error prone than automatic generators. Handling code is implemented in qubes-session-autostart, which is called from qubes-session. qubesos/qubes-issues#1151
This commit is contained in:
parent
d710970e4d
commit
3d06ce1ee9
2
Makefile
2
Makefile
@ -121,6 +121,7 @@ install-rh: install-systemd install-systemd-dropins install-sysvinit
|
|||||||
install -m 0400 -D network/ip6tables $(DESTDIR)/usr/lib/qubes/init/ip6tables
|
install -m 0400 -D network/ip6tables $(DESTDIR)/usr/lib/qubes/init/ip6tables
|
||||||
|
|
||||||
install-common:
|
install-common:
|
||||||
|
$(MAKE) -C autostart-dropins install
|
||||||
install -m 0644 -D misc/fstab $(DESTDIR)/etc/fstab
|
install -m 0644 -D misc/fstab $(DESTDIR)/etc/fstab
|
||||||
|
|
||||||
install -D -m 0440 misc/qubes.sudoers $(DESTDIR)/etc/sudoers.d/qubes
|
install -D -m 0440 misc/qubes.sudoers $(DESTDIR)/etc/sudoers.d/qubes
|
||||||
@ -171,6 +172,7 @@ install-common:
|
|||||||
install network/qubes-netwatcher $(DESTDIR)/$(SBINDIR)/
|
install network/qubes-netwatcher $(DESTDIR)/$(SBINDIR)/
|
||||||
|
|
||||||
install -d $(DESTDIR)/usr/bin
|
install -d $(DESTDIR)/usr/bin
|
||||||
|
install -m 0755 misc/qubes-session-autostart $(DESTDIR)/usr/bin/qubes-session-autostart
|
||||||
install -m 0755 misc/qubes-desktop-file-install $(DESTDIR)/usr/bin/qubes-desktop-file-install
|
install -m 0755 misc/qubes-desktop-file-install $(DESTDIR)/usr/bin/qubes-desktop-file-install
|
||||||
install -m 0755 misc/qubes-trigger-desktop-file-install $(DESTDIR)$(LIBDIR)/qubes/qubes-trigger-desktop-file-install
|
install -m 0755 misc/qubes-trigger-desktop-file-install $(DESTDIR)$(LIBDIR)/qubes/qubes-trigger-desktop-file-install
|
||||||
|
|
||||||
|
6
autostart-dropins/Makefile
Normal file
6
autostart-dropins/Makefile
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
DROPINS_DIR = /etc/qubes/autostart
|
||||||
|
|
||||||
|
install:
|
||||||
|
for f in *.desktop; do install -m 0644 -D $$f $(DESTDIR)$(DROPINS_DIR)/$$f.d/30_qubes.conf; done
|
||||||
|
install -m 0644 README.txt $(DESTDIR)$(DROPINS_DIR)/
|
20
autostart-dropins/README.txt
Normal file
20
autostart-dropins/README.txt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
This directory (/etc/qubes/autostart) is used to override parts of files in
|
||||||
|
/etc/xdg/autostart. For each desktop file there, you can create directory named
|
||||||
|
after the file plus ".d", then place files there. All such files will be read
|
||||||
|
(in lexicographical order) and lines specified there will override respective
|
||||||
|
entries in the original file. This can be used for example to enable or disable
|
||||||
|
specific application in particular VM type.
|
||||||
|
|
||||||
|
For example, you can extend `/etc/xdg/autostart/gnome-keyring-ssh.desktop` by
|
||||||
|
creating `/etc/qubes/autostart/gnome-keyring-ssh.desktop.d/50_user.conf` with:
|
||||||
|
```
|
||||||
|
[Desktop Entry]
|
||||||
|
OnlyShowIn=X-AppVM;
|
||||||
|
```
|
||||||
|
|
||||||
|
This would mean that `OnlyShowIn` key would be read as `X-AppVM;`, regardless
|
||||||
|
of original entry in `/etc/xdg/autostart/gnome-keyring-ssh.desktop`.
|
||||||
|
|
||||||
|
This mechanism overrides only content of /etc/xdg/autostart, files placed in
|
||||||
|
~/.config/autostart are unaffected, so can be used to override settings per-VM
|
||||||
|
basis.
|
2
autostart-dropins/deja-dup-monitor.desktop
Normal file
2
autostart-dropins/deja-dup-monitor.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
NotShowIn=X-QUBES;
|
2
autostart-dropins/gcm-apply.desktop
Normal file
2
autostart-dropins/gcm-apply.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
NotShowIn=X-DisposableVM;
|
2
autostart-dropins/gnome-keyring-gpg.desktop
Normal file
2
autostart-dropins/gnome-keyring-gpg.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
OnlyShowIn=GNOME;X-AppVM;
|
2
autostart-dropins/gnome-keyring-pkcs11.desktop
Normal file
2
autostart-dropins/gnome-keyring-pkcs11.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
OnlyShowIn=GNOME;X-AppVM;
|
2
autostart-dropins/gnome-keyring-secrets.desktop
Normal file
2
autostart-dropins/gnome-keyring-secrets.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
OnlyShowIn=GNOME;X-AppVM;
|
2
autostart-dropins/gnome-keyring-ssh.desktop
Normal file
2
autostart-dropins/gnome-keyring-ssh.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
OnlyShowIn=GNOME;X-AppVM;
|
2
autostart-dropins/gnome-power-manager.desktop
Normal file
2
autostart-dropins/gnome-power-manager.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
NotShowIn=X-QUBES;
|
2
autostart-dropins/gnome-screensaver.desktop
Normal file
2
autostart-dropins/gnome-screensaver.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
NotShowIn=X-QUBES;
|
2
autostart-dropins/gnome-settings-daemon.desktop
Normal file
2
autostart-dropins/gnome-settings-daemon.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
OnlyShowIn=GNOME;X-AppVM;
|
2
autostart-dropins/gnome-sound-applet.desktop
Normal file
2
autostart-dropins/gnome-sound-applet.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
NotShowIn=X-QUBES;
|
2
autostart-dropins/gpk-update-icon.desktop
Normal file
2
autostart-dropins/gpk-update-icon.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
OnlyShowIn=GNOME;X-UpdateableVM;
|
2
autostart-dropins/gsettings-data-convert.desktop
Normal file
2
autostart-dropins/gsettings-data-convert.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
OnlyShowIn=GNOME;X-AppVM;
|
2
autostart-dropins/imsettings-start.desktop
Normal file
2
autostart-dropins/imsettings-start.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
NotShowIn=X-QUBES;
|
2
autostart-dropins/krb5-auth-dialog.desktop
Normal file
2
autostart-dropins/krb5-auth-dialog.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
NotShowIn=X-QUBES;
|
2
autostart-dropins/nm-applet.desktop
Normal file
2
autostart-dropins/nm-applet.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
OnlyShowIn=GNOME;X-QUBES
|
2
autostart-dropins/notify-osd.desktop
Normal file
2
autostart-dropins/notify-osd.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
NotShowIn=X-QUBES;
|
2
autostart-dropins/orca-autostart.desktop
Normal file
2
autostart-dropins/orca-autostart.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
NotShowIn=X-QUBES;
|
2
autostart-dropins/pulseaudio.desktop
Normal file
2
autostart-dropins/pulseaudio.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
NotShowIn=X-QUBES;
|
2
autostart-dropins/restorecond.desktop
Normal file
2
autostart-dropins/restorecond.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
NotShowIn=X-QUBES;
|
2
autostart-dropins/sealertauto.desktop
Normal file
2
autostart-dropins/sealertauto.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
NotShowIn=X-QUBES;
|
2
autostart-dropins/user-dirs-update-gtk.desktop
Normal file
2
autostart-dropins/user-dirs-update-gtk.desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
OnlyShowIn=GNOME;X-AppVM;
|
84
misc/qubes-session-autostart
Normal file
84
misc/qubes-session-autostart
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# The Qubes OS Project, http://www.qubes-os.org
|
||||||
|
#
|
||||||
|
# Copyright (C) 2015 Marek Marczykowski-Górecki
|
||||||
|
# <marmarek@invisiblethingslab.com>
|
||||||
|
#
|
||||||
|
# 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 subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from xdg.DesktopEntry import DesktopEntry
|
||||||
|
from qubes.xdg import launch
|
||||||
|
import xdg.BaseDirectory
|
||||||
|
import os
|
||||||
|
|
||||||
|
QUBES_XDG_CONFIG_DROPINS = '/etc/qubes/autostart'
|
||||||
|
|
||||||
|
def open_desktop_entry_and_dropins(filename):
|
||||||
|
desktop_entry = DesktopEntry(filename)
|
||||||
|
dropins_dir = os.path.join(QUBES_XDG_CONFIG_DROPINS,
|
||||||
|
os.path.basename(filename) + '.d')
|
||||||
|
if os.path.isdir(dropins_dir):
|
||||||
|
for dropin in sorted(os.listdir(dropins_dir)):
|
||||||
|
dropin_content = DesktopEntry(os.path.join(dropins_dir, dropin))
|
||||||
|
desktop_entry.content.update(dropin_content.content)
|
||||||
|
|
||||||
|
return desktop_entry
|
||||||
|
|
||||||
|
|
||||||
|
def entry_should_be_started(entry, environments):
|
||||||
|
"""
|
||||||
|
|
||||||
|
:type entry: DesktopEntry
|
||||||
|
"""
|
||||||
|
if entry.getHidden():
|
||||||
|
return False
|
||||||
|
if entry.getOnlyShowIn():
|
||||||
|
return bool(set(entry.getOnlyShowIn()).intersection(environments))
|
||||||
|
if entry.getNotShowIn():
|
||||||
|
return not bool(set(entry.getNotShowIn()).intersection(environments))
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def process_autostart(environments):
|
||||||
|
# handle only "most important" entry
|
||||||
|
processed_entries = {}
|
||||||
|
for path in xdg.BaseDirectory.load_config_paths('autostart'):
|
||||||
|
for entry_name in os.listdir(path):
|
||||||
|
if entry_name in processed_entries:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# make the entry as processed, even if not actually started
|
||||||
|
processed_entries[entry_name] = True
|
||||||
|
|
||||||
|
entry_path = os.path.join(path, entry_name)
|
||||||
|
# files in $HOME have higher priority than dropins
|
||||||
|
if not path.startswith(xdg.BaseDirectory.xdg_config_home):
|
||||||
|
entry = open_desktop_entry_and_dropins(entry_path)
|
||||||
|
else:
|
||||||
|
entry = DesktopEntry(entry_path)
|
||||||
|
if entry_should_be_started(entry, environments):
|
||||||
|
launch(entry_path)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
process_autostart(sys.argv[1:])
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
@ -356,6 +356,9 @@ rm -f %{name}-%{version}
|
|||||||
%config(noreplace) /etc/qubes-rpc/qubes.SelectDirectory
|
%config(noreplace) /etc/qubes-rpc/qubes.SelectDirectory
|
||||||
%config(noreplace) /etc/qubes-rpc/qubes.GetImageRGBA
|
%config(noreplace) /etc/qubes-rpc/qubes.GetImageRGBA
|
||||||
%config(noreplace) /etc/qubes-rpc/qubes.SetDateTime
|
%config(noreplace) /etc/qubes-rpc/qubes.SetDateTime
|
||||||
|
%dir /etc/qubes/autostart
|
||||||
|
/etc/qubes/autostart/README.txt
|
||||||
|
%config /etc/qubes/autostart/*.desktop.d/30_qubes.conf
|
||||||
%config(noreplace) /etc/sudoers.d/qubes
|
%config(noreplace) /etc/sudoers.d/qubes
|
||||||
%config(noreplace) /etc/sysconfig/iptables.qubes
|
%config(noreplace) /etc/sysconfig/iptables.qubes
|
||||||
%config(noreplace) /etc/sysconfig/ip6tables.qubes
|
%config(noreplace) /etc/sysconfig/ip6tables.qubes
|
||||||
@ -384,6 +387,7 @@ rm -f %{name}-%{version}
|
|||||||
/usr/bin/qubes-desktop-run
|
/usr/bin/qubes-desktop-run
|
||||||
/usr/bin/qrexec-fork-server
|
/usr/bin/qrexec-fork-server
|
||||||
/usr/bin/qrexec-client-vm
|
/usr/bin/qrexec-client-vm
|
||||||
|
/usr/bin/qubes-session-autostart
|
||||||
/usr/bin/qubes-desktop-file-install
|
/usr/bin/qubes-desktop-file-install
|
||||||
%dir /usr/lib/qubes
|
%dir /usr/lib/qubes
|
||||||
/usr/lib/qubes/vusb-ctl.py*
|
/usr/lib/qubes/vusb-ctl.py*
|
||||||
|
Loading…
Reference in New Issue
Block a user