Skip to content

Commit 6c53bde

Browse files
sunweavervkareh
authored andcommitted
util: Blacklist some session-specific variables
Things like XDG_SESSION_ID should not be uploaded to the environment. For example this is broken currently: 1. SSH to your machine 2. Log in to MATE Shell 3. Log out 4. Log in again 5. Lock the screen 6. Try to unlock You can't, and this is because the XDG_SESSION_ID from the first session (step 2) has leaked through to the second one (step 4), and so MATE Shell is listening to the `logind` `UnlockSession` signal for the wrong session. The SSH session established in step 1 serves to keep the `systemd --user` instance alive, so that the state is not torn down between logins. Also, The NOTIFY_SOCKET environment variable was leaking into systemd managed MATE sessions and breaking things like OCI container runtimes (eg., runc and crun). This variable is absent in non-systemd managed sessions. Backported from: - https://gitlab.gnome.org/GNOME/gnome-session/-/commit/646b9bc0 - https://gitlab.gnome.org/GNOME/gnome-session/-/commit/9d8b0709 Fixes #271
1 parent 8e1cfe1 commit 6c53bde

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

mate-session/gsm-util.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@
3939

4040
static gchar *_saved_session_dir = NULL;
4141

42+
static const char * const variable_blacklist[] = {
43+
"NOTIFY_SOCKET",
44+
"XDG_SEAT",
45+
"XDG_SESSION_ID",
46+
"XDG_VTNR",
47+
NULL
48+
};
49+
4250
gchar **
4351
gsm_get_screen_locker_command (void)
4452
{
@@ -544,6 +552,9 @@ gsm_util_export_activation_environment (GError **error)
544552
const char *entry_name = entry_names[i];
545553
const char *entry_value = g_getenv (entry_name);
546554

555+
if (g_strv_contains (variable_blacklist, entry_name))
556+
continue;
557+
547558
if (!g_utf8_validate (entry_name, -1, NULL))
548559
continue;
549560

@@ -611,8 +622,13 @@ gsm_util_export_user_environment (GError **error)
611622
return FALSE;
612623
}
613624

625+
entries = g_get_environ ();
626+
627+
for (; variable_blacklist[i] != NULL; i++)
628+
entries = g_environ_unsetenv (entries, variable_blacklist[i]);
629+
614630
g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
615-
for (entries = g_get_environ (); entries[i] != NULL; i++) {
631+
for (i = 0; entries[i] != NULL; i++) {
616632
const char *entry = entries[i];
617633

618634
if (!g_utf8_validate (entry, -1, NULL))

0 commit comments

Comments
 (0)