Differential D37679 Diff 114075 sysutils/accountsservice/files/patch-src_libaccountsservice_act-user-manager.c
Changeset View
Changeset View
Standalone View
Standalone View
sysutils/accountsservice/files/patch-src_libaccountsservice_act-user-manager.c
| Obtained from: | --- src/libaccountsservice/act-user-manager.c.orig 2022-01-28 20:47:34 UTC | ||||
| https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/ports/sysutils/accountsservice/patches/patch-src_libaccountsservice_act-user-manager_c | |||||
| $OpenBSD: patch-src_libaccountsservice_act-user-manager_c,v 1.2 2021/08/30 19:15:24 ajacoutot Exp $ | |||||
| REVERT: (breaks listing users in gdm and gnome-cc and unlocking screenshield) | |||||
| From c7fa612023a163e8b2352e1170c6df3fceb19b27 Mon Sep 17 00:00:00 2001 | |||||
| From: Ray Strode <rstrode@redhat.com> | |||||
| Date: Thu, 19 Jul 2018 13:14:09 -0400 | |||||
| Subject: [PATCH] lib: don't set loaded state until seat is fetched | |||||
| Index: src/libaccountsservice/act-user-manager.c | |||||
| --- src/libaccountsservice/act-user-manager.c.orig | |||||
| +++ src/libaccountsservice/act-user-manager.c | +++ src/libaccountsservice/act-user-manager.c | ||||
| @@ -2547,7 +2547,7 @@ maybe_set_is_loaded (ActUserManager *manager) | @@ -40,7 +40,7 @@ | ||||
| #include <glib-object.h> | |||||
| #include <gio/gio.h> | |||||
| #include <gio/gunixinputstream.h> | |||||
| -#include <systemd/sd-login.h> | |||||
| +#include <libconsolekit.h> | |||||
| #include "act-user-manager.h" | |||||
| #include "act-user-private.h" | |||||
| @@ -99,9 +99,6 @@ typedef struct | |||||
| char *id; | |||||
| char *session_id; | |||||
| guint load_idle_id; | |||||
| - sd_login_monitor *session_monitor; | |||||
| - GInputStream *session_monitor_stream; | |||||
| - guint session_monitor_source_id; | |||||
| } ActUserManagerSeat; | |||||
| typedef enum { | |||||
| @@ -158,6 +155,8 @@ typedef struct | |||||
| GDBusConnection *connection; | |||||
| AccountsAccounts *accounts_proxy; | |||||
| + LibConsoleKit *ck; | |||||
| + | |||||
| ActUserManagerSeat seat; | |||||
| GSList *new_sessions; | |||||
| @@ -246,6 +245,71 @@ act_user_manager_error_quark (void) | |||||
| return (GQuark) ret; | |||||
| } | |||||
| +static gint | |||||
| +consolekit_get_sessions (gchar ***sessions) | |||||
| +{ | |||||
| + g_autoptr(GDBusConnection) connection = NULL; | |||||
| + g_autoptr(GVariant) variant = NULL; | |||||
| + g_autoptr(GError) error = NULL; | |||||
| + | |||||
| + connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); | |||||
| + if (connection == NULL) { | |||||
| + g_warning ("Failed to get system bus: %s", error->message); | |||||
| + return -1; | |||||
| + } | |||||
| + | |||||
| + variant = g_dbus_connection_call_sync (connection, | |||||
| + "org.freedesktop.ConsoleKit", | |||||
| + "/org/freedesktop/ConsoleKit/Manager", | |||||
| + "org.freedesktop.ConsoleKit.Manager", | |||||
| + "GetSessions", | |||||
| + NULL, | |||||
| + G_VARIANT_TYPE ("(ao)"), | |||||
| + G_DBUS_CALL_FLAGS_NONE, | |||||
| + -1, NULL, &error); | |||||
| + if (variant == NULL) { | |||||
| + g_warning ("Failed to call GetSessions: %s", | |||||
| + error->message); | |||||
| + return -1; | |||||
| + } | |||||
| + | |||||
| + g_variant_get (variant, "(^ao)", sessions); | |||||
| + return g_strv_length (*sessions); | |||||
| +} | |||||
| + | |||||
| +static gint | |||||
| +consolekit_uid_get_sessions (uid_t uid, | |||||
| + gchar ***sessions) | |||||
| +{ | |||||
| + g_autoptr(GDBusConnection) connection = NULL; | |||||
| + g_autoptr(GVariant) variant = NULL; | |||||
| + g_autoptr(GError) error = NULL; | |||||
| + | |||||
| + connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); | |||||
| + if (connection == NULL) { | |||||
| + g_warning ("Failed to get system bus: %s", error->message); | |||||
| + return -1; | |||||
| + } | |||||
| + | |||||
| + variant = g_dbus_connection_call_sync (connection, | |||||
| + "org.freedesktop.ConsoleKit", | |||||
| + "/org/freedesktop/ConsoleKit/Manager", | |||||
| + "org.freedesktop.ConsoleKit.Manager", | |||||
| + "GetSessionsForUnixUser", | |||||
| + g_variant_new ("(u)", uid), | |||||
| + G_VARIANT_TYPE ("(ao)"), | |||||
| + G_DBUS_CALL_FLAGS_NONE, | |||||
| + -1, NULL, &error); | |||||
| + if (variant == NULL) { | |||||
| + g_warning ("Failed to call GetSessionsForUnixUser: %s", | |||||
| + error->message); | |||||
| + return -1; | |||||
| + } | |||||
| + | |||||
| + g_variant_get (variant, "(^ao)", sessions); | |||||
| + return g_strv_length (*sessions); | |||||
| +} | |||||
| + | |||||
| static gboolean | |||||
| activate_systemd_session_id (ActUserManager *manager, | |||||
| const char *seat_id, | |||||
| @@ -262,13 +326,13 @@ activate_systemd_session_id (ActUserManager *manager, | |||||
| } | |||||
| reply = g_dbus_connection_call_sync (connection, | |||||
| - "org.freedesktop.login1", | |||||
| - "/org/freedesktop/login1", | |||||
| - "org.freedesktop.login1.Manager", | |||||
| + "org.freedesktop.ConsoleKit", | |||||
| + "/org/freedesktop/ConsoleKit/Manager", | |||||
| + "org.freedesktop.ConsoleKit.Manager", | |||||
| "ActivateSessionOnSeat", | |||||
| g_variant_new ("(ss)", | |||||
| - seat_id, | |||||
| - session_id), | |||||
| + session_id, | |||||
| + seat_id), | |||||
| NULL, | |||||
| G_DBUS_CALL_FLAGS_NONE, | |||||
| -1, | |||||
| @@ -286,14 +350,24 @@ static gboolean | |||||
| session_is_login_window (ActUserManager *manager, | |||||
| const char *session_id) | |||||
| { | |||||
| - int res; | |||||
| + ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager); | |||||
| + gboolean res; | |||||
| g_autofree gchar *session_class = NULL; | |||||
| + g_autoptr(GError) error = NULL; | |||||
| - res = sd_session_get_class (session_id, &session_class); | |||||
| - if (res < 0) { | |||||
| - g_debug ("failed to determine class of session %s: %s", | |||||
| - session_id, | |||||
| - strerror (-res)); | |||||
| + g_return_val_if_fail (ACT_IS_USER_MANAGER (manager), FALSE); | |||||
| + | |||||
| + res = lib_consolekit_session_get_class (priv->ck, session_id, | |||||
| + &session_class, &error); | |||||
| + if (!res) { | |||||
| + if (error != NULL) { | |||||
| + g_debug ("failed to determine class of session %s: %s", | |||||
| + session_id, | |||||
| + error->message); | |||||
| + } else { | |||||
| + g_debug ("failed to determine class of session %s", | |||||
| + session_id); | |||||
| + } | |||||
| return FALSE; | |||||
| } | |||||
| @@ -305,17 +379,22 @@ session_is_on_our_seat (ActUserManager *manager, | |||||
| const char *session_id) | |||||
| { | |||||
| ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager); | |||||
| - int res; | |||||
| + gboolean res; | |||||
| g_autofree gchar *session_seat = NULL; | |||||
| + g_autoptr(GError) error = NULL; | |||||
| - res = sd_session_get_seat (session_id, &session_seat); | |||||
| - if (res == -ENODATA) { | |||||
| + res = lib_consolekit_session_get_seat (priv->ck, session_id, | |||||
| + &session_seat, &error); | |||||
| + if (!res) { | |||||
| + if (error != NULL) { | |||||
| + g_debug ("failed to determine seat of session %s: %s", | |||||
| + session_id, | |||||
| + error->message); | |||||
| + } else { | |||||
| + g_debug ("failed to determine seat of session %s", | |||||
| + session_id); | |||||
| + } | |||||
| return FALSE; | |||||
| - } else if (res < 0) { | |||||
| - g_debug ("failed to determine seat of session %s: %s", | |||||
| - session_id, | |||||
| - strerror (-res)); | |||||
| - return FALSE; | |||||
| } | |||||
| return g_strcmp0 (priv->seat.id, session_seat) == 0; | |||||
| @@ -356,12 +435,19 @@ static gboolean | |||||
| _can_activate_systemd_sessions (ActUserManager *manager) | |||||
| { | |||||
| ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager); | |||||
| - int res; | |||||
| + gboolean res; | |||||
| + g_autoptr(GError) error = NULL; | |||||
| - res = sd_seat_can_multi_session (priv->seat.id); | |||||
| - if (res < 0) { | |||||
| - g_warning ("unable to determine if seat %s can activate sessions: %s", | |||||
| - priv->seat.id, strerror (-res)); | |||||
| + res = lib_consolekit_seat_can_multi_session (priv->ck, | |||||
| + priv->seat.id, &error); | |||||
| + if (!res) { | |||||
| + if (error != NULL) { | |||||
| + g_warning ("unable to determine if seat %s can activate sessions: %s", | |||||
| + priv->seat.id, error->message); | |||||
| + } else { | |||||
| + g_warning ("unable to determine if seat %s can activate sessions", | |||||
| + priv->seat.id); | |||||
| + } | |||||
| return FALSE; | |||||
| } | |||||
| @@ -510,17 +596,27 @@ queue_load_seat_incrementally (ActUserManager *manager | |||||
| } | |||||
| static gboolean | |||||
| -_systemd_session_is_graphical (const char *session_id) | |||||
| +_consolekit_session_is_graphical (ActUserManager *manager, | |||||
| + const char *session_id) | |||||
| { | |||||
| + ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager); | |||||
| const gchar * const graphical_session_types[] = { "wayland", "x11", "mir", NULL }; | |||||
| - int saved_errno; | |||||
| + gboolean res; | |||||
| g_autofree gchar *type = NULL; | |||||
| + g_autoptr(GError) error = NULL; | |||||
| - saved_errno = sd_session_get_type (session_id, &type); | |||||
| - if (saved_errno < 0) { | |||||
| - g_warning ("Couldn't get type for session '%s': %s", | |||||
| - session_id, | |||||
| - g_strerror (-saved_errno)); | |||||
| + g_return_val_if_fail (ACT_IS_USER_MANAGER (manager), FALSE); | |||||
| + | |||||
| + res = lib_consolekit_session_get_type (priv->ck, session_id, | |||||
| + &type, &error); | |||||
| + if (!res) { | |||||
| + if (error != NULL) { | |||||
| + g_warning ("Couldn't get type for session '%s': %s", | |||||
| + session_id, error->message); | |||||
| + } else { | |||||
| + g_warning ("Couldn't get type for session '%s'", | |||||
| + session_id); | |||||
| + } | |||||
| return FALSE; | |||||
| } | |||||
| @@ -535,23 +631,33 @@ _systemd_session_is_graphical (const char *session_id) | |||||
| } | |||||
| static gboolean | |||||
| -_systemd_session_is_active (const char *session_id) | |||||
| +_consolekit_session_is_active (ActUserManager *manager, | |||||
| + const char *session_id) | |||||
| { | |||||
| + ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager); | |||||
| const gchar * const active_states[] = { "active", "online", NULL }; | |||||
| - int saved_errno; | |||||
| + gboolean res; | |||||
| g_autofree gchar *state = NULL; | |||||
| + g_autoptr(GError) error = NULL; | |||||
| + g_return_val_if_fail (ACT_IS_USER_MANAGER (manager), FALSE); | |||||
| + | |||||
| /* | |||||
| * display sessions can be 'closing' if they are logged out but some | |||||
| * processes are lingering; we shouldn't consider these (this is | |||||
| * checking for a race condition since we specified that we want online | |||||
| * sessions only) | |||||
| */ | |||||
| - saved_errno = sd_session_get_state (session_id, &state); | |||||
| - if (saved_errno < 0) { | |||||
| - g_warning ("Couldn't get state for session '%s': %s", | |||||
| - session_id, | |||||
| - g_strerror (-saved_errno)); | |||||
| + res = lib_consolekit_session_get_state (priv->ck, session_id, | |||||
| + &state, &error); | |||||
| + if (!res) { | |||||
| + if (error != NULL) { | |||||
| + g_warning ("Couldn't get state for session '%s': %s", | |||||
| + session_id, error->message); | |||||
| + } else { | |||||
| + g_warning ("Couldn't get state for session '%s'", | |||||
| + session_id); | |||||
| + } | |||||
| return FALSE; | |||||
| } | |||||
| @@ -564,23 +670,18 @@ _systemd_session_is_active (const char *session_id) | |||||
| } | |||||
| static gboolean | |||||
| -_find_graphical_systemd_session (char **session_id) | |||||
| +_find_graphical_consolekit_session (ActUserManager *manager, | |||||
| + char **session_id) | |||||
| { | |||||
| char *local_session_id = NULL; | |||||
| g_auto(GStrv) sessions = NULL; | |||||
| int n_sessions; | |||||
| - /* filter level 0 means to include inactive and active sessions | |||||
| - * (>0 would mean to return only the active session, and <0 would mean to | |||||
| - * include closing sessions too) | |||||
| - */ | |||||
| - static int filter_level = 0; | |||||
| - | |||||
| g_return_val_if_fail (session_id != NULL, FALSE); | |||||
| g_debug ("Finding a graphical session for user %d", getuid ()); | |||||
| - n_sessions = sd_uid_get_sessions (getuid (), filter_level, &sessions); | |||||
| + n_sessions = consolekit_uid_get_sessions (getuid (), &sessions); | |||||
| if (n_sessions < 0) { | |||||
| g_critical ("Failed to get sessions for user %d", getuid ()); | |||||
| @@ -590,10 +691,10 @@ _find_graphical_systemd_session (char **session_id) | |||||
| for (int i = 0; i < n_sessions; ++i) { | |||||
| g_debug ("Considering session '%s'", sessions[i]); | |||||
| - if (!_systemd_session_is_graphical (sessions[i])) | |||||
| + if (!_consolekit_session_is_graphical (manager, sessions[i])) | |||||
| continue; | |||||
| - if (!_systemd_session_is_active (sessions[i])) | |||||
| + if (!_consolekit_session_is_active (manager, sessions[i])) | |||||
| continue; | |||||
| /* | |||||
| @@ -615,23 +716,29 @@ static void | |||||
| get_seat_id_for_current_session (ActUserManager *manager) | |||||
| { | |||||
| ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager); | |||||
| - int res; | |||||
| + gboolean res; | |||||
| g_autofree gchar *seat_id = NULL; | |||||
| + g_autoptr(GError) error = NULL; | |||||
| if (priv->seat.session_id == NULL) { | |||||
| - if (!_find_graphical_systemd_session (&priv->seat.session_id)) { | |||||
| + if (!_find_graphical_consolekit_session (manager, | |||||
| + &priv->seat.session_id)) { | |||||
| g_warning ("Could not get session"); | |||||
| return; | |||||
| } | |||||
| } | |||||
| - res = sd_session_get_seat (priv->seat.session_id, &seat_id); | |||||
| + res = lib_consolekit_session_get_seat (priv->ck, | |||||
| + priv->seat.session_id, | |||||
| + &seat_id, &error); | |||||
| - if (res == -ENODATA) { | |||||
| - seat_id = NULL; | |||||
| - } else if (res < 0) { | |||||
| - g_warning ("Could not get current seat: %s", | |||||
| - strerror (-res)); | |||||
| + if (!res) { | |||||
| + if (error != NULL) { | |||||
| + g_warning ("Could not get current seat: %s", | |||||
| + error->message); | |||||
| + } else { | |||||
| + g_warning ("Could not get current seat"); | |||||
| + } | |||||
| unload_seat (manager); | |||||
| return; | |||||
| } | |||||
| @@ -1082,7 +1189,7 @@ get_current_session_id (ActUserManager *manager) | |||||
| ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager); | |||||
| g_autofree gchar *session_id = NULL; | |||||
| - if (!_find_graphical_systemd_session (&session_id)) { | |||||
| + if (!_find_graphical_consolekit_session (manager, &session_id)) { | |||||
| g_debug ("Failed to identify the current session"); | |||||
| unload_seat (manager); | |||||
| return; | |||||
| @@ -1138,15 +1245,27 @@ unload_new_session (ActUserManagerNewSession *new_sess | |||||
| static void | |||||
| get_uid_for_new_session (ActUserManagerNewSession *new_session) | |||||
| { | |||||
| - uid_t uid; | |||||
| - int res; | |||||
| + ActUserManager *manager; | |||||
| + uid_t uid; | |||||
| + gboolean res; | |||||
| + g_autoptr(GError) error = NULL; | |||||
| - res = sd_session_get_uid (new_session->id, &uid); | |||||
| + manager = ACT_USER_MANAGER (new_session->manager); | |||||
| + ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager); | |||||
| - if (res < 0) { | |||||
| - g_debug ("Failed to get uid of session '%s': %s", | |||||
| - new_session->id, | |||||
| - strerror (-res)); | |||||
| + res = lib_consolekit_session_get_uid (priv->ck, | |||||
| + new_session->id, | |||||
| + &uid, &error); | |||||
| + | |||||
| + if (!res) { | |||||
| + if (error != NULL) { | |||||
| + g_debug ("Failed to get uid of session '%s': %s", | |||||
| + new_session->id, | |||||
| + error->message); | |||||
| + } else { | |||||
| + g_debug ("Failed to get uid of session '%s'", | |||||
| + new_session->id); | |||||
| + } | |||||
| unload_new_session (new_session); | |||||
| return; | |||||
| } | |||||
| @@ -1309,16 +1428,26 @@ load_included_usernames (ActUserManager *manager) | |||||
| static void | |||||
| get_x11_display_for_new_session (ActUserManagerNewSession *new_session) | |||||
| { | |||||
| + ActUserManager *manager; | |||||
| g_autofree gchar *session_type = NULL; | |||||
| g_autofree gchar *x11_display = NULL; | |||||
| - int res; | |||||
| + gboolean res; | |||||
| + g_autoptr(GError) error = NULL; | |||||
| - res = sd_session_get_type (new_session->id, | |||||
| - &session_type); | |||||
| - if (res < 0) { | |||||
| - g_debug ("ActUserManager: Failed to get the type of session '%s': %s", | |||||
| - new_session->id, | |||||
| - strerror (-res)); | |||||
| + manager = ACT_USER_MANAGER (new_session->manager); | |||||
| + ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager); | |||||
| + | |||||
| + res = lib_consolekit_session_get_type (priv->ck, | |||||
| + new_session->id, | |||||
| + &session_type, &error); | |||||
| + if (!res) { | |||||
| + if (error != NULL) { | |||||
| + g_debug ("ActUserManager: Failed to get the type of session '%s': %s", | |||||
| + new_session->id, error->message); | |||||
| + } else { | |||||
| + g_debug ("ActUserManager: Failed to get the type of session '%s'", | |||||
| + new_session->id); | |||||
| + } | |||||
| unload_new_session (new_session); | |||||
| return; | |||||
| } | |||||
| @@ -1332,12 +1461,17 @@ get_x11_display_for_new_session (ActUserManagerNewSess | |||||
| goto done; | |||||
| } | |||||
| - res = sd_session_get_display (new_session->id, | |||||
| - &x11_display); | |||||
| - if (res < 0) { | |||||
| - g_debug ("ActUserManager: Failed to get the x11 display of session '%s': %s", | |||||
| - new_session->id, | |||||
| - strerror (-res)); | |||||
| + res = lib_consolekit_session_get_display (priv->ck, | |||||
| + new_session->id, | |||||
| + &x11_display, &error); | |||||
| + if (!res) { | |||||
| + if (error != NULL) { | |||||
| + g_debug ("ActUserManager: Failed to get the x11 display of session '%s': %s", | |||||
| + new_session->id, error->message); | |||||
| + } else { | |||||
| + g_debug ("ActUserManager: Failed to get the x11 display of session '%s'", | |||||
| + new_session->id); | |||||
| + } | |||||
| g_debug ("ActUserManager: Treating X11 display as blank"); | |||||
| x11_display = strdup (""); | |||||
| } else { | |||||
| @@ -1562,12 +1696,15 @@ _remove_stale_systemd_sessions (ActUserManager *manage | |||||
| static void | |||||
| reload_systemd_sessions (ActUserManager *manager) | |||||
| { | |||||
| + ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager); | |||||
| int res; | |||||
| int i; | |||||
| g_auto(GStrv) sessions = NULL; | |||||
| g_autoptr(GHashTable) systemd_sessions = NULL; | |||||
| - res = sd_get_sessions (&sessions); | |||||
| + g_return_if_fail (ACT_IS_USER_MANAGER (manager)); | |||||
| + | |||||
| + res = consolekit_get_sessions (&sessions); | |||||
| if (res < 0) { | |||||
| g_debug ("Failed to determine sessions: %s", strerror (-res)); | |||||
| return; | |||||
| @@ -1581,9 +1718,11 @@ reload_systemd_sessions (ActUserManager *manager) | |||||
| g_autofree gchar *state = NULL; | |||||
| g_autofree gchar *session_class = NULL; | |||||
| - res = sd_session_get_state (sessions[i], &state); | |||||
| - if (res < 0) { | |||||
| - g_debug ("Failed to determine state of session %s: %s", sessions[i], strerror (-res)); | |||||
| + if (!lib_consolekit_session_get_state (priv->ck, | |||||
| + sessions[i], | |||||
| + &state, | |||||
| + NULL)) { | |||||
| + g_debug ("Failed to determine state of session %s", sessions[i]); | |||||
| continue; | |||||
| } | |||||
| @@ -1591,9 +1730,11 @@ reload_systemd_sessions (ActUserManager *manager) | |||||
| continue; | |||||
| } | |||||
| - res = sd_session_get_class (sessions[i], &session_class); | |||||
| - if (res < 0) { | |||||
| - g_debug ("Failed to determine class of session %s: %s", sessions[i], strerror (-res)); | |||||
| + if (!lib_consolekit_session_get_class (priv->ck, | |||||
| + sessions[i], | |||||
| + &session_class, | |||||
| + NULL)) { | |||||
| + g_debug ("Failed to determine class of session %s", sessions[i]); | |||||
| continue; | |||||
| } | |||||
| @@ -1612,45 +1753,18 @@ reload_systemd_sessions (ActUserManager *manager) | |||||
| _remove_stale_systemd_sessions (manager, systemd_sessions); | |||||
| } | |||||
| -static gboolean | |||||
| -on_session_monitor_event (GPollableInputStream *stream, | |||||
| - ActUserManager *manager) | |||||
| -{ | |||||
| - ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager); | |||||
| - sd_login_monitor_flush (priv->seat.session_monitor); | |||||
| - reload_systemd_sessions (manager); | |||||
| - return TRUE; | |||||
| -} | |||||
| - | |||||
| static void | |||||
| _monitor_for_systemd_session_changes (ActUserManager *manager) | |||||
| { | |||||
| ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager); | |||||
| - int res; | |||||
| - int fd; | |||||
| - GSource *source; | |||||
| - res = sd_login_monitor_new ("session", &priv->seat.session_monitor); | |||||
| + priv->ck = lib_consolekit_new (); | |||||
| - if (res < 0) { | |||||
| - g_warning ("Failed to monitor logind session changes: %s", | |||||
| - strerror (-res)); | |||||
| + if (priv->ck == NULL) { | |||||
| + g_warning ("Failed to connect to the ConsoleKit2 daemon"); | |||||
| unload_seat (manager); | |||||
| return; | |||||
| } | |||||
| - | |||||
| - fd = sd_login_monitor_get_fd (priv->seat.session_monitor); | |||||
| - | |||||
| - priv->seat.session_monitor_stream = g_unix_input_stream_new (fd, FALSE); | |||||
| - source = g_pollable_input_stream_create_source (G_POLLABLE_INPUT_STREAM (priv->seat.session_monitor_stream), | |||||
| - NULL); | |||||
| - g_source_set_callback (source, | |||||
| - (GSourceFunc) | |||||
| - on_session_monitor_event, | |||||
| - manager, | |||||
| - NULL); | |||||
| - priv->seat.session_monitor_source_id = g_source_attach (source, NULL); | |||||
| - g_source_unref (source); | |||||
| } | |||||
| static void | |||||
| @@ -2034,7 +2148,7 @@ maybe_set_is_loaded (ActUserManager *manager) | |||||
| /* Don't set is_loaded yet unless the seat is already loaded enough | /* Don't set is_loaded yet unless the seat is already loaded enough | ||||
| * or failed to load. | * or failed to load. | ||||
| */ | */ | ||||
| Context not available. | |||||
| g_debug ("ActUserManager: Seat loaded, so now setting loaded property"); | g_debug ("ActUserManager: Seat loaded, so now setting loaded property"); | ||||
| } else if (priv->seat.state == ACT_USER_MANAGER_SEAT_STATE_UNLOADED) { | } else if (priv->seat.state == ACT_USER_MANAGER_SEAT_STATE_UNLOADED) { | ||||
| g_debug ("ActUserManager: Seat wouldn't load, so giving up on it and setting loaded property"); | g_debug ("ActUserManager: Seat wouldn't load, so giving up on it and setting loaded property"); | ||||
| @@ -2513,16 +2627,8 @@ act_user_manager_finalize (GObject *object) | |||||
| g_source_remove (priv->seat.load_idle_id); | |||||
| } | |||||
| - if (priv->seat.session_monitor != NULL) { | |||||
| - sd_login_monitor_unref (priv->seat.session_monitor); | |||||
| - } | |||||
| - | |||||
| - if (priv->seat.session_monitor_stream != NULL) { | |||||
| - g_object_unref (priv->seat.session_monitor_stream); | |||||
| - } | |||||
| - | |||||
| - if (priv->seat.session_monitor_source_id != 0) { | |||||
| - g_source_remove (priv->seat.session_monitor_source_id); | |||||
| + if (priv->ck != NULL) { | |||||
| + g_object_unref (priv->ck); | |||||
| } | |||||
| if (priv->accounts_proxy != NULL) { | |||||
| Context not available. | |||||