summaryrefslogtreecommitdiff
path: root/daemon/gdm-manager.c
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2018-08-01 16:34:30 -0400
committerRay Strode <halfline@gmail.com>2018-08-02 20:06:36 +0000
commit0e9f09da4897bdc4069298c8a4d189cd7f217f81 (patch)
tree719634e2d089d95bc0e3f1206b408fe3b753141e /daemon/gdm-manager.c
parent235214328f23422a87da12b1d952bcbc2c174fcc (diff)
downloadgdm-0e9f09da4897bdc4069298c8a4d189cd7f217f81.tar.gz
common: dedupe gdm_get_login_window_session_id
Right now there are two slightly different cut-and-pastes of the function to get the session id of the login session in the code. This commit deduplicates them.
Diffstat (limited to 'daemon/gdm-manager.c')
-rw-r--r--daemon/gdm-manager.c99
1 files changed, 2 insertions, 97 deletions
diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
index 2ec8d652..ac30aee9 100644
--- a/daemon/gdm-manager.c
+++ b/daemon/gdm-manager.c
@@ -1318,108 +1318,13 @@ maybe_start_pending_initial_login (GdmManager *manager,
g_free (user_session_seat_id);
}
-static gboolean
-get_login_window_session_id (const char *seat_id,
- char **session_id)
-{
- gboolean ret;
- int res, i;
- char **sessions;
- char *service_id;
- char *service_class;
- char *state;
-
- res = sd_seat_get_sessions (seat_id, &sessions, NULL, NULL);
- if (res < 0) {
- g_debug ("Failed to determine sessions: %s", strerror (-res));
- return FALSE;
- }
-
- if (sessions == NULL || sessions[0] == NULL) {
- *session_id = NULL;
- ret = FALSE;
- goto out;
- }
-
- for (i = 0; sessions[i]; i ++) {
-
- res = sd_session_get_class (sessions[i], &service_class);
- if (res < 0) {
- if (res == -ENOENT) {
- free (service_class);
- continue;
- }
-
- g_debug ("failed to determine class of session %s: %s", sessions[i], strerror (-res));
- ret = FALSE;
- goto out;
- }
-
- if (strcmp (service_class, "greeter") != 0) {
- free (service_class);
- continue;
- }
-
- free (service_class);
-
- ret = sd_session_get_state (sessions[i], &state);
- if (ret < 0) {
- if (res == -ENOENT)
- continue;
-
- g_debug ("failed to determine state of session %s: %s", sessions[i], strerror (-res));
- ret = FALSE;
- goto out;
- }
-
- if (g_strcmp0 (state, "closing") == 0) {
- free (state);
- continue;
- }
- free (state);
-
- res = sd_session_get_service (sessions[i], &service_id);
- if (res < 0) {
- if (res == -ENOENT)
- continue;
- g_debug ("failed to determine service of session %s: %s", sessions[i], strerror (-res));
- ret = FALSE;
- goto out;
- }
-
- if (strcmp (service_id, "gdm-launch-environment") == 0) {
- *session_id = g_strdup (sessions[i]);
- ret = TRUE;
-
- free (service_id);
- goto out;
- }
-
- free (service_id);
- }
-
- *session_id = NULL;
- ret = FALSE;
-
-out:
- if (sessions) {
- for (i = 0; sessions[i]; i ++) {
- free (sessions[i]);
- }
-
- free (sessions);
- }
-
- return ret;
-}
-
static void
activate_login_window_session_on_seat (GdmManager *self,
const char *seat_id)
{
char *session_id;
- if (!get_login_window_session_id (seat_id, &session_id)) {
+ if (!gdm_get_login_window_session_id (seat_id, &session_id)) {
return;
}
@@ -2059,7 +1964,7 @@ on_session_reauthenticated (GdmSession *session,
char *session_id;
seat_id = gdm_session_get_display_seat_id (session);
- if (get_login_window_session_id (seat_id, &session_id)) {
+ if (gdm_get_login_window_session_id (seat_id, &session_id)) {
GdmDisplay *display = gdm_display_store_find (manager->priv->display_store,
lookup_by_session_id,
(gpointer) session_id);