Commit 58e4af5c authored by Benjamin Berg's avatar Benjamin Berg Committed by Sebastian Geiger

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.
parent 3b043831
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment