From e5d9a0fec869adbe610c46114afaede04f8c89e2 Mon Sep 17 00:00:00 2001 From: Alessandro Bono Date: Mon, 19 Aug 2024 18:08:42 +0200 Subject: [PATCH] loginDialog: Don't assume this._user is always defined There are cases where this._user might be null when a session is opened. This is because the user is not selected via GDM but it is set through PAM. This happens when logging with smart card or with credential managers, for example. Given the session-id of the opened session, look for the owner. This fixes the following error: ``` gnome-shell[153293]: TypeError: this._user is null Stack trace: _findConflictingSession@resource:///org/gnome/shell/gdm/loginDialog.js:1219:26 _onSessionOpened@resource:///org/gnome/shell/gdm/loginDialog.js:1254:51 @resource:///org/gnome/shell/ui/init.js:21:20 ``` Fixes: df84854d9 ("loginDialog: On login, allow logout a conflicting session") Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7526 Part-of: --- js/gdm/loginDialog.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js index 9e1c050f8..e82313d9e 100644 --- a/js/gdm/loginDialog.js +++ b/js/gdm/loginDialog.js @@ -1137,15 +1137,15 @@ export const LoginDialog = GObject.registerClass({ }); } - async _findConflictingSession(ignoreSessionId) { - const userName = this._user.get_user_name(); + async _findConflictingSession(startingSessionId) { const loginManager = LoginManager.getLoginManager(); const sessions = await loginManager.listSessions(); + const [, , startingSessionOwner, ,] = sessions.find(([id, , , ,]) => id === startingSessionId); for (const session of sessions.map(([id, , user, , path]) => ({id, user, path}))) { - if (ignoreSessionId === session.id) + if (startingSessionId === session.id) continue; - if (userName !== session.user) + if (startingSessionOwner !== session.user) continue; const sessionProxy = loginManager.getSession(session.path);