Commit 4b4312a4 authored by Iain Lane's avatar Iain Lane

Merge branch 'benzea/systemd-fixes' into 'master'

Systemd fixes

Closes #31

See merge request !23
parents 08522478 b7b24627
......@@ -15,5 +15,5 @@ Before=gnome-session-manager.target
[Service]
Type=notify
ExecStart=@libexecdir@/gnome-session-binary --debug --systemd-service --session=%i
ExecStart=@libexecdir@/gnome-session-binary --systemd-service --session=%i
ExecStopPost=-@libexecdir@/gnome-session-ctl --shutdown
......@@ -35,6 +35,12 @@
static gchar *_saved_session_dir = NULL;
static gchar **child_environment;
/* These are variables that will not be passed on to subprocesses
* (either directly, via systemd or DBus).
* Some of these are blacklisted as they might end up in the wrong session
* (e.g. XDG_VTNR), others because they simply must never be passed on
* (NOTIFY_SOCKET).
*/
static const char * const variable_blacklist[] = {
"NOTIFY_SOCKET",
"XDG_SEAT",
......@@ -43,6 +49,24 @@ static const char * const variable_blacklist[] = {
NULL
};
/* The following is copied from GDMs spawn_session function.
*
* Environment variables listed here will be copied into the user's service
* environments if they are set in gnome-session's environment. If they are
* not set in gnome-session's environment, they will be removed from the
* service environments. This is to protect against environment variables
* leaking from previous sessions (e.g. when switching from classic to
* default GNOME $GNOME_SHELL_SESSION_MODE will become unset).
*/
static const char * const variable_unsetlist[] = {
"DISPLAY",
"XAUTHORITY",
"WAYLAND_DISPLAY",
"WAYLAND_SOCKET",
"GNOME_SHELL_SESSION_MODE",
NULL
};
char *
gsm_util_find_desktop_file_for_app_name (const char *name,
gboolean look_in_saved_session,
......@@ -616,10 +640,17 @@ gsm_util_export_user_environment (GError **error)
entries = g_get_environ ();
for (; variable_blacklist[i] != NULL; i++)
for (i = 0; variable_blacklist[i] != NULL; i++)
entries = g_environ_unsetenv (entries, variable_blacklist[i]);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
g_variant_builder_init (&builder, G_VARIANT_TYPE ("(asas)"));
g_variant_builder_open (&builder, G_VARIANT_TYPE ("as"));
for (i = 0; variable_unsetlist[i] != NULL; i++)
g_variant_builder_add (&builder, "s", variable_unsetlist[i]);
g_variant_builder_close (&builder);
g_variant_builder_open (&builder, G_VARIANT_TYPE ("as"));
for (i = 0; entries[i] != NULL; i++) {
const char *entry = entries[i];
......@@ -631,6 +662,7 @@ gsm_util_export_user_environment (GError **error)
g_variant_builder_add (&builder, "s", entry);
}
g_variant_builder_close (&builder);
g_regex_unref (regex);
g_strfreev (entries);
......@@ -639,9 +671,8 @@ gsm_util_export_user_environment (GError **error)
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"SetEnvironment",
g_variant_new ("(@as)",
g_variant_builder_end (&builder)),
"UnsetAndSetEnvironment",
g_variant_builder_end (&builder),
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &bus_error);
......
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