From fac23cfa3e8e9fe21563733c0c1b739ddecead8a Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Thu, 30 Aug 2018 14:01:55 -0400 Subject: [PATCH 24/51] manager: better logind handling commit 9ee68d5c8 highlights we've incorrectly used ENOENT instead of ENXIO when checking for non-existing sessions/seats with logind. This commit mops up all the other cases. --- daemon/gdm-manager.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c index 80f60d24c..367a731cc 100644 --- a/daemon/gdm-manager.c +++ b/daemon/gdm-manager.c @@ -361,113 +361,113 @@ find_session_for_user_on_seat (GdmManager *manager, candidate_username); if (g_strcmp0 (candidate_username, username) == 0 && g_strcmp0 (candidate_seat_id, seat_id) == 0) { g_debug ("GdmManager: yes, found session %s", candidate_session_id); return candidate_session; } g_debug ("GdmManager: no, will not use session %s", candidate_session_id); } g_debug ("GdmManager: no matching sessions found"); return NULL; } static gboolean is_remote_session (GdmManager *self, const char *session_id, GError **error) { char *seat; int ret; gboolean is_remote; /* FIXME: The next release of logind is going to have explicit api for * checking remoteness. */ seat = NULL; ret = sd_session_get_seat (session_id, &seat); - if (ret < 0 && ret != -ENOENT) { + if (ret < 0 && ret != -ENXIO) { g_debug ("GdmManager: Error while retrieving seat for session %s: %s", session_id, strerror (-ret)); } if (seat != NULL) { is_remote = FALSE; free (seat); } else { is_remote = TRUE; } return is_remote; } static char * get_seat_id_for_session_id (const char *session_id, GError **error) { int ret; char *seat, *out_seat; seat = NULL; ret = sd_session_get_seat (session_id, &seat); - if (ret == -ENOENT) { + if (ret == -ENXIO) { out_seat = NULL; } else if (ret < 0) { g_set_error (error, GDM_DISPLAY_ERROR, GDM_DISPLAY_ERROR_GETTING_SESSION_INFO, "Error getting uid for session id %s from systemd: %s", session_id, g_strerror (-ret)); out_seat = NULL; } else { out_seat = g_strdup (seat); free (seat); } return out_seat; } static char * get_tty_for_session_id (const char *session_id, GError **error) { int ret; char *tty, *out_tty; ret = sd_session_get_tty (session_id, &tty); - if (ret == -ENOENT) { + if (ret == -ENXIO) { out_tty = NULL; } else if (ret < 0) { g_set_error (error, GDM_DISPLAY_ERROR, GDM_DISPLAY_ERROR_GETTING_SESSION_INFO, "Error getting tty for session id %s from systemd: %s", session_id, g_strerror (-ret)); out_tty = NULL; } else { out_tty = g_strdup (tty); free (tty); } return out_tty; } static void get_display_and_details_for_bus_sender (GdmManager *self, GDBusConnection *connection, const char *sender, GdmDisplay **out_display, char **out_seat_id, char **out_session_id, char **out_tty, GPid *out_pid, uid_t *out_uid, gboolean *out_is_login_screen, gboolean *out_is_remote) { -- 2.27.0