153 lines
6 KiB
Text
153 lines
6 KiB
Text
|
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
|
||
|
@@ -40,7 +40,11 @@
|
||
|
#include <glib-object.h>
|
||
|
#include <gio/gio.h>
|
||
|
#include <gio/gunixinputstream.h>
|
||
|
+#ifdef __linux__
|
||
|
#include <systemd/sd-login.h>
|
||
|
+#else
|
||
|
+#include <ConsoleKit/sd-login.h>
|
||
|
+#endif
|
||
|
|
||
|
#include "act-user-manager.h"
|
||
|
#include "act-user-private.h"
|
||
|
@@ -100,9 +104,11 @@ typedef struct
|
||
|
char *id;
|
||
|
char *session_id;
|
||
|
guint load_idle_id;
|
||
|
+#ifdef __linux__
|
||
|
sd_login_monitor *session_monitor;
|
||
|
GInputStream *session_monitor_stream;
|
||
|
guint session_monitor_source_id;
|
||
|
+#endif
|
||
|
} ActUserManagerSeat;
|
||
|
|
||
|
typedef enum
|
||
|
@@ -274,6 +280,7 @@ activate_systemd_session_id (ActUserManager *manager,
|
||
|
return FALSE;
|
||
|
}
|
||
|
|
||
|
+#ifdef __linux__
|
||
|
reply = g_dbus_connection_call_sync (connection,
|
||
|
"org.freedesktop.login1",
|
||
|
"/org/freedesktop/login1",
|
||
|
@@ -287,6 +294,21 @@ activate_systemd_session_id (ActUserManager *manager,
|
||
|
-1,
|
||
|
NULL,
|
||
|
&error);
|
||
|
+#else
|
||
|
+ reply = g_dbus_connection_call_sync (connection,
|
||
|
+ "org.freedesktop.ConsoleKit",
|
||
|
+ "/org/freedesktop/ConsoleKit/Manager",
|
||
|
+ "org.freedesktop.ConsoleKit.Manager",
|
||
|
+ "ActivateSessionOnSeat",
|
||
|
+ g_variant_new ("(ss)",
|
||
|
+ seat_id,
|
||
|
+ session_id),
|
||
|
+ NULL,
|
||
|
+ G_DBUS_CALL_FLAGS_NONE,
|
||
|
+ -1,
|
||
|
+ NULL,
|
||
|
+ &error);
|
||
|
+#endif
|
||
|
if (reply == NULL) {
|
||
|
g_warning ("Unable to activate session: %s", error->message);
|
||
|
return FALSE;
|
||
|
@@ -322,9 +344,7 @@ session_is_on_our_seat (ActUserManager *manager,
|
||
|
g_autofree gchar *session_seat = NULL;
|
||
|
|
||
|
res = sd_session_get_seat (session_id, &session_seat);
|
||
|
- if (res == -ENODATA) {
|
||
|
- return FALSE;
|
||
|
- } else if (res < 0) {
|
||
|
+ if (res < 0) {
|
||
|
g_debug ("failed to determine seat of session %s: %s",
|
||
|
session_id,
|
||
|
strerror (-res));
|
||
|
@@ -641,9 +661,7 @@ get_seat_id_for_current_session (ActUserManager *manag
|
||
|
|
||
|
res = sd_session_get_seat (priv->seat.session_id, &seat_id);
|
||
|
|
||
|
- if (res == -ENODATA) {
|
||
|
- seat_id = NULL;
|
||
|
- } else if (res < 0) {
|
||
|
+ if (res < 0) {
|
||
|
g_warning ("Could not get current seat: %s",
|
||
|
strerror (-res));
|
||
|
unload_seat (manager);
|
||
|
@@ -1391,8 +1409,12 @@ get_x11_display_for_new_session (ActUserManagerNewSess
|
||
|
goto done;
|
||
|
}
|
||
|
|
||
|
+#ifndef __OpenBSD__
|
||
|
res = sd_session_get_display (new_session->id,
|
||
|
&x11_display);
|
||
|
+#else
|
||
|
+ res = -1;
|
||
|
+#endif
|
||
|
if (res < 0) {
|
||
|
g_debug ("ActUserManager: Failed to get the x11 display of session '%s': %s",
|
||
|
new_session->id,
|
||
|
@@ -1671,6 +1693,7 @@ reload_systemd_sessions (ActUserManager *manager)
|
||
|
_remove_stale_systemd_sessions (manager, systemd_sessions);
|
||
|
}
|
||
|
|
||
|
+#ifdef __linux__
|
||
|
static gboolean
|
||
|
on_session_monitor_event (GPollableInputStream *stream,
|
||
|
ActUserManager *manager)
|
||
|
@@ -1681,10 +1704,12 @@ on_session_monitor_event (GPollableInputStream *stream
|
||
|
reload_systemd_sessions (manager);
|
||
|
return TRUE;
|
||
|
}
|
||
|
+#endif
|
||
|
|
||
|
static void
|
||
|
_monitor_for_systemd_session_changes (ActUserManager *manager)
|
||
|
{
|
||
|
+#ifdef __linux__
|
||
|
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
|
||
|
int res;
|
||
|
int fd;
|
||
|
@@ -1711,6 +1736,7 @@ _monitor_for_systemd_session_changes (ActUserManager *
|
||
|
NULL);
|
||
|
priv->seat.session_monitor_source_id = g_source_attach (source, NULL);
|
||
|
g_source_unref (source);
|
||
|
+#endif
|
||
|
}
|
||
|
|
||
|
static void
|
||
|
@@ -2180,7 +2206,7 @@ maybe_set_is_loaded (ActUserManager *manager)
|
||
|
/* Don't set is_loaded yet unless the seat is already loaded enough
|
||
|
* or failed to load.
|
||
|
*/
|
||
|
- if (priv->seat.state > ACT_USER_MANAGER_SEAT_STATE_GET_ID) {
|
||
|
+ if (priv->seat.state >= ACT_USER_MANAGER_SEAT_STATE_GET_ID) {
|
||
|
g_debug ("ActUserManager: Seat loaded, so now setting loaded property");
|
||
|
} 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");
|
||
|
@@ -2670,6 +2696,7 @@ act_user_manager_finalize (GObject *object)
|
||
|
g_source_remove (priv->seat.load_idle_id);
|
||
|
}
|
||
|
|
||
|
+#ifdef __linux__
|
||
|
if (priv->seat.session_monitor != NULL) {
|
||
|
sd_login_monitor_unref (priv->seat.session_monitor);
|
||
|
}
|
||
|
@@ -2681,6 +2708,7 @@ act_user_manager_finalize (GObject *object)
|
||
|
if (priv->seat.session_monitor_source_id != 0) {
|
||
|
g_source_remove (priv->seat.session_monitor_source_id);
|
||
|
}
|
||
|
+#endif
|
||
|
|
||
|
if (priv->accounts_proxy != NULL) {
|
||
|
g_object_unref (priv->accounts_proxy);
|