[gnome-session/benzea/autostart-whitelist: 1/2] fill: Add AutostartWhitelist key to session file
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-session/benzea/autostart-whitelist: 1/2] fill: Add AutostartWhitelist key to session file
- Date: Tue, 7 Apr 2020 14:56:11 +0000 (UTC)
commit 2f3b342133e31b8e30bf10833d1a0732c0477abb
Author: Benjamin Berg <bberg redhat com>
Date: Tue Apr 7 16:27:03 2020 +0200
fill: Add AutostartWhitelist key to session file
gnome-session currently has an autostart directory override. The purpose
of this is to disable the usual autostart applications and only start
whatever is in the given autostart directory.
The nice thing about this is that it is possible (even for third
parties) to extend the autostart list. The bad part is that it is an odd
mechanism of partially disabling autostart. One that cannot be mapped
appropriately to e.g. a systemd generator.
To improve this, add a new AutostartWhitelist key. This key effecitvely
disables autostart (if left empty) and one can add a whitelist of
applications that should still be started (in the login screen, as that
is the only real user).
The disadvantage is that it means distributions need to e.g. add
spice-vdagent uconditionally to this list rather than installing it into
/usr/share/gdm/greeter/autostart. The advantage is that the key can be
appropriately resolved without passing any magic parameters or
environment variables over from GDM to the gnome-session. It also means
that quite a bit of code can be removed from gnome-session.
gnome-session/gsm-manager.c | 11 ++++++++++-
gnome-session/gsm-manager.h | 5 +++--
gnome-session/gsm-session-fill.c | 14 +++++++++++---
3 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/gnome-session/gsm-manager.c b/gnome-session/gsm-manager.c
index 6839a02d..44a0a9d2 100644
--- a/gnome-session/gsm-manager.c
+++ b/gnome-session/gsm-manager.c
@@ -3759,7 +3759,8 @@ gsm_manager_add_required_app (GsmManager *manager,
gboolean
gsm_manager_add_autostart_apps_from_dir (GsmManager *manager,
- const char *path)
+ const char *path,
+ const char * const *whitelist)
{
GDir *dir;
const char *name;
@@ -3776,11 +3777,19 @@ gsm_manager_add_autostart_apps_from_dir (GsmManager *manager,
while ((name = g_dir_read_name (dir))) {
char *desktop_file;
+ g_autofree char *app_id = NULL;
if (!g_str_has_suffix (name, ".desktop")) {
continue;
}
+ if (whitelist) {
+ /* Remove .desktop suffix */
+ app_id = g_strndup (name, strlen(name) - 8);
+ if (!g_strv_contains (whitelist, app_id))
+ continue;
+ }
+
desktop_file = g_build_filename (path, name, NULL);
gsm_manager_add_autostart_app (manager, desktop_file, NULL);
g_free (desktop_file);
diff --git a/gnome-session/gsm-manager.h b/gnome-session/gsm-manager.h
index 3ce4350f..6f8427c2 100644
--- a/gnome-session/gsm-manager.h
+++ b/gnome-session/gsm-manager.h
@@ -109,8 +109,9 @@ gboolean gsm_manager_add_autostart_app (GsmManager *
gboolean gsm_manager_add_required_app (GsmManager *manager,
const char *path,
const char *provides);
-gboolean gsm_manager_add_autostart_apps_from_dir (GsmManager *manager,
- const char *path);
+gboolean gsm_manager_add_autostart_apps_from_dir (GsmManager *manager,
+ const char *path,
+ const char * const *whitelist);
gboolean gsm_manager_add_legacy_session_apps (GsmManager *manager,
const char *path);
diff --git a/gnome-session/gsm-session-fill.c b/gnome-session/gsm-session-fill.c
index bdd92081..7a2622c6 100644
--- a/gnome-session/gsm-session-fill.c
+++ b/gnome-session/gsm-session-fill.c
@@ -30,6 +30,7 @@
#define GSM_KEYFILE_RUNNABLE_KEY "IsRunnableHelper"
#define GSM_KEYFILE_FALLBACK_KEY "FallbackSession"
#define GSM_KEYFILE_REQUIRED_COMPONENTS_KEY "RequiredComponents"
+#define GSM_KEYFILE_AUTOSTART_WHITELIST_KEY "AutostartWhitelist"
/* See https://bugzilla.gnome.org/show_bug.cgi?id=641992 for discussion */
#define GSM_RUNNABLE_HELPER_TIMEOUT 3000 /* ms */
@@ -111,7 +112,7 @@ maybe_load_saved_session_apps (GsmManager *manager)
if (is_login)
return;
- gsm_manager_add_autostart_apps_from_dir (manager, gsm_util_get_saved_session_dir ());
+ gsm_manager_add_autostart_apps_from_dir (manager, gsm_util_get_saved_session_dir (), NULL);
}
static void
@@ -141,17 +142,24 @@ load_standard_apps (GsmManager *manager,
g_debug ("fill: *** Done adding required components");
if (!gsm_manager_get_failsafe (manager)) {
+ g_auto(GStrv) autostart_whitelist = NULL;
char **autostart_dirs;
int i;
autostart_dirs = gsm_util_get_autostart_dirs ();
- if (!gsm_manager_get_systemd_managed (manager))
+ autostart_whitelist = g_key_file_get_string_list (keyfile,
+ GSM_KEYFILE_SESSION_GROUP,
+ GSM_KEYFILE_AUTOSTART_WHITELIST_KEY,
+ NULL, NULL);
+
+ if (!gsm_manager_get_systemd_managed (manager) && !autostart_whitelist)
maybe_load_saved_session_apps (manager);
for (i = 0; autostart_dirs[i]; i++) {
gsm_manager_add_autostart_apps_from_dir (manager,
- autostart_dirs[i]);
+ autostart_dirs[i],
+ (const char * const *)autostart_whitelist);
}
g_strfreev (autostart_dirs);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]