Rework all patches to be closer to what upstream is shipping instead of

patching over reverts of reverts.
This will ease future updates and see what we are doing differently.
This commit is contained in:
ajacoutot 2021-05-29 14:02:24 +00:00
parent ae1001d003
commit be75295218
16 changed files with 785 additions and 1871 deletions

View File

@ -1,9 +1,10 @@
# $OpenBSD: Makefile,v 1.297 2021/05/15 15:49:02 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.298 2021/05/29 14:02:24 ajacoutot Exp $
COMMENT= GNOME display manager
GNOME_PROJECT= gdm
GNOME_VERSION= 40.0
REVISION= 0
DISTFILES= ${DISTNAME}${EXTRACT_SUFX} gdm-puffy.png:0
EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX}

View File

@ -1,29 +0,0 @@
$OpenBSD: patch-common_gdm-address_c,v 1.2 2019/05/12 21:28:50 ajacoutot Exp $
--- common/gdm-address.c.orig Thu Jun 16 15:24:47 2011
+++ common/gdm-address.c Thu Jun 16 15:25:19 2011
@@ -29,6 +29,8 @@
#include <stropts.h>
#endif
#include <string.h>
+#include <sys/types.h>
+#include <sys/param.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
@@ -37,7 +39,6 @@
#endif
#include <netdb.h>
#include <sys/ioctl.h>
-#include <net/if.h>
#ifndef G_OS_WIN32
#include <sys/select.h>
@@ -47,6 +48,7 @@
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
+#include <net/if.h>
#include <glib-object.h>

View File

@ -1,201 +1,81 @@
$OpenBSD: patch-common_gdm-common_c,v 1.9 2021/05/15 15:49:02 ajacoutot Exp $
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From fcba1e1a5d556ce7b52101dbd2d1ba4a19469161 Mon Sep 17 00:00:00 2001
From: Iain Lane <iain@orangesquash.org.uk>
Date: Fri, 5 Jan 2018 11:53:34 +0000
Subject: [PATCH] manager: Find user's current graphical session, not session of caller
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 9be58c9ec9a3a411492a5182ac4b0d51fdc3a323 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 13:48:52 -0400
Subject: require logind support
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 1ac67f522f5690c27023d98096ca817f12f7eb88 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 13:28:01 -0400
Subject: drop consolekit support
$OpenBSD: patch-common_gdm-common_c,v 1.10 2021/05/29 14:02:24 ajacoutot Exp $
Index: common/gdm-common.c
--- common/gdm-common.c.orig
+++ common/gdm-common.c
@@ -36,12 +36,25 @@
@@ -36,7 +36,9 @@
#include "gdm-common.h"
+#ifdef WITH_SYSTEMD
+#if 0
#include <systemd/sd-login.h>
+#endif
#define GDM_DBUS_NAME "org.gnome.DisplayManager"
#define GDM_DBUS_LOCAL_DISPLAY_FACTORY_PATH "/org/gnome/DisplayManager/LocalDisplayFactory"
#define GDM_DBUS_LOCAL_DISPLAY_FACTORY_INTERFACE "org.gnome.DisplayManager.LocalDisplayFactory"
+#ifdef WITH_CONSOLE_KIT
+#define CK_NAME "org.freedesktop.ConsoleKit"
+#define CK_PATH "/org/freedesktop/ConsoleKit"
+#define CK_INTERFACE "org.freedesktop.ConsoleKit"
+
+#define CK_MANAGER_PATH "/org/freedesktop/ConsoleKit/Manager"
+#define CK_MANAGER_INTERFACE "org.freedesktop.ConsoleKit.Manager"
+#define CK_SEAT_INTERFACE "org.freedesktop.ConsoleKit.Seat"
+#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
+#endif
+
G_DEFINE_QUARK (gdm-common-error, gdm_common_error);
gboolean
@@ -352,8 +365,87 @@ create_transient_display (GDBusConnection *connection,
return TRUE;
}
+#ifdef WITH_CONSOLE_KIT
gboolean
-gdm_activate_session_by_id (GDBusConnection *connection,
+get_current_session_id (GDBusConnection *connection,
+ char **session_id)
+{
+ GError *local_error = NULL;
+ GVariant *reply;
+
+ reply = g_dbus_connection_call_sync (connection,
+ CK_NAME,
+ CK_MANAGER_PATH,
+ CK_MANAGER_INTERFACE,
+ "GetCurrentSession",
+ NULL, /* parameters */
+ G_VARIANT_TYPE ("(o)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL, &local_error);
+ if (reply == NULL) {
+ g_warning ("Unable to determine session: %s", local_error->message);
+ g_error_free (local_error);
+ return FALSE;
+ }
+
+ g_variant_get (reply, "(o)", session_id);
+ g_variant_unref (reply);
+
+ return TRUE;
+}
+
+static gboolean
+get_seat_id_for_session (GDBusConnection *connection,
+ const char *session_id,
+ char **seat_id)
+{
+ GError *local_error = NULL;
+ GVariant *reply;
+
+ reply = g_dbus_connection_call_sync (connection,
+ CK_NAME,
+ session_id,
+ CK_SESSION_INTERFACE,
+ "GetSeatId",
+ NULL, /* parameters */
+ G_VARIANT_TYPE ("(o)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL, &local_error);
+ if (reply == NULL) {
+ g_warning ("Unable to determine seat: %s", local_error->message);
+ g_error_free (local_error);
+ return FALSE;
+ }
+
+ g_variant_get (reply, "(o)", seat_id);
+ g_variant_unref (reply);
+
+ return TRUE;
+}
+
+static char *
+get_current_seat_id (GDBusConnection *connection)
+{
+ gboolean res;
+ char *session_id;
+ char *seat_id;
+
+ session_id = NULL;
+ seat_id = NULL;
+
+ res = get_current_session_id (connection, &session_id);
+ if (res) {
+ res = get_seat_id_for_session (connection, session_id, &seat_id);
+ }
+ g_free (session_id);
+
+ return seat_id;
+}
+
+gboolean
+activate_session_id_for_ck (GDBusConnection *connection,
const char *seat_id,
const char *session_id)
{
@@ -361,6 +453,217 @@ gdm_activate_session_by_id (GDBusConnection *connectio
@@ -361,11 +363,11 @@ gdm_activate_session_by_id (GDBusConnection *connectio
GVariant *reply;
reply = g_dbus_connection_call_sync (connection,
+ CK_NAME,
- "org.freedesktop.login1",
- "/org/freedesktop/login1",
- "org.freedesktop.login1.Manager",
- "ActivateSessionOnSeat",
- g_variant_new ("(ss)", session_id, seat_id),
+ "org.freedesktop.ConsoleKit",
+ seat_id,
+ CK_SEAT_INTERFACE,
+ "org.freedesktop.ConsoleKit.Seat",
+ "ActivateSession",
+ g_variant_new ("(o)", session_id),
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL, &local_error);
+ if (reply == NULL) {
+ g_warning ("Unable to activate session: %s", local_error->message);
+ g_error_free (local_error);
+ return FALSE;
+ }
+
+ g_variant_unref (reply);
+
+ return TRUE;
+}
+
+static gboolean
+session_is_login_window (GDBusConnection *connection,
+ const char *session_id)
+{
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
@@ -381,98 +383,216 @@ gdm_activate_session_by_id (GDBusConnection *connectio
return TRUE;
}
-gboolean
-gdm_get_login_window_session_id (const char *seat_id,
- char **session_id)
+static const char **
+seat_get_sessions (GDBusConnection *connection,
+ const char *seat_id)
{
- gboolean ret;
- int res, i;
- char **sessions;
- char *service_id;
- char *service_class;
- char *state;
+ GError *local_error = NULL;
+ GVariant *reply;
+ const char *value;
+ gboolean ret;
+
+ const char **value;
- res = sd_seat_get_sessions (seat_id, &sessions, NULL, NULL);
- if (res < 0) {
- g_debug ("Failed to determine sessions: %s", strerror (-res));
+ reply = g_dbus_connection_call_sync (connection,
+ CK_NAME,
+ session_id,
+ CK_SESSION_INTERFACE,
+ "GetSessionType",
+ "org.freedesktop.ConsoleKit",
+ seat_id,
+ "org.freedesktop.ConsoleKit.Seat",
+ "GetSessions",
+ NULL,
+ G_VARIANT_TYPE ("(s)"),
+ G_VARIANT_TYPE ("(ao)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL, &local_error);
+ if (reply == NULL) {
+ g_warning ("Unable to determine session type: %s", local_error->message);
+ g_warning ("Unable to list sessions: %s", local_error->message);
+ g_error_free (local_error);
+ return FALSE;
+ }
+
+ g_variant_get (reply, "(&s)", &value);
+
+ if (value == NULL || value[0] == '\0' || strcmp (value, "LoginWindow") != 0) {
+ ret = FALSE;
+ } else {
+ ret = TRUE;
+ }
+
return FALSE;
}
- if (sessions == NULL || sessions[0] == NULL) {
- *session_id = NULL;
+ g_variant_get (reply, "(^ao)", &value);
+ g_variant_unref (reply);
+
+ return ret;
+ return value;
+}
+
+static gboolean
@ -207,9 +87,9 @@ Index: common/gdm-common.c
+ gboolean ret;
+
+ reply = g_dbus_connection_call_sync (connection,
+ CK_NAME,
+ "org.freedesktop.ConsoleKit",
+ seat_id,
+ CK_SEAT_INTERFACE,
+ "org.freedesktop.ConsoleKit.Seat",
+ "CanActivateSessions",
+ NULL,
+ G_VARIANT_TYPE ("(b)"),
@ -228,347 +108,288 @@ Index: common/gdm-common.c
+ return ret;
+}
+
+static const char **
+seat_get_sessions (GDBusConnection *connection,
+ const char *seat_id)
+static gboolean
+session_is_login_window (GDBusConnection *connection,
+ const char *session_id)
+{
+ GError *local_error = NULL;
+ GVariant *reply;
+ const char **value;
+ const char *value;
+ gboolean ret;
+
+ reply = g_dbus_connection_call_sync (connection,
+ CK_NAME,
+ seat_id,
+ CK_SEAT_INTERFACE,
+ "GetSessions",
+ "org.freedesktop.ConsoleKit",
+ session_id,
+ "org.freedesktop.ConsoleKit.Session",
+ "GetSessionType",
+ NULL,
+ G_VARIANT_TYPE ("(ao)"),
+ G_VARIANT_TYPE ("(s)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL, &local_error);
+ if (reply == NULL) {
+ g_warning ("Unable to list sessions: %s", local_error->message);
+ g_warning ("Unable to determine session type: %s", local_error->message);
+ g_error_free (local_error);
+ return FALSE;
+ }
+
+ g_variant_get (reply, "(^ao)", &value);
+ g_variant_get (reply, "(&s)", &value);
+
+ if (value == NULL || value[0] == '\0' || strcmp (value, "LoginWindow") != 0) {
ret = FALSE;
- goto out;
+ } else {
+ ret = TRUE;
}
- for (i = 0; sessions[i]; i ++) {
+ g_variant_unref (reply);
+
+ return value;
- res = sd_session_get_class (sessions[i], &service_class);
- if (res < 0) {
- if (res == -ENXIO)
- continue;
+ return ret;
+}
+
+static gboolean
+get_login_window_session_id_for_ck (GDBusConnection *connection,
+ const char *seat_id,
+ char **session_id)
- g_debug ("failed to determine class of session %s: %s", sessions[i], strerror (-res));
- ret = FALSE;
- goto out;
- }
+gboolean
+get_login_window_session_id (GDBusConnection *connection,
+ const char *seat_id,
+ char **session_id)
+{
+ gboolean can_activate_sessions;
+ gboolean can_activate_sessions;
+ const char **sessions;
+ int i;
+
- if (strcmp (service_class, "greeter") != 0) {
- free (service_class);
- continue;
- }
+ *session_id = NULL;
+ sessions = NULL;
+
- free (service_class);
+ g_debug ("checking if seat can activate sessions");
+
- ret = sd_session_get_state (sessions[i], &state);
- if (ret < 0) {
- if (res == -ENXIO)
- continue;
+ can_activate_sessions = seat_can_activate_sessions (connection, seat_id);
+ if (! can_activate_sessions) {
+ g_debug ("seat is unable to activate sessions");
+ return FALSE;
+ }
+
- g_debug ("failed to determine state of session %s: %s", sessions[i], strerror (-res));
- ret = FALSE;
- goto out;
- }
+ sessions = seat_get_sessions (connection, seat_id);
+ for (i = 0; sessions [i] != NULL; i++) {
+ const char *ssid;
+
- if (g_strcmp0 (state, "closing") == 0) {
- free (state);
- continue;
+ ssid = sessions [i];
+
+ if (session_is_login_window (connection, ssid)) {
+ *session_id = g_strdup (ssid);
+ break;
+ }
}
- free (state);
+ }
+ g_free (sessions);
+
- res = sd_session_get_service (sessions[i], &service_id);
- if (res < 0) {
- if (res == -ENXIO)
- continue;
+ return TRUE;
+}
- g_debug ("failed to determine service of session %s: %s", sessions[i], strerror (-res));
- ret = FALSE;
- goto out;
- }
+gboolean
+get_current_session_id (GDBusConnection *connection,
+ char **session_id)
+{
+ GError *local_error = NULL;
+ GVariant *reply;
- if (strcmp (service_id, "gdm-launch-environment") == 0) {
- *session_id = g_strdup (sessions[i]);
- ret = TRUE;
+ reply = g_dbus_connection_call_sync (connection,
+ "org.freedesktop.ConsoleKit",
+ "/org/freedesktop/ConsoleKit/Manager",
+ "org.freedesktop.ConsoleKit.Manager",
+ "GetCurrentSession",
+ NULL, /* parameters */
+ G_VARIANT_TYPE ("(o)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL, &local_error);
+ if (reply == NULL) {
+ g_warning ("Unable to determine session: %s", local_error->message);
+ g_error_free (local_error);
+ return FALSE;
+ }
- free (service_id);
- goto out;
- }
+ g_variant_get (reply, "(o)", session_id);
+ g_variant_unref (reply);
- free (service_id);
+ return TRUE;
+}
+
+static gboolean
+goto_login_session_for_ck (GDBusConnection *connection,
+ GError **error)
+{
+ gboolean ret;
+ gboolean res;
+ char *session_id;
+ char *seat_id;
+
+ ret = FALSE;
+
+ /* First look for any existing LoginWindow sessions on the seat.
+ If none are found, create a new one. */
+
+ seat_id = get_current_seat_id (connection);
+ if (seat_id == NULL || seat_id[0] == '\0') {
+ g_debug ("seat id is not set; can't switch sessions");
+ g_set_error (error, GDM_COMMON_ERROR, 0, _("Could not identify the current session."));
+
+ return FALSE;
+ }
+
+ res = get_login_window_session_id_for_ck (connection, seat_id, &session_id);
+ if (! res) {
+ g_set_error (error, GDM_COMMON_ERROR, 1, _("User unable to switch sessions."));
+ return FALSE;
+ }
+
+ if (session_id != NULL) {
+ res = activate_session_id_for_ck (connection, seat_id, session_id);
+ if (res) {
+ ret = TRUE;
+ }
+ }
+
+ if (! ret && g_strcmp0 (seat_id, "/org/freedesktop/ConsoleKit/Seat1") == 0) {
+ res = create_transient_display (connection, error);
+ if (res) {
+ ret = TRUE;
+ }
+ }
+
+ return ret;
+}
+#endif
+
+#ifdef WITH_SYSTEMD
+
+gboolean
+activate_session_id_for_systemd (GDBusConnection *connection,
+ const char *seat_id,
+ const char *session_id)
+get_seat_id_for_session (GDBusConnection *connection,
+ const char *session_id,
+ char **seat_id)
+{
+ GError *local_error = NULL;
+ GVariant *reply;
+
+ reply = g_dbus_connection_call_sync (connection,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
@@ -382,8 +685,8 @@ gdm_activate_session_by_id (GDBusConnection *connectio
}
+ "org.freedesktop.ConsoleKit",
+ session_id,
+ "org.freedesktop.ConsoleKit.Session",
+ "GetSeatId",
+ NULL, /* parameters */
+ G_VARIANT_TYPE ("(o)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL, &local_error);
+ if (reply == NULL) {
+ g_warning ("Unable to determine seat: %s", local_error->message);
+ g_error_free (local_error);
+ return FALSE;
}
gboolean
-gdm_get_login_window_session_id (const char *seat_id,
- char **session_id)
+get_login_window_session_id_for_systemd (const char *seat_id,
+ char **session_id)
{
gboolean ret;
int res, i;
@@ -476,15 +779,14 @@ out:
- *session_id = NULL;
- ret = FALSE;
+ g_variant_get (reply, "(o)", seat_id);
+ g_variant_unref (reply);
-out:
- if (sessions) {
- for (i = 0; sessions[i]; i ++) {
- free (sessions[i]);
- }
+ return TRUE;
+}
- free (sessions);
+static char *
+get_current_seat_id (GDBusConnection *connection)
+{
+ gboolean res;
+ char *session_id;
+ char *seat_id;
+
+ session_id = NULL;
+ seat_id = NULL;
+
+ res = get_current_session_id (connection, &session_id);
+ if (res) {
+ res = get_seat_id_for_session (connection, session_id, &seat_id);
}
+ g_free (session_id);
- return ret;
+ return seat_id;
}
static gboolean
-goto_login_session (GDBusConnection *connection,
- GError **error)
+goto_login_session_for_systemd (GDBusConnection *connection,
+ GError **error)
@@ -480,57 +600,43 @@ goto_login_session (GDBusConnection *connection,
GError **error)
{
gboolean ret;
int res;
char *our_session;
- int res;
- char *our_session;
+ gboolean res;
char *session_id;
char *seat_id;
- GError *local_error = NULL;
ret = FALSE;
session_id = NULL;
@@ -497,8 +799,10 @@ goto_login_session (GDBusConnection *connection,
* since the data allocated is from libsystemd-logind, which
* does not use GLib's g_malloc (). */
- session_id = NULL;
- seat_id = NULL;
/* First look for any existing LoginWindow sessions on the seat.
If none are found, create a new one. */
- /* Note that we mostly use free () here, instead of g_free ()
- * since the data allocated is from libsystemd-logind, which
- * does not use GLib's g_malloc (). */
+ seat_id = get_current_seat_id (connection);
+ if (seat_id == NULL || seat_id[0] == '\0') {
+ g_debug ("seat id is not set; can't switch sessions");
+ g_set_error (error, GDM_COMMON_ERROR, 0, _("Could not identify the current session."));
- if (!gdm_find_display_session (0, getuid (), &our_session, &local_error)) {
- g_propagate_prefixed_error (error, local_error, _("Could not identify the current session: "));
+ res = sd_pid_get_session (0, &our_session);
+ if (res < 0) {
+ g_debug ("failed to determine own session: %s", strerror (-res));
+ g_set_error (error, GDM_COMMON_ERROR, 0, _("Could not identify the current session."));
-
return FALSE;
}
@@ -512,9 +816,9 @@ goto_login_session (GDBusConnection *connection,
- res = sd_session_get_seat (our_session, &seat_id);
- free (our_session);
- if (res < 0) {
- g_debug ("failed to determine own seat: %s", strerror (-res));
- g_set_error (error, GDM_COMMON_ERROR, 0, _("Could not identify the current seat."));
-
+ res = get_login_window_session_id (connection, seat_id, &session_id);
+ if (! res) {
+ g_set_error (error, GDM_COMMON_ERROR, 1, _("User unable to switch sessions."));
return FALSE;
}
- res = gdm_get_login_window_session_id (seat_id, &session_id);
+ res = get_login_window_session_id_for_systemd (seat_id, &session_id);
if (res && session_id != NULL) {
- res = gdm_activate_session_by_id (connection, seat_id, session_id);
+ res = activate_session_id_for_systemd (connection, seat_id, session_id);
- if (res && session_id != NULL) {
+ if (session_id != NULL) {
res = gdm_activate_session_by_id (connection, seat_id, session_id);
-
if (res) {
ret = TRUE;
@@ -533,6 +837,7 @@ goto_login_session (GDBusConnection *connection,
return ret;
}
+#endif
gboolean
gdm_goto_login_session (GError **error)
@@ -548,7 +853,17 @@ gdm_goto_login_session (GError **error)
return FALSE;
}
- return goto_login_session (connection, error);
+#ifdef WITH_SYSTEMD
+ if (LOGIND_RUNNING()) {
+ return goto_login_session_for_systemd (connection, error);
+ }
+#endif
+
+#ifdef WITH_CONSOLE_KIT
+ return goto_login_session_for_ck (connection, error);
+#else
+ return FALSE;
+#endif
}
static void
@@ -823,136 +1138,4 @@ gdm_shell_expand (const char *str,
}
}
return g_string_free (s, FALSE);
-}
- if (! ret && g_strcmp0 (seat_id, "seat0") == 0) {
+ if (! ret && g_strcmp0 (seat_id, "/org/freedesktop/ConsoleKit/Seat1") == 0) {
res = create_transient_display (connection, error);
if (res) {
ret = TRUE;
}
}
- free (seat_id);
- g_free (session_id);
-
-static gboolean
-_systemd_session_is_graphical (const char *session_id)
-{
- const gchar * const graphical_session_types[] = { "wayland", "x11", "mir", NULL };
- int saved_errno;
- g_autofree gchar *type = 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));
- return FALSE;
- }
-
- if (!g_strv_contains (graphical_session_types, type)) {
- g_debug ("Session '%s' is not a graphical session (type: '%s')",
- session_id,
- type);
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gboolean
-_systemd_session_is_active (const char *session_id)
-{
- const gchar * const active_states[] = { "active", "online", NULL };
- int saved_errno;
- g_autofree gchar *state = NULL;
-
- /*
- * 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
- * GDM_SYSTEMD_SESSION_REQUIRE_ONLINE)
- */
- 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));
- return FALSE;
- }
-
- if (!g_strv_contains (active_states, state)) {
- g_debug ("Session '%s' is not active or online", session_id);
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
-gdm_find_display_session (GPid pid,
- const uid_t uid,
- char **out_session_id,
- GError **error)
-{
- char *local_session_id = NULL;
- g_auto(GStrv) sessions = NULL;
- int n_sessions;
- int res;
-
- g_return_val_if_fail (out_session_id != NULL, FALSE);
-
- /* First try to look up the session using the pid. We need this
- * at least for the greeter, because it currently runs multiple
- * sessions under the same user.
- * See also commit 2b52d8933c8ab38e7ee83318da2363d00d8c5581
- * which added an explicit dbus-run-session for all but seat0.
- */
- res = sd_pid_get_session (pid, &local_session_id);
- if (res >= 0) {
- g_debug ("GdmCommon: Found session %s for PID %d, using", local_session_id, pid);
-
- *out_session_id = g_strdup (local_session_id);
- free (local_session_id);
-
- return TRUE;
- } else {
- if (res != -ENODATA)
- g_warning ("GdmCommon: Failed to retrieve session information for pid %d: %s",
- pid, strerror (-res));
- }
-
- g_debug ("Finding a graphical session for user %d", uid);
-
- n_sessions = sd_uid_get_sessions (uid,
- GDM_SYSTEMD_SESSION_REQUIRE_ONLINE,
- &sessions);
-
- if (n_sessions < 0) {
- g_set_error (error,
- GDM_COMMON_ERROR,
- 0,
- "Failed to get sessions for user %d",
- uid);
- return FALSE;
- }
-
- for (int i = 0; i < n_sessions; ++i) {
- g_debug ("Considering session '%s'", sessions[i]);
-
- if (!_systemd_session_is_graphical (sessions[i]))
- continue;
-
- if (!_systemd_session_is_active (sessions[i]))
- continue;
-
- /*
- * We get the sessions from newest to oldest, so take the last
- * one we find that's good
- */
- local_session_id = sessions[i];
- }
-
- if (local_session_id == NULL) {
- g_set_error (error,
- GDM_COMMON_ERROR,
- 0,
- "Could not find a graphical session for user %d",
- uid);
- return FALSE;
- }
-
- *out_session_id = g_strdup (local_session_id);
-
- return TRUE;
return ret;
}
@@ -825,6 +931,7 @@ gdm_shell_expand (const char *str,
return g_string_free (s, FALSE);
}
+#if 0
static gboolean
_systemd_session_is_graphical (const char *session_id)
{
@@ -956,3 +1063,4 @@ gdm_find_display_session (GPid pid,
return TRUE;
}
+#endif

View File

@ -1,52 +0,0 @@
$OpenBSD: patch-common_gdm-common_h,v 1.5 2020/05/14 15:25:54 ajacoutot Exp $
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From fcba1e1a5d556ce7b52101dbd2d1ba4a19469161 Mon Sep 17 00:00:00 2001
From: Iain Lane <iain@orangesquash.org.uk>
Date: Fri, 5 Jan 2018 11:53:34 +0000
Subject: [PATCH] manager: Find user's current graphical session, not session of caller
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 9be58c9ec9a3a411492a5182ac4b0d51fdc3a323 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 13:48:52 -0400
Subject: require logind support
Index: common/gdm-common.h
--- common/gdm-common.h.orig
+++ common/gdm-common.h
@@ -37,6 +37,11 @@
#define GDM_SYSTEMD_SESSION_REQUIRE_ONLINE 0
+/* check if logind is running */
+#define LOGIND_RUNNING() (access("/run/systemd/seats/", F_OK) >= 0)
+
+#define GDM_SYSTEMD_SESSION_REQUIRE_ONLINE 0
+
GQuark gdm_common_error_quark (void);
#define GDM_COMMON_ERROR gdm_common_error_quark()
@@ -51,11 +56,6 @@ int gdm_wait_on_and_disown_pid (int pid,
int gdm_signal_pid (int pid,
int signal);
-gboolean gdm_find_display_session (GPid pid,
- const uid_t uid,
- char **out_session_id,
- GError **error);
-
gboolean gdm_get_pwent_for_name (const char *name,
struct passwd **pwentp);
@@ -82,10 +82,6 @@ gboolean gdm_shell_var_is_valid_char (char c,
char * gdm_shell_expand (const char *str,
GdmExpandVarFunc expand_func,
gpointer user_data);
-
-gboolean gdm_activate_session_by_id (GDBusConnection *connection,
- const char *seat_id,
- const char *session_id);
G_END_DECLS

View File

@ -1,10 +1,4 @@
$OpenBSD: patch-common_gdm-log_c,v 1.2 2018/04/24 08:37:00 ajacoutot Exp $
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 9be58c9ec9a3a411492a5182ac4b0d51fdc3a323 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 13:48:52 -0400
Subject: require logind support
$OpenBSD: patch-common_gdm-log_c,v 1.3 2021/05/29 14:02:24 ajacoutot Exp $
Index: common/gdm-log.c
--- common/gdm-log.c.orig
@ -13,45 +7,9 @@ Index: common/gdm-log.c
#include <unistd.h>
#include <syslog.h>
+#ifdef WITH_SYSTEMD
+#if 0
#include <systemd/sd-daemon.h>
+#endif
#include <glib.h>
#include <glib/gstdio.h>
@@ -125,12 +127,35 @@ gdm_log_set_debug (gboolean debug)
void
gdm_log_init (void)
{
+ const char *prg_name;
+ int options;
+
if (initialized)
return;
initialized = TRUE;
+#ifdef WITH_SYSTEMD
+ is_sd_booted = sd_booted () > 0;
+#endif
+
g_log_set_default_handler (gdm_log_default_handler, NULL);
+
+ /* Only set up syslog if !systemd, otherwise with systemd
+ * enabled, we keep the default GLib log handler which goes to
+ * stderr, which is routed to the appropriate place in the
+ * systemd service file.
+ */
+ if (!is_sd_booted) {
+ prg_name = g_get_prgname ();
+
+ options = LOG_PID;
+#ifdef LOG_PERROR
+ options |= LOG_PERROR;
+#endif
+
+ openlog (prg_name, options, LOG_DAEMON);
+ }
}
void

View File

@ -1,19 +1,7 @@
$OpenBSD: patch-daemon_gdm-launch-environment_c,v 1.10 2019/11/02 15:34:07 ajacoutot Exp $
$OpenBSD: patch-daemon_gdm-launch-environment_c,v 1.11 2021/05/29 14:02:24 ajacoutot Exp $
XXX fix+push upstream
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 1ac67f522f5690c27023d98096ca817f12f7eb88 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 13:28:01 -0400
Subject: drop consolekit support
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From a9cacb929470eb82582396984c61d5b611bfeb1a Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 14:33:40 -0400
Subject: session: drop session-type property
Index: daemon/gdm-launch-environment.c
--- daemon/gdm-launch-environment.c.orig
+++ daemon/gdm-launch-environment.c

View File

@ -1,16 +1,4 @@
$OpenBSD: patch-daemon_gdm-local-display-factory_c,v 1.16 2021/05/15 15:49:02 ajacoutot Exp $
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 1ac67f522f5690c27023d98096ca817f12f7eb88 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 13:28:01 -0400
Subject: drop consolekit support
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 9be58c9ec9a3a411492a5182ac4b0d51fdc3a323 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 13:48:52 -0400
Subject: require logind support
$OpenBSD: patch-daemon_gdm-local-display-factory_c,v 1.17 2021/05/29 14:02:24 ajacoutot Exp $
Index: daemon/gdm-local-display-factory.c
--- daemon/gdm-local-display-factory.c.orig
@ -19,89 +7,39 @@ Index: daemon/gdm-local-display-factory.c
#include <glib-object.h>
#include <gio/gio.h>
+#ifdef WITH_SYSTEMD
+#if 0
#include <systemd/sd-login.h>
+#endif
#include "gdm-common.h"
#include "gdm-manager.h"
@@ -42,6 +44,8 @@
#include "gdm-local-display.h"
#include "gdm-legacy-display.h"
+#define CK_SEAT1_PATH "/org/freedesktop/ConsoleKit/Seat1"
+
#define GDM_DBUS_PATH "/org/gnome/DisplayManager"
#define GDM_LOCAL_DISPLAY_FACTORY_DBUS_PATH GDM_DBUS_PATH "/LocalDisplayFactory"
#define GDM_MANAGER_DBUS_NAME "org.gnome.DisplayManager.LocalDisplayFactory"
@@ -61,9 +65,11 @@ struct _GdmLocalDisplayFactory
/* FIXME: this needs to be per seat? */
guint num_failures;
+#ifdef WITH_SYSTEMD
guint seat_new_id;
guint seat_removed_id;
guint seat_properties_changed_id;
+#endif
gboolean seat0_graphics_check_timed_out;
guint seat0_graphics_check_timeout_id;
@@ -90,7 +96,9 @@ static void on_display_status_changed
GParamSpec *arg1,
GdmLocalDisplayFactory *factory);
+#ifdef WITH_SYSTEMD
static gboolean gdm_local_display_factory_sync_seats (GdmLocalDisplayFactory *factory);
+#endif
static gpointer local_display_factory_object = NULL;
static gboolean lookup_by_session_id (const char *id,
GdmDisplay *display,
@@ -235,7 +243,7 @@ gdm_local_display_factory_create_transient_display (Gd
g_debug ("GdmLocalDisplayFactory: Creating transient display");
-#ifdef ENABLE_USER_DISPLAY_SERVER
+#if defined ENABLE_USER_DISPLAY_SERVER && defined WITH_SYSTEMD
display = gdm_local_display_new ();
if (gdm_local_display_factory_use_wayland ())
g_object_set (G_OBJECT (display), "session-type", "wayland", NULL);
@@ -376,7 +384,7 @@ on_display_status_changed (GdmDisplay *dis
@@ -376,7 +378,7 @@ on_display_status_changed (GdmDisplay *dis
/* reset num failures */
factory->num_failures = 0;
- gdm_local_display_factory_sync_seats (factory);
+ ensure_display_for_seat (factory, seat_id);
+ ensure_display_for_seat (factory, seat_id);
}
break;
case GDM_DISPLAY_FAILED:
@@ -480,9 +488,12 @@ ensure_display_for_seat (GdmLocalDisplayFactory *facto
const char *session_type = "wayland";
GdmDisplayStore *store;
@@ -482,7 +484,7 @@ ensure_display_for_seat (GdmLocalDisplayFactory *facto
GdmDisplay *display = NULL;
+#ifdef WITH_SYSTEMD
g_autofree char *login_session_id = NULL;
-
ret = sd_seat_can_graphical (seat_id);
+#else
+ ret = 1;
+#endif
- ret = sd_seat_can_graphical (seat_id);
+ ret = 1;
if (ret < 0) {
g_critical ("Failed to query CanGraphical information for seat %s", seat_id);
@@ -576,6 +587,7 @@ ensure_display_for_seat (GdmLocalDisplayFactory *facto
@@ -576,6 +578,7 @@ ensure_display_for_seat (GdmLocalDisplayFactory *facto
return;
}
+#ifdef WITH_SYSTEMD
+#if 0
/* If we already have a login window, switch to it */
if (gdm_get_login_window_session_id (seat_id, &login_session_id)) {
GdmDisplay *display;
@@ -589,14 +601,15 @@ ensure_display_for_seat (GdmLocalDisplayFactory *facto
g_object_set (G_OBJECT (display), "status", GDM_DISPLAY_MANAGED, NULL);
g_debug ("GdmLocalDisplayFactory: session %s found, activating.",
login_session_id);
- gdm_activate_session_by_id (factory->connection, seat_id, login_session_id);
+ activate_session_id (factory->connection, seat_id, login_session_id);
@@ -593,6 +596,7 @@ ensure_display_for_seat (GdmLocalDisplayFactory *facto
return;
}
}
@ -109,75 +47,39 @@ Index: daemon/gdm-local-display-factory.c
g_debug ("GdmLocalDisplayFactory: Adding display on seat %s", seat_id);
-#ifdef ENABLE_USER_DISPLAY_SERVER
+#if defined ENABLE_USER_DISPLAY_SERVER && defined WITH_SYSTEMD
if (is_seat0) {
display = gdm_local_display_new ();
if (session_type != NULL) {
@@ -628,6 +641,7 @@ ensure_display_for_seat (GdmLocalDisplayFactory *facto
return;
}
+#ifdef WITH_SYSTEMD
static void
delete_display (GdmLocalDisplayFactory *factory,
const char *seat_id) {
@@ -746,7 +760,11 @@ on_seat_properties_changed (GDBusConnection *connectio
@@ -746,7 +750,7 @@ on_seat_properties_changed (GDBusConnection *connectio
if (!changed)
return;
+#ifdef WITH_SYSTEMD
ret = sd_seat_can_graphical (seat);
+#else
+ ret = -1;
+#endif
- ret = sd_seat_can_graphical (seat);
+ ret = 1;
if (ret < 0)
return;
@@ -1046,6 +1064,7 @@ gdm_local_display_factory_stop_monitor (GdmLocalDispla
}
#endif
@@ -768,6 +772,7 @@ lookup_by_session_id (const char *id,
return g_strcmp0 (current, looking_for) == 0;
}
+#if 0
static gboolean
lookup_by_tty (const char *id,
GdmDisplay *display,
@@ -790,6 +795,7 @@ lookup_by_tty (const char *id,
return g_strcmp0 (tty_to_check, tty_to_find) == 0;
}
+#endif
#if defined(ENABLE_USER_DISPLAY_SERVER)
static void
on_display_added (GdmDisplayStore *display_store,
@@ -1097,8 +1116,16 @@ gdm_local_display_factory_start (GdmDisplayFactory *ba
@@ -1097,8 +1103,8 @@ gdm_local_display_factory_start (GdmDisplayFactory *ba
factory,
0);
- gdm_local_display_factory_start_monitor (factory);
- return gdm_local_display_factory_sync_seats (factory);
+#ifdef WITH_SYSTEMD
+ if (LOGIND_RUNNING()) {
+ gdm_local_display_factory_start_monitor (factory);
+ return gdm_local_display_factory_sync_seats (factory);
+ }
+#endif
+
+ /* On ConsoleKit just create Seat1, and that's it. */
+ ensure_display_for_seat (factory, CK_SEAT1_PATH);
+ ensure_display_for_seat (factory, "/org/freedesktop/ConsoleKit/Seat1");
+ return TRUE;
}
static gboolean
@@ -1109,7 +1136,9 @@ gdm_local_display_factory_stop (GdmDisplayFactory *bas
g_return_val_if_fail (GDM_IS_LOCAL_DISPLAY_FACTORY (factory), FALSE);
+#ifdef WITH_SYSTEMD
gdm_local_display_factory_stop_monitor (factory);
+#endif
store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
@@ -1263,7 +1292,9 @@ gdm_local_display_factory_finalize (GObject *object)
g_hash_table_destroy (factory->used_display_numbers);
+#ifdef WITH_SYSTEMD
gdm_local_display_factory_stop_monitor (factory);
+#endif
G_OBJECT_CLASS (gdm_local_display_factory_parent_class)->finalize (object);
}

View File

@ -1,34 +1,4 @@
$OpenBSD: patch-daemon_gdm-manager_c,v 1.27 2021/05/15 15:49:02 ajacoutot Exp $
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From fcba1e1a5d556ce7b52101dbd2d1ba4a19469161 Mon Sep 17 00:00:00 2001
From: Iain Lane <iain@orangesquash.org.uk>
Date: Fri, 5 Jan 2018 11:53:34 +0000
Subject: [PATCH] manager: Find user's current graphical session, not session of caller
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 21905303afbd508f3bf599ad219c9209413c53a2 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Wed, 5 Apr 2017 12:11:20 -0400
Subject: manager: stop transient greeter session when done with it
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 22c332baaf8ad6d7082c5b01250bae70934c2fd1 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Tue, 4 Apr 2017 17:07:04 -0400
Subject: manager: make sure we end up on a login screen
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 1ac67f522f5690c27023d98096ca817f12f7eb88 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 13:28:01 -0400
Subject: drop consolekit support
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 9be58c9ec9a3a411492a5182ac4b0d51fdc3a323 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 13:48:52 -0400
Subject: require logind support
$OpenBSD: patch-daemon_gdm-manager_c,v 1.28 2021/05/29 14:02:24 ajacoutot Exp $
Index: daemon/gdm-manager.c
--- daemon/gdm-manager.c.orig
@ -37,13 +7,13 @@ Index: daemon/gdm-manager.c
#include <act/act-user-manager.h>
+#ifdef WITH_SYSTEMD
+#if 0
#include <systemd/sd-login.h>
+#endif
#include "gdm-common.h"
@@ -61,9 +63,18 @@
@@ -61,7 +63,7 @@
#define GDM_MANAGER_PATH GDM_DBUS_PATH "/Manager"
#define GDM_MANAGER_DISPLAYS_PATH GDM_DBUS_PATH "/Displays"
@ -51,46 +21,30 @@ Index: daemon/gdm-manager.c
+#define INITIAL_SETUP_USERNAME "_gnome-initial-setup"
#define ALREADY_RAN_INITIAL_SETUP_ON_THIS_BOOT GDM_RUN_DIR "/gdm.ran-initial-setup"
+#define CK_NAME "org.freedesktop.ConsoleKit"
+#define CK_PATH "/org/freedesktop/ConsoleKit"
+#define CK_INTERFACE "org.freedesktop.ConsoleKit"
+
+#define CK_MANAGER_PATH "/org/freedesktop/ConsoleKit/Manager"
+#define CK_MANAGER_INTERFACE "org.freedesktop.ConsoleKit.Manager"
+#define CK_SEAT_INTERFACE "org.freedesktop.ConsoleKit.Seat"
+#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
+
typedef struct
{
GdmManager *manager;
@@ -205,9 +216,10 @@ plymouth_quit_without_transition (void)
}
@@ -206,51 +208,62 @@ plymouth_quit_without_transition (void)
#endif
+#ifdef WITH_SYSTEMD
static char *
-get_session_id_for_pid (pid_t pid,
- GError **error)
+get_session_id_for_pid_systemd (pid_t pid,
+ GError **error)
+get_session_id_for_pid (GDBusConnection *connection,
+ pid_t pid,
+ GError **error)
{
char *session, *gsession;
int ret;
@@ -232,11 +244,61 @@ get_session_id_for_pid (pid_t pid,
return NULL;
}
}
+#endif
+#ifdef WITH_CONSOLE_KIT
+static char *
+get_session_id_for_pid_consolekit (GDBusConnection *connection,
+ pid_t pid,
+ GError **error)
+{
- char *session, *gsession;
- int ret;
+ GVariant *reply;
+ char *retval;
+
- session = NULL;
- ret = sd_pid_get_session (pid, &session);
- if (ret < 0) {
- g_set_error (error,
- GDM_DISPLAY_ERROR,
- GDM_DISPLAY_ERROR_GETTING_SESSION_INFO,
- "Error getting session id from systemd: %s",
- g_strerror (-ret));
+ reply = g_dbus_connection_call_sync (connection,
+ "org.freedesktop.ConsoleKit",
+ "/org/freedesktop/ConsoleKit/Manager",
@ -102,61 +56,43 @@ Index: daemon/gdm-manager.c
+ -1,
+ NULL, error);
+ if (reply == NULL) {
+ return NULL;
+ }
+
return NULL;
}
- if (session != NULL) {
- gsession = g_strdup (session);
- free (session);
+ g_variant_get (reply, "(o)", &retval);
+ g_variant_unref (reply);
+
- return gsession;
- } else {
- return NULL;
- }
+ return retval;
+}
+#endif
+
+static char *
+get_session_id_for_pid (GDBusConnection *connection,
+ pid_t pid,
+ GError **error)
+{
+#ifdef WITH_SYSTEMD
+ if (LOGIND_RUNNING()) {
+ return get_session_id_for_pid_systemd (pid, error);
+ }
+#endif
+
+#ifdef WITH_CONSOLE_KIT
+ return get_session_id_for_pid_consolekit (connection, pid, error);
+#endif
+
+ return NULL;
+}
+
+#ifdef WITH_SYSTEMD
}
static gboolean
-get_uid_for_session_id (const char *session_id,
- uid_t *uid,
- GError **error)
+get_uid_for_systemd_session_id (const char *session_id,
+ uid_t *uid,
+ GError **error)
+get_uid_for_session_id (GDBusConnection *connection,
+ const char *session_id,
+ uid_t *out_uid,
+ GError **error)
{
int ret;
@@ -253,8 +315,62 @@ get_uid_for_session_id (const char *session_id,
return TRUE;
}
+#endif
+#ifdef WITH_CONSOLE_KIT
static gboolean
+get_uid_for_consolekit_session_id (GDBusConnection *connection,
+ const char *session_id,
+ uid_t *out_uid,
+ GError **error)
+{
- int ret;
+ GVariant *reply;
+ guint32 uid;
+
- ret = sd_session_get_uid (session_id, uid);
- 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));
+ reply = g_dbus_connection_call_sync (connection,
+ "org.freedesktop.ConsoleKit",
+ session_id,
@ -169,58 +105,43 @@ Index: daemon/gdm-manager.c
+ NULL,
+ error);
+ if (reply == NULL) {
+ return FALSE;
+ }
+
return FALSE;
}
+ g_variant_get (reply, "(u)", &uid);
+ g_variant_unref (reply);
+
+ *out_uid = (uid_t) uid;
+
+ return TRUE;
+}
+#endif
+
+static gboolean
+get_uid_for_session_id (GDBusConnection *connection,
+ const char *session_id,
+ uid_t *uid,
+ GError **error)
+{
+#ifdef WITH_SYSTEMD
+ if (LOGIND_RUNNING()) {
+ return get_uid_for_systemd_session_id (session_id, uid, error);
+ }
+#endif
+
+#ifdef WITH_CONSOLE_KIT
+ return get_uid_for_consolekit_session_id (connection, session_id, uid, error);
+#endif
+
+ return FALSE;
+}
+
+static gboolean
lookup_by_session_id (const char *id,
GdmDisplay *display,
gpointer user_data)
@@ -266,11 +382,51 @@ lookup_by_session_id (const char *id,
return g_strcmp0 (current, looking_for) == 0;
return TRUE;
}
@@ -267,31 +280,39 @@ lookup_by_session_id (const char *id,
}
+#ifdef WITH_CONSOLE_KIT
static gboolean
-is_login_session (GdmManager *self,
- const char *session_id,
- GError **error)
+is_consolekit_login_session (GdmManager *self,
+ GDBusConnection *connection,
+ const char *session_id,
+ GError **error)
+is_login_session (GdmManager *self,
+ GDBusConnection *connection,
+ const char *session_id,
+ GError **error)
{
- char *session_class = NULL;
- int ret;
+ GVariant *reply;
+ char *session_type = NULL;
+
- ret = sd_session_get_class (session_id, &session_class);
-
- if (ret < 0) {
- g_set_error (error,
- GDM_DISPLAY_ERROR,
- GDM_DISPLAY_ERROR_GETTING_SESSION_INFO,
- "Error getting class for session id %s from systemd: %s",
- session_id,
- g_strerror (-ret));
+ reply = g_dbus_connection_call_sync (connection,
+ "org.freedesktop.ConsoleKit",
+ session_id,
@ -233,78 +154,42 @@ Index: daemon/gdm-manager.c
+ NULL,
+ error);
+ if (reply == NULL) {
+ return FALSE;
+ }
+
return FALSE;
}
- if (g_strcmp0 (session_class, "greeter") != 0) {
- g_free (session_class);
+ g_variant_get (reply, "(s)", &session_type);
+ g_variant_unref (reply);
+
+ if (g_strcmp0 (session_type, "LoginWindow") != 0) {
+ g_free (session_type);
+
+ return FALSE;
+ }
+
+ g_free (session_type);
+ return TRUE;
+}
+#endif
+
+#ifdef WITH_SYSTEMD
+static gboolean
+is_systemd_login_session (GdmManager *self,
+ const char *session_id,
+ GError **error)
+{
char *session_class = NULL;
int ret;
return FALSE;
}
@@ -294,29 +450,49 @@ is_login_session (GdmManager *self,
g_free (session_class);
- g_free (session_class);
+ g_free (session_type);
return TRUE;
}
+#endif
static gboolean
-session_unlock (GdmManager *manager,
- const char *ssid)
+is_login_session (GdmManager *self,
+ GDBusConnection *connection,
+ const char *session_id,
+ GError **error)
{
+#ifdef WITH_SYSTEMD
+ if (LOGIND_RUNNING()) {
+ return is_systemd_login_session (self, session_id, error);
+ }
+#endif
+
+#ifdef WITH_CONSOLE_KIT
+ return is_consolekit_login_session (self, connection, session_id, error);
+#endif
+
+ return FALSE;
+}
+
+#ifdef WITH_SYSTEMD
+static gboolean
+activate_session_id_for_systemd (GdmManager *manager,
+ const char *seat_id,
+ const char *session_id)
+{
@@ -302,21 +323,19 @@ session_unlock (GdmManager *manager,
GError *error = NULL;
GVariant *reply;
- g_debug ("Unlocking session %s", ssid);
-
reply = g_dbus_connection_call_sync (manager->priv->connection,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
- "org.freedesktop.login1",
- "/org/freedesktop/login1",
- "org.freedesktop.login1.Manager",
- "UnlockSession",
- g_variant_new ("(s)", ssid),
+ "ActivateSessionOnSeat",
+ g_variant_new ("(ss)", session_id, seat_id),
+ "org.freedesktop.ConsoleKit",
+ ssid,
+ "org.freedesktop.ConsoleKit.Session",
+ "Unlock",
+ NULL, /* parameters */
NULL, /* expected reply */
G_DBUS_CALL_FLAGS_NONE,
-1,
@ -312,147 +197,36 @@ Index: daemon/gdm-manager.c
&error);
if (reply == NULL) {
- g_debug ("GdmManager: logind 'UnlockSession' %s raised:\n %s\n\n",
+ g_debug ("GdmManager: logind 'ActivateSessionOnSeat' %s raised:\n %s\n\n",
+ g_debug ("GdmManager: ConsoleKit %s raised:\n %s\n\n",
g_dbus_error_get_remote_error (error), error->message);
g_error_free (error);
return FALSE;
@@ -326,7 +502,119 @@ session_unlock (GdmManager *manager,
return TRUE;
}
+#endif
+#ifdef WITH_CONSOLE_KIT
+static gboolean
+activate_session_id_for_ck (GdmManager *manager,
+ const char *seat_id,
+ const char *session_id)
+{
+ GError *error = NULL;
+ GVariant *reply;
+
+ reply = g_dbus_connection_call_sync (manager->priv->connection,
+ CK_NAME,
+ seat_id,
+ "org.freedesktop.ConsoleKit.Seat",
+ "ActivateSession",
+ g_variant_new ("(o)", session_id),
+ NULL, /* expected reply */
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (reply == NULL) {
+ g_debug ("GdmManager: ConsoleKit %s raised:\n %s\n\n",
+ g_dbus_error_get_remote_error (error), error->message);
+ g_error_free (error);
+
+ /* It is very likely that the "error" just reported is
+ * that the session is already active. Unfortunately,
+ * ConsoleKit doesn't use proper error codes and it
+ * translates the error message, so we have no real way
+ * to detect this case...
+ */
+ return TRUE;
+ }
+
+ g_variant_unref (reply);
+
+ return TRUE;
+}
+#endif
+
+static gboolean
+activate_session_id (GdmManager *manager,
+ const char *seat_id,
+ const char *session_id)
+{
+
+#ifdef WITH_SYSTEMD
+ if (LOGIND_RUNNING()) {
+ return activate_session_id_for_systemd (manager, seat_id, session_id);
+ }
+#endif
+
+#ifdef WITH_CONSOLE_KIT
+ return activate_session_id_for_ck (manager, seat_id, session_id);
+#else
+ return FALSE;
+#endif
+}
+
+#ifdef WITH_CONSOLE_KIT
+static gboolean
+session_unlock_for_ck (GdmManager *manager,
+ const char *ssid)
+{
+ GError *error = NULL;
+ GVariant *reply;
+
+ reply = g_dbus_connection_call_sync (manager->priv->connection,
+ CK_NAME,
+ ssid,
+ CK_SESSION_INTERFACE,
+ "Unlock",
+ NULL, /* parameters */
+ NULL, /* expected reply */
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (reply == NULL) {
+ g_debug ("GdmManager: ConsoleKit %s raised:\n %s\n\n",
+ g_dbus_error_get_remote_error (error), error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+
+ g_variant_unref (reply);
+
+ return TRUE;
+}
+#endif
+
+static gboolean
+session_unlock (GdmManager *manager,
+ const char *ssid)
+{
+
+ g_debug ("Unlocking session %s", ssid);
+
+#ifdef WITH_SYSTEMD
+ if (LOGIND_RUNNING()) {
+ return session_unlock_for_systemd (manager, ssid);
+ }
+#endif
+
+#ifdef WITH_CONSOLE_KIT
+ return session_unlock_for_ck (manager, ssid);
+#else
+ return TRUE;
+#endif
+}
+
static GdmSession *
find_session_for_user_on_seat (GdmManager *manager,
const char *username,
@@ -374,11 +662,44 @@ find_session_for_user_on_seat (GdmManager *manager,
return NULL;
@@ -375,88 +394,69 @@ find_session_for_user_on_seat (GdmManager *manager,
}
+#ifdef WITH_CONSOLE_KIT
static gboolean
-is_remote_session (GdmManager *self,
- const char *session_id,
- GError **error)
+is_consolekit_remote_session (GdmManager *self,
+ GDBusConnection *connection,
+ const char *session_id,
+ GError **error)
+is_remote_session (GdmManager *self,
+ GDBusConnection *connection,
+ const char *session_id,
+ GError **error)
{
- char *seat;
- int ret;
+ GVariant *reply;
+ gboolean is_remote;
+
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 != -ENXIO) {
- g_debug ("GdmManager: Error while retrieving seat for session %s: %s",
- session_id, strerror (-ret));
+ reply = g_dbus_connection_call_sync (connection,
+ "org.freedesktop.ConsoleKit",
+ session_id,
@ -466,75 +240,48 @@ Index: daemon/gdm-manager.c
+ error);
+ if (reply == NULL) {
+ return FALSE;
+ }
+
}
- if (seat != NULL) {
- is_remote = FALSE;
- free (seat);
- } else {
- is_remote = TRUE;
- }
+ g_variant_get (reply, "(b)", &is_remote);
+ g_variant_unref (reply);
+
+ return is_remote;
+}
+#endif
+
+#ifdef WITH_SYSTEMD
+static gboolean
+is_systemd_remote_session (GdmManager *self,
+ const char *session_id,
+ GError **error)
+{
char *seat;
int ret;
gboolean is_remote;
@@ -403,10 +724,12 @@ is_remote_session (GdmManager *self,
return is_remote;
}
+#endif
+#ifdef WITH_SYSTEMD
static char *
-get_seat_id_for_session_id (const char *session_id,
- GError **error)
+get_seat_id_for_systemd_session_id (const char *session_id,
+ GError **error)
{
int ret;
char *seat, *out_seat;
@@ -431,11 +754,85 @@ get_seat_id_for_session_id (const char *session_id,
return out_seat;
}
+#endif
+static gboolean
+is_remote_session (GdmManager *self,
+ GDBusConnection *connection,
+ const char *session_id,
+ GError **error)
+{
+#ifdef WITH_SYSTEMD
+ if (LOGIND_RUNNING()) {
+ return is_systemd_remote_session (self, session_id, error);
+ }
+#endif
+
+#ifdef WITH_CONSOLE_KIT
+ return is_consolekit_remote_session (self, connection, session_id, error);
+#endif
+
+ return FALSE;
+}
+
+#ifdef WITH_CONSOLE_KIT
static char *
-get_tty_for_session_id (const char *session_id,
- GError **error)
+get_seat_id_for_consolekit_session_id (GDBusConnection *connection,
+ const char *session_id,
+ GError **error)
+get_seat_id_for_session_id (GDBusConnection *connection,
+ const char *session_id,
+ GError **error)
{
- int ret;
- char *seat, *out_seat;
+ GVariant *reply;
+ char *retval;
+
- seat = NULL;
- ret = sd_session_get_seat (session_id, &seat);
-
- 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);
+ reply = g_dbus_connection_call_sync (connection,
+ "org.freedesktop.ConsoleKit",
+ session_id,
@ -548,68 +295,45 @@ Index: daemon/gdm-manager.c
+ error);
+ if (reply == NULL) {
+ return NULL;
+ }
+
}
- return out_seat;
+ g_variant_get (reply, "(o)", &retval);
+ g_variant_unref (reply);
+
+ return retval;
+}
+#endif
+
+static char *
+get_seat_id_for_session_id (GDBusConnection *connection,
+ const char *session_id,
+ GError **error)
+{
+#ifdef WITH_SYSTEMD
+ if (LOGIND_RUNNING()) {
+ return get_seat_id_for_systemd_session_id (session_id, error);
+ }
+#endif
+
+#ifdef WITH_CONSOLE_KIT
+ return get_seat_id_for_consolekit_session_id (connection, session_id, error);
+#endif
+
+ return NULL;
+}
+
+#ifdef WITH_SYSTEMD
+static char *
+get_tty_for_systemd_session_id (const char *session_id,
+ GError **error)
+{
+
+
+
+
int ret;
char *tty, *out_tty;
@@ -458,7 +855,21 @@ get_tty_for_session_id (const char *session_id,
return out_tty;
}
+#endif
+static char *
+get_tty_for_session_id (const char *session_id,
+ GError **error)
+{
+#ifdef WITH_SYSTEMD
+ if (LOGIND_RUNNING()) {
+ return get_tty_for_systemd_session_id (session_id, error);
+ }
+#endif
+
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 == -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;
+ return NULL;
+}
+
}
static void
get_display_and_details_for_bus_sender (GdmManager *self,
GDBusConnection *connection,
@@ -501,11 +912,10 @@ get_display_and_details_for_bus_sender (GdmManager
@@ -501,11 +501,10 @@ get_display_and_details_for_bus_sender (GdmManager
goto out;
}
@ -624,7 +348,7 @@ Index: daemon/gdm-manager.c
error->message);
g_error_free (error);
goto out;
@@ -516,7 +926,7 @@ get_display_and_details_for_bus_sender (GdmManager
@@ -516,7 +515,7 @@ get_display_and_details_for_bus_sender (GdmManager
}
if (out_is_login_screen != NULL) {
@ -633,7 +357,7 @@ Index: daemon/gdm-manager.c
if (error != NULL) {
g_debug ("GdmManager: Error while checking if sender is login screen: %s",
@@ -526,7 +936,7 @@ get_display_and_details_for_bus_sender (GdmManager
@@ -526,7 +525,7 @@ get_display_and_details_for_bus_sender (GdmManager
}
}
@ -642,7 +366,7 @@ Index: daemon/gdm-manager.c
g_debug ("GdmManager: Error while retrieving uid for session: %s",
error->message);
g_error_free (error);
@@ -543,7 +953,7 @@ get_display_and_details_for_bus_sender (GdmManager
@@ -543,7 +542,7 @@ get_display_and_details_for_bus_sender (GdmManager
}
if (out_seat_id != NULL) {
@ -651,7 +375,7 @@ Index: daemon/gdm-manager.c
if (error != NULL) {
g_debug ("GdmManager: Error while retrieving seat id for session: %s",
@@ -553,7 +963,7 @@ get_display_and_details_for_bus_sender (GdmManager
@@ -553,7 +552,7 @@ get_display_and_details_for_bus_sender (GdmManager
}
if (out_is_remote != NULL) {
@ -660,55 +384,7 @@ Index: daemon/gdm-manager.c
if (error != NULL) {
g_debug ("GdmManager: Error while retrieving remoteness for session: %s",
@@ -610,7 +1020,7 @@ switch_to_compatible_user_session (GdmManager *manager
if (existing_session != NULL) {
ssid_to_activate = gdm_session_get_session_id (existing_session);
if (seat_id != NULL) {
- res = gdm_activate_session_by_id (manager->priv->connection, seat_id, ssid_to_activate);
+ res = activate_session_id (manager, seat_id, ssid_to_activate);
if (! res) {
g_debug ("GdmManager: unable to activate session: %s", ssid_to_activate);
goto out;
@@ -712,29 +1122,6 @@ out:
return recorded;
}
-static GdmSession *
-find_user_session_for_display (GdmManager *self,
- GdmDisplay *display)
-{
-
- GList *node = self->priv->user_sessions;
-
- while (node != NULL) {
- GdmSession *session = node->data;
- GdmDisplay *candidate_display;
- GList *next_node = node->next;
-
- candidate_display = get_display_for_user_session (session);
-
- if (candidate_display == display)
- return session;
-
- node = next_node;
- }
-
- return NULL;
-}
-
static gboolean
gdm_manager_handle_register_display (GdmDBusManager *manager,
GDBusMethodInvocation *invocation,
@@ -774,7 +1161,7 @@ gdm_manager_handle_register_display (GdmDBusManager
}
}
- session = find_user_session_for_display (self, display);
+ session = get_user_session_for_display (display);
if (session != NULL) {
GPid pid;
@@ -981,7 +1368,8 @@ on_reauthentication_client_rejected (GdmSession
@@ -981,7 +980,8 @@ on_reauthentication_client_rejected (GdmSession
* same audit session, ignore it since it doesn't "own" the
* reauthentication session
*/
@ -718,40 +394,37 @@ Index: daemon/gdm-manager.c
NULL);
session_id = g_object_get_data (G_OBJECT (session), "caller-session-id");
@@ -1200,16 +1588,19 @@ static gboolean
@@ -1199,18 +1199,7 @@ manager_interface_init (GdmDBusManagerIface *interface
static gboolean
display_is_on_seat0 (GdmDisplay *display)
{
gboolean is_on_seat0 = TRUE;
- gboolean is_on_seat0 = TRUE;
- char *seat_id = NULL;
-
- g_object_get (G_OBJECT (display), "seat-id", &seat_id, NULL);
+#ifdef WITH_SYSTEMD
+ if (LOGIND_RUNNING()) {
+ char *seat_id = NULL;
+ g_object_get (G_OBJECT (display), "seat-id", &seat_id, NULL);
-
- if (g_strcmp0 (seat_id, "seat0") != 0) {
- is_on_seat0 = FALSE;
- }
+ if (g_strcmp0 (seat_id, "seat0") != 0) {
+ is_on_seat0 = FALSE;
+ }
-
- g_free (seat_id);
-
+ g_free (seat_id);
+ }
+#endif
return is_on_seat0;
- return is_on_seat0;
+ return TRUE;
}
@@ -2019,11 +2410,57 @@ on_user_session_died (GdmSession *session,
static gboolean
@@ -2018,12 +2007,44 @@ on_user_session_died (GdmSession *session,
remove_user_session (manager, session);
}
static char *
+query_ck_for_display_device (GdmManager *manager,
+ GdmDisplay *display)
+{
-static char *
+char *
get_display_device (GdmManager *manager,
GdmDisplay *display)
{
- /* systemd finds the display device out on its own based on the display */
- return NULL;
+ char *out;
+ char *command;
+ char *display_name = NULL;
@ -786,48 +459,22 @@ Index: daemon/gdm-manager.c
+ g_free (command);
+
+ return out;
+}
+
+static char *
get_display_device (GdmManager *manager,
GdmDisplay *display)
{
- /* systemd finds the display device out on its own based on the display */
- return NULL;
+#ifdef WITH_SYSTEMD
+ if (LOGIND_RUNNING()) {
+ /* systemd finds the display device out on its own based on the display */
+ return NULL;
+ }
+#endif
+
+ return query_ck_for_display_device (manager, display);
}
static void
@@ -2032,25 +2469,6 @@ on_session_reauthenticated (GdmSession *session,
GdmManager *manager)
@@ -2033,6 +2054,7 @@ on_session_reauthenticated (GdmSession *session,
{
gboolean fail_if_already_switched = FALSE;
-
- if (gdm_session_get_display_mode (session) == GDM_SESSION_DISPLAY_MODE_REUSE_VT) {
- const char *seat_id;
- char *session_id;
-
- seat_id = gdm_session_get_display_seat_id (session);
- 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);
-
- if (display != NULL) {
- gdm_display_stop_greeter_session (display);
- gdm_display_unmanage (display);
- gdm_display_finish (display);
- }
- g_free (session_id);
- }
- }
+#if 0
if (gdm_session_get_display_mode (session) == GDM_SESSION_DISPLAY_MODE_REUSE_VT) {
const char *seat_id;
char *session_id;
@@ -2051,6 +2073,7 @@ on_session_reauthenticated (GdmSession *session,
g_free (session_id);
}
}
+#endif
/* There should already be a session running, so jump to its
* VT. In the event we're already on the right VT, (i.e. user

View File

@ -1,23 +1,12 @@
$OpenBSD: patch-daemon_gdm-server_c,v 1.12 2019/05/08 21:58:04 ajacoutot Exp $
$OpenBSD: patch-daemon_gdm-server_c,v 1.13 2021/05/29 14:02:24 ajacoutot Exp $
Some chunks are part of:
REVERT - OpenBSD lacks sigwaitinfo(2)
From 956d7d1c7a0cfbf2beacdb9e88e645e15ad32047 Mon Sep 17 00:00:00 2001
From: Jasper St. Pierre <jstpierre@mecheye.net>
Date: Fri, 14 Feb 2014 19:32:50 +0000
Subject: server: Process SIGUSR1 more carefully
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 1ac67f522f5690c27023d98096ca817f12f7eb88 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 13:28:01 -0400
Subject: drop consolekit support
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 9be58c9ec9a3a411492a5182ac4b0d51fdc3a323 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 13:48:52 -0400
Subject: require logind support
Index: daemon/gdm-server.c
--- daemon/gdm-server.c.orig
+++ daemon/gdm-server.c
@ -25,7 +14,7 @@ Index: daemon/gdm-server.c
#include <linux/vt.h>
#endif
+#ifdef WITH_SYSTEMD
+#if 0
#include <systemd/sd-daemon.h>
+#endif
@ -39,59 +28,24 @@ Index: daemon/gdm-server.c
gboolean is_initial;
};
@@ -114,90 +117,74 @@ static void gdm_server_finalize (GObject
G_DEFINE_TYPE (GdmServer, gdm_server, G_TYPE_OBJECT)
-char *
-gdm_server_get_display_device (GdmServer *server)
+static char *
+_gdm_server_query_ck_for_display_device (GdmServer *server)
@@ -117,8 +120,36 @@ G_DEFINE_TYPE (GdmServer, gdm_server, G_TYPE_OBJECT)
char *
gdm_server_get_display_device (GdmServer *server)
{
- /* systemd finds the display device out on its own based on the display */
- return NULL;
-}
+ char *out;
+ char *command;
+ int status;
+ gboolean res;
+ GError *error;
-static void
-gdm_server_ready (GdmServer *server)
-{
- g_debug ("GdmServer: Got USR1 from X server - emitting READY");
+
+ g_return_val_if_fail (GDM_IS_SERVER (server), NULL);
- gdm_run_script (GDMCONFDIR "/Init", GDM_USERNAME,
- server->display_name,
- NULL, /* hostname */
- server->auth_file);
+
+ error = NULL;
+ command = g_strdup_printf (CONSOLEKIT_DIR "/ck-get-x11-display-device --display %s",
+ server->display_name);
- g_signal_emit (server, signals[READY], 0);
-}
-
-static GSList *active_servers;
-static gboolean sigusr1_thread_running;
-static GCond sigusr1_thread_cond;
-static GMutex sigusr1_thread_mutex;
-
-static gboolean
-got_sigusr1 (gpointer user_data)
-{
- GPid pid = GPOINTER_TO_UINT (user_data);
- GSList *l;
-
- g_debug ("GdmServer: got SIGUSR1 from PID %d", pid);
-
- for (l = active_servers; l; l = l->next) {
- GdmServer *server = l->data;
-
- if (server->pid == pid)
- gdm_server_ready (server);
+
+ g_debug ("GdmServer: Running helper %s", command);
+ out = NULL;
+ res = g_spawn_command_line_sync (command,
@ -105,176 +59,100 @@ Index: daemon/gdm-server.c
+ } else {
+ out = g_strstrip (out);
+ g_debug ("GdmServer: Got tty: '%s'", out);
}
- return G_SOURCE_REMOVE;
+ }
+
+ g_free (command);
+
+ return out;
}
-static gpointer
-sigusr1_thread_main (gpointer user_data)
+char *
+gdm_server_get_display_device (GdmServer *server)
{
- sigset_t sigusr1_mask;
+#ifdef WITH_SYSTEMD
+ if (LOGIND_RUNNING()) {
+ /* systemd finds the display device out on its own based on the display */
+ return NULL;
+ }
+#endif
static void
@@ -141,22 +172,21 @@ static GMutex sigusr1_thread_mutex;
- /* Handle only SIGUSR1 */
- sigemptyset (&sigusr1_mask);
- sigaddset (&sigusr1_mask, SIGUSR1);
- sigprocmask (SIG_SETMASK, &sigusr1_mask, NULL);
-
- g_mutex_lock (&sigusr1_thread_mutex);
- sigusr1_thread_running = TRUE;
- g_cond_signal (&sigusr1_thread_cond);
- g_mutex_unlock (&sigusr1_thread_mutex);
-
- /* Spin waiting for a SIGUSR1 */
- while (TRUE) {
- siginfo_t info;
-
- if (sigwaitinfo (&sigusr1_mask, &info) == -1)
- continue;
-
- g_idle_add (got_sigusr1, GUINT_TO_POINTER (info.si_pid));
+ if (server->display_device == NULL) {
+ server->display_device =
+ _gdm_server_query_ck_for_display_device (server);
+ g_object_notify (G_OBJECT (server), "display-device");
}
- return NULL;
+ return g_strdup (server->display_device);
}
-static void
-gdm_server_launch_sigusr1_thread_if_needed (void)
+static gboolean
+on_sigusr1 (gpointer user_data)
{
- static GThread *sigusr1_thread;
static gboolean
got_sigusr1 (gpointer user_data)
-{
- GPid pid = GPOINTER_TO_UINT (user_data);
- GSList *l;
+ {
+ GdmServer *server = user_data;
- if (sigusr1_thread == NULL) {
- sigusr1_thread = g_thread_new ("gdm SIGUSR1 catcher", sigusr1_thread_main, NULL);
- g_debug ("GdmServer: got SIGUSR1 from PID %d", pid);
+ g_debug ("GdmServer: Got USR1 from X server - emitting READY");
- g_mutex_lock (&sigusr1_thread_mutex);
- while (!sigusr1_thread_running)
- g_cond_wait (&sigusr1_thread_cond, &sigusr1_thread_mutex);
- g_mutex_unlock (&sigusr1_thread_mutex);
- }
+
+ gdm_run_script (GDMCONFDIR "/Init", GDM_USERNAME,
+ server->display_name,
+ NULL, /* hostname */
+ server->auth_file);
+
- for (l = active_servers; l; l = l->next) {
- GdmServer *server = l->data;
-
- if (server->pid == pid)
- gdm_server_ready (server);
- }
-
- return G_SOURCE_REMOVE;
+ g_signal_emit (server, signals[READY], 0);
+ return FALSE;
}
static void
@@ -218,8 +205,10 @@ gdm_server_init_command (GdmServer *server)
debug_options = "";
+#if 0
static gpointer
sigusr1_thread_main (gpointer user_data)
{
@@ -199,6 +229,7 @@ gdm_server_launch_sigusr1_thread_if_needed (void)
g_mutex_unlock (&sigusr1_thread_mutex);
}
}
+#endif
-#define X_SERVER_ARG_FORMAT " -background none -noreset -verbose %s%s"
+ #define X_SERVER_ARG_FORMAT " -background none -noreset -verbose %s%s"
static void
gdm_server_init_command (GdmServer *server)
@@ -220,6 +251,7 @@ gdm_server_init_command (GdmServer *server)
+#ifdef WITH_SYSTEMD
+
#define X_SERVER_ARG_FORMAT " -background none -noreset -verbose %s%s"
+#if 0
/* This is a temporary hack to work around the fact that XOrg
* currently lacks support for multi-seat hotplugging for
* display devices. This bit should be removed as soon as XOrg
@@ -234,6 +223,10 @@ gdm_server_init_command (GdmServer *server)
* wasn't booted using systemd, or b) the wrapper tool is
* missing, or c) we are running for the main seat 'seat0'. */
+ if (!LOGIND_RUNNING()) {
+ goto fallback;
+ }
+
#ifdef ENABLE_SYSTEMD_JOURNAL
/* For systemd, we don't have a log file but instead log to stdout,
so set it to the xserver's built-in default verbosity */
@@ -256,8 +249,8 @@ gdm_server_init_command (GdmServer *server)
@@ -256,6 +288,7 @@ gdm_server_init_command (GdmServer *server)
return;
fallback:
+#endif
server->command = g_strdup_printf (X_SERVER X_SERVER_ARG_FORMAT, verbosity, debug_options);
-
}
@@ -705,7 +738,9 @@ gdm_server_spawn (GdmServer *server,
prune_active_servers_list,
server);
static gboolean
@@ -307,10 +300,12 @@ gdm_server_resolve_command_line (GdmServer *server,
argv[len++] = g_strdup (server->auth_file);
}
- if (server->display_seat_id != NULL) {
+#ifdef WITH_SYSTEMD
+ if (LOGIND_RUNNING() && server->priv->display_seat_id != NULL) {
argv[len++] = g_strdup ("-seat");
argv[len++] = g_strdup (server->display_seat_id);
}
+#if 0
gdm_server_launch_sigusr1_thread_if_needed ();
+#endif
/* If we were compiled with Xserver >= 1.17 we need to specify
* '-listen tcp' as the X server dosen't listen on tcp sockets
@@ -655,12 +650,6 @@ server_child_watch (GPid pid,
g_object_unref (server);
}
-static void
-prune_active_servers_list (GdmServer *server)
-{
- active_servers = g_slist_remove (active_servers, server);
-}
-
static gboolean
gdm_server_spawn (GdmServer *server,
const char *vtarg,
@@ -698,15 +687,6 @@ gdm_server_spawn (GdmServer *server,
g_debug ("GdmServer: Starting X server process: %s", freeme);
g_free (freeme);
- active_servers = g_slist_append (active_servers, server);
-
- g_object_weak_ref (G_OBJECT (server),
- (GWeakNotify)
- prune_active_servers_list,
- server);
-
- gdm_server_launch_sigusr1_thread_if_needed ();
-
if (!g_spawn_async_with_pipes (NULL,
argv,
(char **)env->pdata,
@@ -1043,6 +1023,10 @@ gdm_server_init (GdmServer *server)
@@ -1043,6 +1078,10 @@ gdm_server_init (GdmServer *server)
server->pid = -1;
server->log_dir = g_strdup (LOGDIR);
+
+ server->sigusr1_id = g_unix_signal_add (SIGUSR1,
+ on_sigusr1,
+ server);
+ got_sigusr1,
+ server);
}
static void
@@ -1054,6 +1038,9 @@ gdm_server_finalize (GObject *object)
g_return_if_fail (GDM_IS_SERVER (object));
@@ -1056,6 +1095,9 @@ gdm_server_finalize (GObject *object)
server = GDM_SERVER (object);
gdm_server_stop (server);
+
+ if (server->sigusr1_id > 0)
+ g_source_remove (server->sigusr1_id);
gdm_server_stop (server);
g_free (server->command);
g_free (server->user_name);

View File

@ -1,18 +1,13 @@
$OpenBSD: patch-daemon_gdm-session-worker-job_c,v 1.1 2015/10/18 13:25:54 ajacoutot Exp $
$OpenBSD: patch-daemon_gdm-session-worker-job_c,v 1.2 2021/05/29 14:02:24 ajacoutot Exp $
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 9be58c9ec9a3a411492a5182ac4b0d51fdc3a323 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 13:48:52 -0400
Subject: require logind support
--- daemon/gdm-session-worker-job.c.orig Mon Sep 21 16:12:33 2015
+++ daemon/gdm-session-worker-job.c Sun Oct 18 14:23:39 2015
Index: daemon/gdm-session-worker-job.c
--- daemon/gdm-session-worker-job.c.orig
+++ daemon/gdm-session-worker-job.c
@@ -36,7 +36,9 @@
#include <sys/prctl.h>
#endif
+#ifdef WITH_SYSTEMD
+#if 0
#include <systemd/sd-daemon.h>
+#endif

View File

@ -1,28 +1,4 @@
$OpenBSD: patch-daemon_gdm-session-worker_c,v 1.23 2021/05/15 15:49:02 ajacoutot Exp $
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 1ac67f522f5690c27023d98096ca817f12f7eb88 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 13:28:01 -0400
Subject: drop consolekit support
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 9be58c9ec9a3a411492a5182ac4b0d51fdc3a323 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 13:48:52 -0400
Subject: require logind support
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From a9cacb929470eb82582396984c61d5b611bfeb1a Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 14:33:40 -0400
Subject: session: drop session-type property
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 6942fb9b16bab7173bbd295fb19a9770289dbe0e Mon Sep 17 00:00:00 2001
From: Tim Lunn <tim@feathertop.org>
Date: Mon, 11 Apr 2016 23:18:10 +1000
Subject: gdm-session: set PAM_TTY when initialising pam
$OpenBSD: patch-daemon_gdm-session-worker_c,v 1.24 2021/05/29 14:02:24 ajacoutot Exp $
Index: daemon/gdm-session-worker.c
--- daemon/gdm-session-worker.c.orig
@ -31,7 +7,7 @@ Index: daemon/gdm-session-worker.c
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
+#ifdef WITH_SYSTEMD
+#if 0
#include <sys/ioctl.h>
#include <sys/vt.h>
#include <sys/kd.h>
@ -43,7 +19,7 @@ Index: daemon/gdm-session-worker.c
#include <X11/Xauth.h>
+#ifdef WITH_SYSTEMD
+#if 0
#include <systemd/sd-daemon.h>
+#endif
@ -58,30 +34,27 @@ Index: daemon/gdm-session-worker.c
#endif
#ifndef GDM_SESSION_ROOT_UID
@@ -126,6 +130,10 @@ struct GdmSessionWorkerPrivate
@@ -126,6 +130,8 @@ struct GdmSessionWorkerPrivate
int exit_code;
+#ifdef WITH_CONSOLE_KIT
+ char *session_cookie;
+#endif
+
pam_handle_t *pam_handle;
GPid child_pid;
@@ -140,6 +148,7 @@ struct GdmSessionWorkerPrivate
char *hostname;
@@ -141,6 +147,7 @@ struct GdmSessionWorkerPrivate
char *username;
char *log_file;
+ char *session_type;
char *session_id;
+ char *session_type;
uid_t uid;
gid_t gid;
@@ -214,6 +223,204 @@ G_DEFINE_TYPE_WITH_CODE (GdmSessionWorker,
gboolean password_is_required;
@@ -214,6 +221,202 @@ G_DEFINE_TYPE_WITH_CODE (GdmSessionWorker,
worker_interface_init)
G_ADD_PRIVATE (GdmSessionWorker))
+#ifdef WITH_CONSOLE_KIT
+static gboolean
+open_ck_session (GdmSessionWorker *worker)
+{
@ -277,30 +250,19 @@ Index: daemon/gdm-session-worker.c
+out:
+ return session_id;
+}
+#endif
+
/* adapted from glib script_execute */
static void
script_execute (const gchar *file,
@@ -665,7 +872,9 @@ gdm_session_worker_process_pam_message (GdmSessionWork
char *user_answer;
gboolean res;
char *utf8_msg;
+#ifdef PAM_RADIO_TYPE
char *msg;
+#endif
if (response != NULL) {
*response = NULL;
@@ -915,6 +1124,7 @@ gdm_session_worker_stop_auditor (GdmSessionWorker *wor
@@ -915,6 +1118,7 @@ gdm_session_worker_stop_auditor (GdmSessionWorker *wor
worker->priv->auditor = NULL;
}
+#ifdef WITH_SYSTEMD
+#if 0
static void
on_release_display (int signal)
{
@@ -1057,6 +1267,7 @@ jump_to_vt (GdmSessionWorker *worker,
@@ -1057,6 +1261,7 @@ jump_to_vt (GdmSessionWorker *worker,
close (active_vt_tty_fd);
}
@ -308,33 +270,24 @@ Index: daemon/gdm-session-worker.c
static void
gdm_session_worker_set_state (GdmSessionWorker *worker,
@@ -1161,7 +1372,6 @@ gdm_session_worker_initialize_pam (GdmSessionWorker
{
struct pam_conv pam_conversation;
int error_code;
- char tty_string[256];
g_assert (worker->priv->pam_handle == NULL);
@@ -1228,10 +1438,12 @@ gdm_session_worker_initialize_pam (GdmSessionWorker
@@ -1228,10 +1433,12 @@ gdm_session_worker_initialize_pam (GdmSessionWorker
}
}
+#ifdef WITH_SYSTEMD
+#if 0
/* set seat ID */
- if (seat_id != NULL && seat_id[0] != '\0') {
+ if (seat_id != NULL && seat_id[0] != '\0' && LOGIND_RUNNING()) {
if (seat_id != NULL && seat_id[0] != '\0') {
gdm_session_worker_set_environment_variable (worker, "XDG_SEAT", seat_id);
}
+#endif
if (strcmp (service, "gdm-launch-environment") == 0) {
gdm_session_worker_set_environment_variable (worker, "XDG_SESSION_CLASS", "greeter");
@@ -1240,12 +1452,14 @@ gdm_session_worker_initialize_pam (GdmSessionWorker
@@ -1240,12 +1447,14 @@ gdm_session_worker_initialize_pam (GdmSessionWorker
g_debug ("GdmSessionWorker: state SETUP_COMPLETE");
gdm_session_worker_set_state (worker, GDM_SESSION_WORKER_STATE_SETUP_COMPLETE);
+#ifdef WITH_SYSTEMD
+#if 0
/* Temporarily set PAM_TTY with the login VT,
PAM_TTY will be reset with the users VT right before the user session is opened */
g_snprintf (tty_string, 256, "/dev/tty%d", GDM_INITIAL_VT);
@ -345,7 +298,7 @@ Index: daemon/gdm-session-worker.c
out:
if (error_code != PAM_SUCCESS) {
@@ -1548,7 +1762,7 @@ _lookup_passwd_info (const char *username,
@@ -1548,7 +1757,7 @@ _lookup_passwd_info (const char *username,
if (passwd_entry->pw_shell != NULL && passwd_entry->pw_shell[0] != '\0') {
*shellp = g_strdup (passwd_entry->pw_shell);
} else {
@ -354,20 +307,13 @@ Index: daemon/gdm-session-worker.c
}
}
ret = TRUE;
@@ -1800,6 +2014,26 @@ gdm_session_worker_get_environment (GdmSessionWorker *
@@ -1800,6 +2009,18 @@ gdm_session_worker_get_environment (GdmSessionWorker *
return (const char * const *) pam_getenvlist (worker->priv->pam_handle);
}
+#ifdef WITH_CONSOLE_KIT
+static void
+register_ck_session (GdmSessionWorker *worker)
+{
+#ifdef WITH_SYSTEMD
+ if (LOGIND_RUNNING()) {
+ return;
+ }
+#endif
+
+ open_ck_session (worker);
+
+ if (worker->priv->session_cookie != NULL) {
@ -376,39 +322,28 @@ Index: daemon/gdm-session-worker.c
+ worker->priv->session_cookie);
+ }
+}
+#endif
+
static gboolean
run_script (GdmSessionWorker *worker,
const char *dir)
@@ -1877,6 +2111,10 @@ session_worker_child_watch (GPid pid,
@@ -1877,6 +2098,8 @@ session_worker_child_watch (GPid pid,
: WIFSIGNALED (status) ? WTERMSIG (status)
: -1);
+#ifdef WITH_CONSOLE_KIT
+ close_ck_session (worker);
+#endif
+
gdm_session_worker_uninitialize_pam (worker, PAM_SUCCESS);
worker->priv->child_pid = -1;
@@ -2000,7 +2238,6 @@ _open_program_session_log (const char *filename)
goto out;
}
-
out:
if (fd < 0) {
g_warning ("unable to log program session");
@@ -2089,6 +2326,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w
@@ -2089,6 +2312,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w
error_code = PAM_SUCCESS;
+#ifdef WITH_SYSTEMD
+#if 0
/* If we're in new vt mode, jump to the new vt now. There's no need to jump for
* the other two modes: in the logind case, the session will activate itself when
* ready, and in the reuse server case, we're already on the correct VT. */
@@ -2097,6 +2335,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w
@@ -2097,6 +2321,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w
jump_to_vt (worker, worker->priv->session_vt);
}
}
@ -416,15 +351,15 @@ Index: daemon/gdm-session-worker.c
if (!worker->priv->is_program_session && !run_script (worker, GDMCONFDIR "/PostLogin")) {
g_set_error (error,
@@ -2159,6 +2398,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w
@@ -2159,6 +2384,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w
_exit (EXIT_FAILURE);
}
+#ifdef WITH_SYSTEMD
+#if 0
/* Take control of the tty
*/
if (needs_controlling_terminal) {
@@ -2166,6 +2406,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w
@@ -2166,6 +2392,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w
g_debug ("GdmSessionWorker: could not take control of tty: %m");
}
}
@ -432,41 +367,15 @@ Index: daemon/gdm-session-worker.c
#ifdef HAVE_LOGINCAP
if (setusercontext (NULL, passwd_entry, passwd_entry->pw_uid, LOGIN_SETALL) < 0) {
@@ -2297,11 +2538,13 @@ gdm_session_worker_start_session (GdmSessionWorker *w
@@ -2297,6 +2524,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w
return TRUE;
}
+#ifdef WITH_SYSTEMD
+#if 0
static gboolean
set_up_for_new_vt (GdmSessionWorker *worker)
{
int initial_vt_fd;
char vt_string[256], tty_string[256];
+ struct vt_stat vt_state = { 0 };
int session_vt = 0;
/* open the initial vt. We need it for two scenarios:
@@ -2319,6 +2562,11 @@ set_up_for_new_vt (GdmSessionWorker *worker)
return FALSE;
}
+ if (ioctl (fd, VT_GETSTATE, &vt_state) < 0) {
+ g_debug ("GdmSessionWorker: couldn't get current VT: %m");
+ goto fail;
+ }
+
if (worker->priv->display_is_initial) {
session_vt = GDM_INITIAL_VT;
} else {
@@ -2332,6 +2580,7 @@ set_up_for_new_vt (GdmSessionWorker *worker)
}
}
+ worker->priv->login_vt = vt_state.v_active;
worker->priv->session_vt = session_vt;
g_assert (session_vt > 0);
@@ -2397,6 +2646,7 @@ fail:
@@ -2397,6 +2625,7 @@ fail:
close (fd);
return FALSE;
}
@ -474,11 +383,11 @@ Index: daemon/gdm-session-worker.c
static gboolean
set_up_for_current_vt (GdmSessionWorker *worker,
@@ -2464,12 +2714,14 @@ set_up_for_current_vt (GdmSessionWorker *worker,
@@ -2464,12 +2693,14 @@ set_up_for_current_vt (GdmSessionWorker *worker,
}
#endif
+#ifdef WITH_SYSTEMD
+#if 0
if (g_strcmp0 (worker->priv->display_seat_id, "seat0") == 0) {
g_debug ("GdmSessionWorker: setting XDG_VTNR to current vt");
set_xdg_vtnr_to_current_vt (worker);
@ -489,15 +398,15 @@ Index: daemon/gdm-session-worker.c
return TRUE;
out:
@@ -2495,6 +2747,7 @@ gdm_session_worker_open_session (GdmSessionWorker *wo
@@ -2495,6 +2726,7 @@ gdm_session_worker_open_session (GdmSessionWorker *wo
break;
case GDM_SESSION_DISPLAY_MODE_NEW_VT:
case GDM_SESSION_DISPLAY_MODE_LOGIND_MANAGED:
+#ifdef WITH_SYSTEMD
+#if 0
if (!set_up_for_new_vt (worker)) {
g_set_error (error,
GDM_SESSION_WORKER_ERROR,
@@ -2502,6 +2755,7 @@ gdm_session_worker_open_session (GdmSessionWorker *wo
@@ -2502,6 +2734,7 @@ gdm_session_worker_open_session (GdmSessionWorker *wo
"Unable to open VT");
return FALSE;
}
@ -505,26 +414,19 @@ Index: daemon/gdm-session-worker.c
break;
}
@@ -2524,8 +2778,18 @@ gdm_session_worker_open_session (GdmSessionWorker *wo
g_debug ("GdmSessionWorker: state SESSION_OPENED");
gdm_session_worker_set_state (worker, GDM_SESSION_WORKER_STATE_SESSION_OPENED);
@@ -2526,6 +2759,11 @@ gdm_session_worker_open_session (GdmSessionWorker *wo
+#ifdef WITH_SYSTEMD
session_id = gdm_session_worker_get_environment_variable (worker, "XDG_SESSION_ID");
+#endif
+#ifdef WITH_CONSOLE_KIT
+ register_ck_session (worker);
+
+ if (session_id == NULL) {
+ session_id = get_ck_session_id (worker);
+ }
+#endif
+
if (session_id != NULL) {
g_free (worker->priv->session_id);
worker->priv->session_id = session_id;
@@ -2634,6 +2898,19 @@ gdm_session_worker_handle_set_session_name (GdmDBusWor
@@ -2634,6 +2872,19 @@ gdm_session_worker_handle_set_session_name (GdmDBusWor
}
static gboolean
@ -544,7 +446,7 @@ Index: daemon/gdm-session-worker.c
gdm_session_worker_handle_set_session_display_mode (GdmDBusWorker *object,
GDBusMethodInvocation *invocation,
const char *str)
@@ -3060,6 +3337,7 @@ gdm_session_worker_handle_open (GdmDBusWorker
@@ -3060,6 +3311,7 @@ gdm_session_worker_handle_open (GdmDBusWorker
return TRUE;
}
@ -552,7 +454,7 @@ Index: daemon/gdm-session-worker.c
static char **
filter_extensions (const char * const *extensions)
{
@@ -3085,6 +3363,7 @@ filter_extensions (const char * const *extensions)
@@ -3085,6 +3337,7 @@ filter_extensions (const char * const *extensions)
return filtered_extensions;
}
@ -560,7 +462,7 @@ Index: daemon/gdm-session-worker.c
static gboolean
gdm_session_worker_handle_initialize (GdmDBusWorker *object,
@@ -3104,8 +3383,10 @@ gdm_session_worker_handle_initialize (GdmDBusWorker
@@ -3104,8 +3357,10 @@ gdm_session_worker_handle_initialize (GdmDBusWorker
while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) {
if (g_strcmp0 (key, "service") == 0) {
worker->priv->service = g_variant_dup_string (value, NULL);
@ -571,7 +473,7 @@ Index: daemon/gdm-session-worker.c
} else if (g_strcmp0 (key, "username") == 0) {
worker->priv->username = g_variant_dup_string (value, NULL);
} else if (g_strcmp0 (key, "is-program-session") == 0) {
@@ -3545,6 +3826,7 @@ worker_interface_init (GdmDBusWorkerIface *interface)
@@ -3545,6 +3800,7 @@ worker_interface_init (GdmDBusWorkerIface *interface)
interface->handle_open = gdm_session_worker_handle_open;
interface->handle_set_language_name = gdm_session_worker_handle_set_language_name;
interface->handle_set_session_name = gdm_session_worker_handle_set_session_name;

View File

@ -1,10 +1,4 @@
$OpenBSD: patch-daemon_gdm-session-worker_xml,v 1.1 2015/10/18 13:25:54 ajacoutot Exp $
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From a9cacb929470eb82582396984c61d5b611bfeb1a Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 14:33:40 -0400
Subject: session: drop session-type property
$OpenBSD: patch-daemon_gdm-session-worker_xml,v 1.2 2021/05/29 14:02:24 ajacoutot Exp $
--- daemon/gdm-session-worker.xml.orig Mon Sep 21 16:12:33 2015
+++ daemon/gdm-session-worker.xml Sun Oct 18 14:23:02 2015

View File

@ -1,32 +1,18 @@
$OpenBSD: patch-daemon_gdm-session_c,v 1.23 2021/05/15 15:49:02 ajacoutot Exp $
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 9be58c9ec9a3a411492a5182ac4b0d51fdc3a323 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 13:48:52 -0400
Subject: require logind support
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From a9cacb929470eb82582396984c61d5b611bfeb1a Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 14:33:40 -0400
Subject: session: drop session-type property
$OpenBSD: patch-daemon_gdm-session_c,v 1.24 2021/05/29 14:02:24 ajacoutot Exp $
Index: daemon/gdm-session.c
--- daemon/gdm-session.c.orig
+++ daemon/gdm-session.c
@@ -3241,6 +3241,10 @@ gdm_session_bypasses_xsession (GdmSession *self)
@@ -3241,6 +3241,8 @@ gdm_session_bypasses_xsession (GdmSession *self)
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (GDM_IS_SESSION (self), FALSE);
+ if (!LOGIND_RUNNING()) {
+ return GDM_SESSION_DISPLAY_MODE_REUSE_VT;
+ }
+ return GDM_SESSION_DISPLAY_MODE_REUSE_VT;
+
#ifdef ENABLE_WAYLAND_SUPPORT
if (gdm_session_is_wayland_session (self)) {
bypasses_xsession = TRUE;
@@ -3333,6 +3337,27 @@ gdm_session_select_program (GdmSession *self,
@@ -3333,6 +3335,27 @@ gdm_session_select_program (GdmSession *self,
g_free (self->selected_program);
self->selected_program = g_strdup (text);

View File

@ -1,10 +1,4 @@
$OpenBSD: patch-daemon_gdm-session_h,v 1.6 2019/11/02 15:34:07 ajacoutot Exp $
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From a9cacb929470eb82582396984c61d5b611bfeb1a Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 14:33:40 -0400
Subject: session: drop session-type property
$OpenBSD: patch-daemon_gdm-session_h,v 1.7 2021/05/29 14:02:24 ajacoutot Exp $
Index: daemon/gdm-session.h
--- daemon/gdm-session.h.orig

View File

@ -1,74 +1,32 @@
$OpenBSD: patch-libgdm_gdm-user-switching_c,v 1.5 2021/05/15 15:49:02 ajacoutot Exp $
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From fcba1e1a5d556ce7b52101dbd2d1ba4a19469161 Mon Sep 17 00:00:00 2001
From: Iain Lane <iain@orangesquash.org.uk>
Date: Fri, 5 Jan 2018 11:53:34 +0000
Subject: [PATCH] manager: Find user's current graphical session, not session of caller
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 1ac67f522f5690c27023d98096ca817f12f7eb88 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 13:28:01 -0400
Subject: drop consolekit support
REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
From 9be58c9ec9a3a411492a5182ac4b0d51fdc3a323 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Jun 2015 13:48:52 -0400
Subject: require logind support
$OpenBSD: patch-libgdm_gdm-user-switching_c,v 1.6 2021/05/29 14:02:24 ajacoutot Exp $
Index: libgdm/gdm-user-switching.c
--- libgdm/gdm-user-switching.c.orig
+++ libgdm/gdm-user-switching.c
@@ -31,12 +31,25 @@
@@ -31,7 +31,9 @@
#include <glib-object.h>
#include <gio/gio.h>
+#ifdef WITH_SYSTEMD
+#if 0
#include <systemd/sd-login.h>
+#endif
#include "common/gdm-common.h"
#include "gdm-user-switching.h"
#include "gdm-client.h"
+#ifdef WITH_CONSOLE_KIT
+#define CK_NAME "org.freedesktop.ConsoleKit"
+#define CK_PATH "/org/freedesktop/ConsoleKit"
+#define CK_INTERFACE "org.freedesktop.ConsoleKit"
+
+#define CK_MANAGER_PATH "/org/freedesktop/ConsoleKit/Manager"
+#define CK_MANAGER_INTERFACE "org.freedesktop.ConsoleKit.Manager"
+#define CK_SEAT_INTERFACE "org.freedesktop.ConsoleKit.Seat"
+#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
+#endif
+
static gboolean
create_transient_display (GDBusConnection *connection,
GCancellable *cancellable,
@@ -67,16 +80,308 @@ create_transient_display (GDBusConnection *connection,
return TRUE;
@@ -68,6 +70,84 @@ create_transient_display (GDBusConnection *connection,
}
+#ifdef WITH_CONSOLE_KIT
+
static gboolean
-activate_session_id (GDBusConnection *connection,
- GCancellable *cancellable,
- const char *seat_id,
- const char *session_id,
- GError **error)
+get_current_session_id (GDBusConnection *connection,
+ char **session_id)
{
+{
+ GError *local_error = NULL;
GVariant *reply;
reply = g_dbus_connection_call_sync (connection,
+ CK_NAME,
+ CK_MANAGER_PATH,
+ CK_MANAGER_INTERFACE,
+ GVariant *reply;
+
+ reply = g_dbus_connection_call_sync (connection,
+ "org.freedesktop.ConsoleKit",
+ "/org/freedesktop/ConsoleKit/Manager",
+ "org.freedesktop.ConsoleKit.Manager",
+ "GetCurrentSession",
+ NULL, /* parameters */
+ G_VARIANT_TYPE ("(o)"),
@ -96,9 +54,9 @@ Index: libgdm/gdm-user-switching.c
+ GVariant *reply;
+
+ reply = g_dbus_connection_call_sync (connection,
+ CK_NAME,
+ "org.freedesktop.ConsoleKit",
+ session_id,
+ CK_SESSION_INTERFACE,
+ "org.freedesktop.ConsoleKit.Session",
+ "GetSeatId",
+ NULL, /* parameters */
+ G_VARIANT_TYPE ("(o)"),
@ -136,48 +94,59 @@ Index: libgdm/gdm-user-switching.c
+ return seat_id;
+}
+
+gboolean
+activate_session_id_for_ck (GDBusConnection *connection,
+ GCancellable *cancellable,
+ const char *seat_id,
+ const char *session_id,
+ GError **error)
+{
+ GVariant *reply;
+
+ reply = g_dbus_connection_call_sync (connection,
+ CK_NAME,
+static gboolean
activate_session_id (GDBusConnection *connection,
GCancellable *cancellable,
const char *seat_id,
@@ -77,15 +157,15 @@ activate_session_id (GDBusConnection *connection,
GVariant *reply;
reply = g_dbus_connection_call_sync (connection,
- "org.freedesktop.login1",
- "/org/freedesktop/login1",
- "org.freedesktop.login1.Manager",
- "ActivateSessionOnSeat",
- g_variant_new ("(ss)", session_id, seat_id),
+ "org.freedesktop.ConsoleKit",
+ seat_id,
+ CK_SEAT_INTERFACE,
+ "org.freedesktop.ConsoleKit.Seat",
+ "ActivateSession",
+ g_variant_new ("(o)", session_id),
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
- cancellable, error);
+ NULL, error);
+ if (reply == NULL) {
+ g_prefix_error (error, _("Unable to activate session: "));
+ return FALSE;
+ }
+
+ g_variant_unref (reply);
+
+ return TRUE;
+}
+
+static gboolean
if (reply == NULL) {
g_prefix_error (error, _("Unable to activate session: "));
return FALSE;
@@ -97,88 +177,137 @@ activate_session_id (GDBusConnection *connection,
}
static gboolean
-get_login_window_session_id (const char *seat_id,
- char **session_id)
+session_is_login_window (GDBusConnection *connection,
+ const char *session_id)
+{
{
- gboolean ret;
- int res, i;
- char **sessions;
- char *service_id;
- char *service_class;
- char *state;
+ GError *local_error = NULL;
+ GVariant *reply;
+ const char *value;
+ gboolean ret;
+
- res = sd_seat_get_sessions (seat_id, &sessions, NULL, NULL);
- if (res < 0) {
- g_debug ("Failed to determine sessions: %s", strerror (-res));
+ reply = g_dbus_connection_call_sync (connection,
+ CK_NAME,
+ "org.freedesktop.ConsoleKit",
+ session_id,
+ CK_SESSION_INTERFACE,
+ "org.freedesktop.ConsoleKit.Session",
+ "GetSessionType",
+ NULL,
+ G_VARIANT_TYPE ("(s)"),
@ -187,22 +156,36 @@ Index: libgdm/gdm-user-switching.c
+ if (reply == NULL) {
+ g_warning ("Unable to determine session type: %s", local_error->message);
+ g_error_free (local_error);
+ return FALSE;
+ }
+
return FALSE;
}
- if (sessions == NULL || sessions[0] == NULL) {
- *session_id = NULL;
+ g_variant_get (reply, "(&s)", &value);
+
+ if (value == NULL || value[0] == '\0' || strcmp (value, "LoginWindow") != 0) {
+ ret = FALSE;
+ } else {
+ ret = TRUE;
+ }
+
ret = TRUE;
- goto out;
}
- for (i = 0; sessions[i]; i ++) {
+ g_variant_unref (reply);
+
- res = sd_session_get_class (sessions[i], &service_class);
- if (res < 0) {
- g_debug ("failed to determine class of session %s: %s", sessions[i], strerror (-res));
- ret = FALSE;
- goto out;
- }
+ return ret;
+}
+
- if (strcmp (service_class, "greeter") != 0) {
- free (service_class);
- continue;
- }
+static gboolean
+seat_can_activate_sessions (GDBusConnection *connection,
+ const char *seat_id)
@ -210,11 +193,12 @@ Index: libgdm/gdm-user-switching.c
+ GError *local_error = NULL;
+ GVariant *reply;
+ gboolean ret;
+
- free (service_class);
+ reply = g_dbus_connection_call_sync (connection,
+ CK_NAME,
+ "org.freedesktop.ConsoleKit",
+ seat_id,
+ CK_SEAT_INTERFACE,
+ "org.freedesktop.ConsoleKit.Seat",
+ "CanActivateSessions",
+ NULL,
+ G_VARIANT_TYPE ("(b)"),
@ -226,13 +210,30 @@ Index: libgdm/gdm-user-switching.c
+ g_error_free (local_error);
+ return FALSE;
+ }
+
- ret = sd_session_get_state (sessions[i], &state);
- if (ret < 0) {
- g_debug ("failed to determine state of session %s: %s", sessions[i], strerror (-res));
- ret = FALSE;
- goto out;
- }
+ g_variant_get (reply, "(b)", &ret);
+ g_variant_unref (reply);
+
- if (g_strcmp0 (state, "closing") == 0) {
- free (state);
- continue;
- }
- free (state);
+ return ret;
+}
+
- res = sd_session_get_service (sessions[i], &service_id);
- if (res < 0) {
- g_debug ("failed to determine service of session %s: %s", sessions[i], strerror (-res));
- ret = FALSE;
- goto out;
- }
+static const char **
+seat_get_sessions (GDBusConnection *connection,
+ const char *seat_id)
@ -240,11 +241,14 @@ Index: libgdm/gdm-user-switching.c
+ GError *local_error = NULL;
+ GVariant *reply;
+ const char **value;
+
- if (strcmp (service_id, "gdm-launch-environment") == 0) {
- *session_id = g_strdup (sessions[i]);
- ret = TRUE;
+ reply = g_dbus_connection_call_sync (connection,
+ CK_NAME,
+ "org.freedesktop.ConsoleKit",
+ seat_id,
+ CK_SEAT_INTERFACE,
+ "org.freedesktop.ConsoleKit.Seat",
+ "GetSessions",
+ NULL,
+ G_VARIANT_TYPE ("(ao)"),
@ -256,33 +260,46 @@ Index: libgdm/gdm-user-switching.c
+ g_error_free (local_error);
+ return FALSE;
+ }
+
- free (service_id);
- goto out;
- }
+ g_variant_get (reply, "(^ao)", &value);
+ g_variant_unref (reply);
+
- free (service_id);
- }
+ return value;
+}
+
+static gboolean
+get_login_window_session_id_for_ck (GDBusConnection *connection,
+ const char *seat_id,
+ char **session_id)
+get_login_window_session_id (GDBusConnection *connection,
+ const char *seat_id,
+ char **session_id)
+{
+ gboolean can_activate_sessions;
+ const char **sessions;
+ int i;
+
+ *session_id = NULL;
*session_id = NULL;
- ret = TRUE;
+ sessions = NULL;
+
-out:
- if (sessions) {
- for (i = 0; sessions[i]; i ++) {
- free (sessions[i]);
- }
+ g_debug ("checking if seat can activate sessions");
+
- free (sessions);
+ can_activate_sessions = seat_can_activate_sessions (connection, seat_id);
+ if (! can_activate_sessions) {
+ g_debug ("seat is unable to activate sessions");
+ return FALSE;
+ }
+
}
- return ret;
+ sessions = seat_get_sessions (connection, seat_id);
+ for (i = 0; sessions [i] != NULL; i++) {
+ const char *ssid;
@ -297,161 +314,72 @@ Index: libgdm/gdm-user-switching.c
+ g_free (sessions);
+
+ return TRUE;
+}
+
+static gboolean
+goto_login_session_for_ck (GDBusConnection *connection,
+ GCancellable *cancellable,
+ GError **error)
+{
+ gboolean ret;
+ gboolean res;
+ char *session_id;
+ char *seat_id;
+
+ ret = FALSE;
+
+ /* First look for any existing LoginWindow sessions on the seat.
+ If none are found, create a new one. */
+
+ seat_id = get_current_seat_id (connection);
+ if (seat_id == NULL || seat_id[0] == '\0') {
+ g_debug ("seat id is not set; can't switch sessions");
+ g_set_error (error, GDM_CLIENT_ERROR, 0, _("Could not identify the current session."));
+
+ return FALSE;
+ }
+
+ res = get_login_window_session_id_for_ck (connection, seat_id, &session_id);
+ if (! res) {
+ g_set_error (error, GDM_CLIENT_ERROR, 0, _("User unable to switch sessions."));
+ return FALSE;
+ }
+
+ if (session_id != NULL) {
+ res = activate_session_id_for_ck (connection, cancellable, seat_id, session_id, error);
+ if (res) {
+ ret = TRUE;
+ }
+ }
+
+ if (! ret && g_strcmp0 (seat_id, "/org/freedesktop/ConsoleKit/Seat1") == 0) {
+ res = create_transient_display (connection, cancellable, error);
+ if (res) {
+ ret = TRUE;
+ }
+ }
+
+ return ret;
+}
+#endif
+
+#ifdef WITH_SYSTEMD
+
+gboolean
+activate_session_id_for_systemd (GDBusConnection *connection,
+ GCancellable *cancellable,
+ const char *seat_id,
+ const char *session_id,
+ GError **error)
+{
+ GVariant *reply;
+
+ reply = g_dbus_connection_call_sync (connection,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
@@ -97,8 +402,8 @@ activate_session_id (GDBusConnection *connection,
}
static gboolean
-get_login_window_session_id (const char *seat_id,
- char **session_id)
+get_login_window_session_id_for_systemd (const char *seat_id,
+ char **session_id)
{
gboolean ret;
int res, i;
@@ -182,16 +487,15 @@ out:
}
static gboolean
-goto_login_session (GDBusConnection *connection,
- GCancellable *cancellable,
- GError **error)
+goto_login_session_for_systemd (GDBusConnection *connection,
+ GCancellable *cancellable,
+ GError **error)
@@ -187,55 +316,42 @@ goto_login_session (GDBusConnection *connection,
GError **error)
{
gboolean ret;
int res;
char *our_session;
- int res;
- char *our_session;
+ gboolean res;
char *session_id;
char *seat_id;
- GError *local_error = NULL;
ret = FALSE;
session_id = NULL;
@@ -203,8 +507,10 @@ goto_login_session (GDBusConnection *connection,
/* Note that we mostly use free () here, instead of g_free ()
* since the data allocated is from libsystemd-logind, which
* does not use GLib's g_malloc (). */
- session_id = NULL;
- seat_id = NULL;
/* First look for any existing LoginWindow sessions on the seat.
If none are found, create a new one. */
- /* Note that we mostly use free () here, instead of g_free ()
- * since the data allocated is from libsystemd-logind, which
- * does not use GLib's g_malloc (). */
- if (!gdm_find_display_session (0, getuid (), &our_session, &local_error)) {
- g_propagate_prefixed_error (error, local_error, _("Could not identify the current session: "));
+ res = sd_pid_get_session (0, &our_session);
+ if (res < 0) {
+ g_debug ("failed to determine own session: %s", strerror (-res));
+ seat_id = get_current_seat_id (connection);
+ if (seat_id == NULL || seat_id[0] == '\0') {
+ g_debug ("seat id is not set; can't switch sessions");
+ g_set_error (error, GDM_CLIENT_ERROR, 0, _("Could not identify the current session."));
return FALSE;
}
@@ -218,9 +524,9 @@ goto_login_session (GDBusConnection *connection,
- res = sd_session_get_seat (our_session, &seat_id);
- free (our_session);
- if (res < 0) {
- g_debug ("failed to determine own seat: %s", strerror (-res));
- g_set_error (error, GDM_CLIENT_ERROR, 0, _("Could not identify the current seat."));
-
+ res = get_login_window_session_id (connection, seat_id, &session_id);
+ if (! res) {
+ g_set_error (error, GDM_CLIENT_ERROR, 0, _("User unable to switch sessions."));
return FALSE;
}
- res = get_login_window_session_id (seat_id, &session_id);
+ res = get_login_window_session_id_for_systemd (seat_id, &session_id);
if (res && session_id != NULL) {
- res = activate_session_id (connection, cancellable, seat_id, session_id, error);
+ res = activate_session_id_for_systemd (connection, cancellable, seat_id, session_id, error);
- if (res && session_id != NULL) {
+ if (session_id != NULL) {
res = activate_session_id (connection, cancellable, seat_id, session_id, error);
-
if (res) {
ret = TRUE;
@@ -239,10 +545,11 @@ goto_login_session (GDBusConnection *connection,
}
}
- if (! ret && g_strcmp0 (seat_id, "seat0") == 0) {
+ if (! ret && g_strcmp0 (seat_id, "/org/freedesktop/ConsoleKit/Seat1") == 0) {
res = create_transient_display (connection, cancellable, error);
if (res) {
ret = TRUE;
}
}
-
- free (seat_id);
- g_free (session_id);
return ret;
}
+#endif
gboolean
gdm_goto_login_session_sync (GCancellable *cancellable,
- GError **error)
+ GError **error)
{
GDBusConnection *connection;
gboolean retval;
@@ -251,8 +558,23 @@ gdm_goto_login_session_sync (GCancellable *cancellabl
if (!connection)
return FALSE;
- retval = goto_login_session (connection, cancellable, error);
+#ifdef WITH_SYSTEMD
+ if (LOGIND_RUNNING()) {
+ retval = goto_login_session_for_systemd (connection,
+ cancellable,
+ error);
+ g_object_unref (connection);
+ return retval;
+ }
+#endif
+
+#ifdef WITH_CONSOLE_KIT
+ retval = goto_login_session_for_ck (connection, cancellable, error);
+
g_object_unref (connection);
return retval;
+#else
+ return FALSE;
+#endif
}

View File

@ -1,9 +1,9 @@
$OpenBSD: patch-pam_gdm_pam_gdm_c,v 1.1 2020/11/08 09:52:01 ajacoutot Exp $
$OpenBSD: patch-pam_gdm_pam_gdm_c,v 1.2 2021/05/29 14:02:24 ajacoutot Exp $
Index: pam_gdm/pam_gdm.c
--- pam_gdm/pam_gdm.c.orig
+++ pam_gdm/pam_gdm.c
@@ -21,11 +21,13 @@
@@ -21,11 +21,15 @@
#include <unistd.h>
@ -11,10 +11,11 @@ Index: pam_gdm/pam_gdm.c
#include <security/_pam_macros.h>
#include <security/pam_ext.h>
#include <security/pam_misc.h>
-#include <security/pam_modules.h>
#include <security/pam_modules.h>
#include <security/pam_modutil.h>
+#endif
+#else
+#include <security/pam_modules.h>
+#endif
#ifdef HAVE_KEYUTILS
#include <keyutils.h>