pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
gdm: take OpenBSD patches
Module Name: pkgsrc-wip
Committed By: coypu <coypu%sdf.org@localhost>
Pushed By: coypu
Date: Tue Feb 23 12:27:26 2016 +0200
Changeset: 9249ad97adb8d071f73fef518784ba4cc5b23e3a
Modified Files:
gdm/Makefile
gdm/distinfo
Added Files:
gdm/patches/patch-common_gdm-address_c
gdm/patches/patch-common_gdm-common_c
gdm/patches/patch-common_gdm-common_h
gdm/patches/patch-common_gdm-log_c
gdm/patches/patch-configure_ac
gdm/patches/patch-daemon_Makefile_am
gdm/patches/patch-daemon_gdm-display_c
gdm/patches/patch-daemon_gdm-launch-environment_c
gdm/patches/patch-daemon_gdm-local-display-factory_c
gdm/patches/patch-daemon_gdm-manager_c
gdm/patches/patch-daemon_gdm-server_c
gdm/patches/patch-daemon_gdm-session-record_c
gdm/patches/patch-daemon_gdm-session-worker-job_c
gdm/patches/patch-daemon_gdm-session-worker_c
gdm/patches/patch-daemon_gdm-session-worker_xml
gdm/patches/patch-daemon_gdm-session_c
gdm/patches/patch-daemon_gdm-session_h
gdm/patches/patch-daemon_main_c
gdm/patches/patch-data_Init_in
gdm/patches/patch-data_Makefile_am
gdm/patches/patch-data_PostSession_in
gdm/patches/patch-data_PreSession_in
gdm/patches/patch-libgdm_gdm-user-switching_c
Log Message:
gdm: take OpenBSD patches
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=9249ad97adb8d071f73fef518784ba4cc5b23e3a
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
gdm/Makefile | 19 +-
gdm/distinfo | 30 +-
gdm/patches/patch-common_gdm-address_c | 28 +
gdm/patches/patch-common_gdm-common_c | 408 ++++++++++++
gdm/patches/patch-common_gdm-common_h | 20 +
gdm/patches/patch-common_gdm-log_c | 48 ++
gdm/patches/patch-configure_ac | 127 ++++
gdm/patches/patch-daemon_Makefile_am | 41 ++
gdm/patches/patch-daemon_gdm-display_c | 24 +
gdm/patches/patch-daemon_gdm-launch-environment_c | 46 ++
.../patch-daemon_gdm-local-display-factory_c | 167 +++++
gdm/patches/patch-daemon_gdm-manager_c | 721 +++++++++++++++++++++
gdm/patches/patch-daemon_gdm-server_c | 288 ++++++++
gdm/patches/patch-daemon_gdm-session-record_c | 141 ++++
gdm/patches/patch-daemon_gdm-session-worker-job_c | 20 +
gdm/patches/patch-daemon_gdm-session-worker_c | 481 ++++++++++++++
gdm/patches/patch-daemon_gdm-session-worker_xml | 20 +
gdm/patches/patch-daemon_gdm-session_c | 55 ++
gdm/patches/patch-daemon_gdm-session_h | 19 +
gdm/patches/patch-daemon_main_c | 39 ++
gdm/patches/patch-data_Init_in | 25 +
gdm/patches/patch-data_Makefile_am | 63 ++
gdm/patches/patch-data_PostSession_in | 12 +
gdm/patches/patch-data_PreSession_in | 12 +
gdm/patches/patch-libgdm_gdm-user-switching_c | 426 ++++++++++++
25 files changed, 3272 insertions(+), 8 deletions(-)
diffs:
diff --git a/gdm/Makefile b/gdm/Makefile
index c1783ed..a73c541 100644
--- a/gdm/Makefile
+++ b/gdm/Makefile
@@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.6 2015/06/06 20:44:44 krytarowski Exp $
#
-DISTNAME= gdm-3.17.2
+DISTNAME= gdm-3.18.2
CATEGORIES= x11 gnome
MASTER_SITES= ${MASTER_SITE_GITHUB:=GNOME/}
@@ -27,7 +27,8 @@ CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR:Q}
CONFIGURE_ARGS+= --with-dmconfdir=${PKG_SYSCONFDIR:Q}/dm
CONFIGURE_ARGS+= --with-sysconfsubdir=
CONFIGURE_ARGS+= --with-prefetch=yes
-CONFIGURE_ARGS+= --with-plymouth=no
+CONFIGURE_ARGS+= --without-plymouth
+CONFIGURE_ARGS+= --without-systemd
CONFIGURE_ARGS+= --disable-systemd-journal
CONFIGURE_ENV+= PREFIX=${PREFIX:Q}
CONFIGURE_ENV+= X11BASE=${X11BASE:Q}
@@ -130,15 +131,23 @@ PLIST.gdmopen= yes
PRINT_PLIST_AWK+= /gdmopen/ { print "$${GDMOPEN}" $$0; next }
pre-configure:
- ${RUN} cd ${WRKSRC} && \
- ${SETENV} ${CONFIGURE_ENV} ${SH} ./autogen.sh NOCONFIGURE=1
-
+ sed -i -e 's,root:root,root:wheel,g' \
+ -e 's,root:gdm,root:676,g' \
+ -e 's,gdm:gdm,676:676,g' ${WRKSRC}/data/Makefile.am
+ sed -i -e 's,/usr/local,${LOCALBASE},g' \
+ -e 's,/bin/bash,/bin/ksh,g' \
+ ${WRKSRC}/daemon/gdm-session-worker.c
+ cd ${WRKSRC} && \
+ ./autogen.sh; \
+ autoreconf -fiv; \
+ intltoolize
post-install:
${INSTALL_DATA} ${FILESDIR}/NetBSD.xpm ${DESTDIR}${PREFIX}/share/pixmaps
${INSTALL_DATA} ${FILESDIR}/custom.desktop \
${DESTDIR}${PREFIX}/share/gdm/BuiltInSessions
.include "../../audio/libcanberra/buildlink3.mk"
+.include "../../textproc/iso-codes/buildlink3.mk"
.include "../../x11/gtk3/buildlink3.mk"
.include "../../wip/accountsservice/buildlink3.mk"
.include "../../devel/gettext-lib/buildlink3.mk"
diff --git a/gdm/distinfo b/gdm/distinfo
index 2641ebf..6655cf3 100644
--- a/gdm/distinfo
+++ b/gdm/distinfo
@@ -1,5 +1,29 @@
$NetBSD: distinfo,v 1.5 2015/06/06 20:00:43 krytarowski Exp $
-SHA1 (gdm-3.17.2.tar.gz) = 0d03cce39a025c3e9c972949f76a0ff0e473b25c
-RMD160 (gdm-3.17.2.tar.gz) = 4041dac5baa53fd5244f1c8931a79e556805f919
-Size (gdm-3.17.2.tar.gz) = 2552713 bytes
+SHA1 (gdm-3.18.2.tar.gz) = f62a3fd116198d1ac500d64d00380a4bb6da3de9
+RMD160 (gdm-3.18.2.tar.gz) = 06eb2e9a1d90b06def795d3c1dd02ea3fe0a027e
+SHA512 (gdm-3.18.2.tar.gz) = d0806010a1575880a9f108fdefe0bb68d40c64c9ff9307fa3718a93125d95293e16f9c44e6041723132a0630db09df37e54f8b2996c940458b73c71848725215
+Size (gdm-3.18.2.tar.gz) = 2603925 bytes
+SHA1 (patch-common_gdm-address_c) = 194c2ccb1404709d2cb78cdaded93258bfec74f3
+SHA1 (patch-common_gdm-common_c) = 4ce512da501f37c98c397dc29b375e90c41e845e
+SHA1 (patch-common_gdm-common_h) = 4d2b59d14aac48af055bb805ee4d4533a1e2b674
+SHA1 (patch-common_gdm-log_c) = 7f3b809a082a17b9d6d05b4bcc6f3d623860bd47
+SHA1 (patch-configure_ac) = c2696cedeee73ef3e8f8fb8b7a20c0211bf06e74
+SHA1 (patch-daemon_Makefile_am) = 45e1bdaada5241a488c4d3bb1a4f538f22483a30
+SHA1 (patch-daemon_gdm-display_c) = d24d91aeb8e7e85980b45cc084fc4dc6f81aa938
+SHA1 (patch-daemon_gdm-launch-environment_c) = 712c3dc71101970bbaca2ff36d5a0226d82f58c2
+SHA1 (patch-daemon_gdm-local-display-factory_c) = 7e9e3aab79d5067be8c219408e7a591cfe9af38a
+SHA1 (patch-daemon_gdm-manager_c) = b8429ff15331586e8dfa72c6d6691203029b9d46
+SHA1 (patch-daemon_gdm-server_c) = 283d327c96269b7d2722a15ca9dd33c7ca9210aa
+SHA1 (patch-daemon_gdm-session-record_c) = b62d5cf03c7f6c6bbf2b948a939bfd62cd82ae1d
+SHA1 (patch-daemon_gdm-session-worker-job_c) = 1c067b09637f96e7e997bdfbada6eb61ec760cda
+SHA1 (patch-daemon_gdm-session-worker_c) = ab54b035f669ffc536aa91a5a2786b1e3aed7d36
+SHA1 (patch-daemon_gdm-session-worker_xml) = d6b97526777bc6bf374069cfd11c1370c6bb1ac6
+SHA1 (patch-daemon_gdm-session_c) = 6b7b7173e2b5f678616f5b22e5f7288b2f0a6c70
+SHA1 (patch-daemon_gdm-session_h) = 026c361633566413f7a07135683596feb9f9ad09
+SHA1 (patch-daemon_main_c) = 10342344290dfe27b93d0b5b620861e7af8026d1
+SHA1 (patch-data_Init_in) = 9df2fcf45c138fd3bd392964b6f7dd514e31bcad
+SHA1 (patch-data_Makefile_am) = 699bf0cbb3a8e9f4886985b6880c47230e613bc5
+SHA1 (patch-data_PostSession_in) = 3a8e66f8ae2839a54955aa8a25f51f3a26cbe791
+SHA1 (patch-data_PreSession_in) = 598d10822c2d9e0600a684c29a7b2a2f5e14d10d
+SHA1 (patch-libgdm_gdm-user-switching_c) = 861d676eb6f4a2c94c85993d49f7ee71643b7af1
diff --git a/gdm/patches/patch-common_gdm-address_c b/gdm/patches/patch-common_gdm-address_c
new file mode 100644
index 0000000..9c60698
--- /dev/null
+++ b/gdm/patches/patch-common_gdm-address_c
@@ -0,0 +1,28 @@
+$OpenBSD: patch-common_gdm-address_c,v 1.1 2011/09/12 07:39:21 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>
+
diff --git a/gdm/patches/patch-common_gdm-common_c b/gdm/patches/patch-common_gdm-common_c
new file mode 100644
index 0000000..0440414
--- /dev/null
+++ b/gdm/patches/patch-common_gdm-common_c
@@ -0,0 +1,408 @@
+$OpenBSD: patch-common_gdm-common_c,v 1.4 2015/10/18 13:25:54 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@localhost>
+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@localhost>
+Date: Fri, 12 Jun 2015 13:28:01 -0400
+Subject: drop consolekit support
+
+--- common/gdm-common.c.orig 2015-11-17 17:16:04.000000000 +0000
++++ common/gdm-common.c
+@@ -39,12 +39,25 @@
+ #include "mkdtemp.h"
+ #endif
+
++#ifdef WITH_SYSTEMD
+ #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);
+
+ const char *
+@@ -343,10 +356,301 @@ create_transient_display (GDBusConnectio
+ return TRUE;
+ }
+
++#ifdef WITH_CONSOLE_KIT
++
++static gboolean
++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;
++}
++
++static gboolean
++activate_session_id_for_ck (GDBusConnection *connection,
++ const char *seat_id,
++ const char *session_id)
++{
++ GError *local_error = NULL;
++ GVariant *reply;
++
++ reply = g_dbus_connection_call_sync (connection,
++ CK_NAME,
++ seat_id,
++ CK_SEAT_INTERFACE,
++ "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
+-activate_session_id (GDBusConnection *connection,
+- const char *seat_id,
+- const char *session_id)
++session_is_login_window (GDBusConnection *connection,
++ const char *session_id)
++{
++ GError *local_error = NULL;
++ GVariant *reply;
++ const char *value;
++ gboolean ret;
++
++ reply = g_dbus_connection_call_sync (connection,
++ CK_NAME,
++ session_id,
++ CK_SESSION_INTERFACE,
++ "GetSessionType",
++ NULL,
++ G_VARIANT_TYPE ("(s)"),
++ G_DBUS_CALL_FLAGS_NONE,
++ -1,
++ NULL, &local_error);
++ if (reply == NULL) {
++ g_warning ("Unable to determine session type: %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;
++ }
++
++ g_variant_unref (reply);
++
++ return ret;
++}
++
++static gboolean
++seat_can_activate_sessions (GDBusConnection *connection,
++ const char *seat_id)
++{
++ GError *local_error = NULL;
++ GVariant *reply;
++ gboolean ret;
++
++ reply = g_dbus_connection_call_sync (connection,
++ CK_NAME,
++ seat_id,
++ CK_SEAT_INTERFACE,
++ "CanActivateSessions",
++ NULL,
++ G_VARIANT_TYPE ("(b)"),
++ G_DBUS_CALL_FLAGS_NONE,
++ -1,
++ NULL, &local_error);
++ if (reply == NULL) {
++ g_warning ("Unable to determine if can activate sessions: %s", local_error->message);
++ g_error_free (local_error);
++ return FALSE;
++ }
++
++ g_variant_get (reply, "(b)", &ret);
++ g_variant_unref (reply);
++
++ return ret;
++}
++
++static const char **
++seat_get_sessions (GDBusConnection *connection,
++ const char *seat_id)
++{
++ GError *local_error = NULL;
++ GVariant *reply;
++ const char **value;
++
++ reply = g_dbus_connection_call_sync (connection,
++ CK_NAME,
++ seat_id,
++ CK_SEAT_INTERFACE,
++ "GetSessions",
++ NULL,
++ G_VARIANT_TYPE ("(ao)"),
++ G_DBUS_CALL_FLAGS_NONE,
++ -1,
++ NULL, &local_error);
++ if (reply == NULL) {
++ g_warning ("Unable to list sessions: %s", local_error->message);
++ g_error_free (local_error);
++ return FALSE;
++ }
++
++ g_variant_get (reply, "(^ao)", &value);
++ g_variant_unref (reply);
++
++ return value;
++}
++
++static gboolean
++get_login_window_session_id_for_ck (GDBusConnection *connection,
++ const char *seat_id,
++ char **session_id)
++{
++ gboolean can_activate_sessions;
++ const char **sessions;
++ int i;
++
++ *session_id = NULL;
++ sessions = NULL;
++
++ g_debug ("checking if seat can activate 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;
++ }
++
++ sessions = seat_get_sessions (connection, seat_id);
++ for (i = 0; sessions [i] != NULL; i++) {
++ const char *ssid;
++
++ ssid = sessions [i];
++
++ if (session_is_login_window (connection, ssid)) {
++ *session_id = g_strdup (ssid);
++ break;
++ }
++ }
++ g_free (sessions);
++
++ 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
++
++static gboolean
++activate_session_id_for_systemd (GDBusConnection *connection,
++ const char *seat_id,
++ const char *session_id)
+ {
+ GError *local_error = NULL;
+ GVariant *reply;
+@@ -373,8 +677,8 @@ activate_session_id (GDBusConnection *co
+ }
+
+ 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;
+@@ -442,8 +746,8 @@ out:
+ }
+
+ static gboolean
+-goto_login_session (GDBusConnection *connection,
+- GError **error)
++goto_login_session_for_systemd (GDBusConnection *connection,
++ GError **error)
+ {
+ gboolean ret;
+ int res;
+@@ -497,9 +801,9 @@ goto_login_session (GDBusConnection *co
+ 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, seat_id, session_id);
++ res = activate_session_id_for_systemd (connection, seat_id, session_id);
+
+ if (res) {
+ ret = TRUE;
+@@ -518,6 +822,7 @@ goto_login_session (GDBusConnection *co
+
+ return ret;
+ }
++#endif
+
+ gboolean
+ gdm_goto_login_session (GError **error)
+@@ -533,7 +838,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
diff --git a/gdm/patches/patch-common_gdm-common_h b/gdm/patches/patch-common_gdm-common_h
new file mode 100644
index 0000000..474ac27
--- /dev/null
+++ b/gdm/patches/patch-common_gdm-common_h
@@ -0,0 +1,20 @@
+$OpenBSD: patch-common_gdm-common_h,v 1.1 2015/10/18 13:25:54 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@localhost>
+Date: Fri, 12 Jun 2015 13:48:52 -0400
+Subject: require logind support
+
+--- common/gdm-common.h.orig Mon Sep 21 16:12:33 2015
++++ common/gdm-common.h Sun Oct 18 14:23:39 2015
+@@ -33,6 +33,9 @@
+
+ #define GDM_CUSTOM_SESSION "custom"
+
++/* check if logind is running */
++#define LOGIND_RUNNING() (access("/run/systemd/seats/", F_OK) >= 0)
++
+ GQuark gdm_common_error_quark (void);
+ #define GDM_COMMON_ERROR gdm_common_error_quark()
+
diff --git a/gdm/patches/patch-common_gdm-log_c b/gdm/patches/patch-common_gdm-log_c
new file mode 100644
index 0000000..d198230
--- /dev/null
+++ b/gdm/patches/patch-common_gdm-log_c
@@ -0,0 +1,48 @@
+$OpenBSD: patch-common_gdm-log_c,v 1.1 2015/10/18 13:25:54 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@localhost>
+Date: Fri, 12 Jun 2015 13:48:52 -0400
+Subject: require logind support
+
+--- common/gdm-log.c.orig Mon Sep 21 16:12:33 2015
++++ common/gdm-log.c Sun Oct 18 14:23:39 2015
+@@ -30,7 +30,9 @@
+ #include <unistd.h>
+
+ #include <syslog.h>
++#ifdef WITH_SYSTEMD
+ #include <systemd/sd-daemon.h>
++#endif
+
+ #include <glib.h>
+ #include <glib/gstdio.h>
+@@ -133,7 +135,27 @@ gdm_log_init (void)
+
+ 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
diff --git a/gdm/patches/patch-configure_ac b/gdm/patches/patch-configure_ac
new file mode 100644
index 0000000..8d9277e
--- /dev/null
+++ b/gdm/patches/patch-configure_ac
@@ -0,0 +1,127 @@
+$OpenBSD: patch-configure_ac,v 1.7 2015/10/18 13:25:54 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@localhost>
+Date: Fri, 12 Jun 2015 13:28:01 -0400
+Subject: drop consolekit support
+
+https://bugzilla.gnome.org/show_bug.cgi?id=722482
+
+--- configure.ac.orig 2015-11-17 17:16:04.000000000 +0000
++++ configure.ac
+@@ -244,7 +244,15 @@ AC_ARG_WITH(tcp-wrappers,
+ [Use TCP Wrappers @<:@default=auto@:>@]),,
+ with_tcp_wrappers=auto)
+
+-
++AC_ARG_WITH(console-kit,
++ AS_HELP_STRING([--with-console-kit],
++ [Add ConsoleKit support @<:@default=auto@:>@]),,
++ with_console_kit=no)
++
++AC_ARG_WITH(systemd,
++ AS_HELP_STRING([--with-systemd],
++ [Add systemd support @<:@default=auto@:>@]),
++ [with_systemd=$withval], [with_systemd=auto])
+ AC_ARG_WITH([systemdsystemunitdir],
+ AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
+ [Directory for systemd service files]),
+@@ -614,14 +622,8 @@ dnl ------------------------------------
+ dnl - Check for utmp stuff
+ dnl ---------------------------------------------------------------------------
+
+-AC_CHECK_HEADERS(utmp.h utmpx.h libutil.h sys/param.h)
+-AC_CHECK_FUNCS([getutxent updwtmpx updwtmp])
+-AC_CHECK_LIB(util, login, [
+- AC_DEFINE(HAVE_LOGIN, 1, [Define if have login])
+- EXTRA_DAEMON_LIBS="$EXTRA_DAEMON_LIBS -lutil" ])
+-AC_CHECK_LIB(util, logout, [
+- AC_DEFINE(HAVE_LOGOUT, 1, [Define if have logout])
+- EXTRA_DAEMON_LIBS="$EXTRA_DAEMON_LIBS -lutil" ])
++AC_CHECK_HEADERS(utmp.h utmpx.h util.h sys/param.h)
++AC_CHECK_FUNCS([getutxent getttyent updwtmpx updwtmp])
+ AC_CHECK_LIB(util, logwtmp, [
+ AC_DEFINE(HAVE_LOGWTMP, 1, [Define if have logwtmp])
+ EXTRA_DAEMON_LIBS="$EXTRA_DAEMON_LIBS -lutil" ])
+@@ -870,12 +872,42 @@ AC_SUBST(XINERAMA_LIBS)
+ CPPFLAGS="$xinerama_save_cppflags"
+
+ dnl ---------------------------------------------------------------------------
++dnl - Check for ConsoleKit support
++dnl ---------------------------------------------------------------------------
++
++use_console_kit=no
++if test "x$with_console_kit" != "xno" ; then
++ use_console_kit=yes
++ AC_DEFINE(WITH_CONSOLE_KIT, 1, [Define to enable ConsoleKit support])
++fi
++AM_CONDITIONAL(WITH_CONSOLE_KIT, test x$use_console_kit = xyes)
++AC_SUBST(WITH_CONSOLE_KIT)
++
++dnl ---------------------------------------------------------------------------
+ dnl - Check for systemd support
+ dnl ---------------------------------------------------------------------------
+
+ PKG_CHECK_MODULES(SYSTEMD,
+- [libsystemd])
++ [libsystemd-login >= 186 libsystemd-daemon],
++ [have_systemd=yes], [have_systemd=no])
+
++if test "x$with_systemd" = "xauto" ; then
++ if test x$have_systemd = xno ; then
++ use_systemd=no
++ else
++ use_systemd=yes
++ fi
++else
++ use_systemd="$with_systemd"
++fi
++
++if test "x$use_systemd" != "xno" ; then
++ if test "x$have_systemd" = "xno"; then
++ AC_MSG_ERROR([Systemd support explicitly required, but systemd not found])
++ fi
++
++ AC_DEFINE(WITH_SYSTEMD, 1, [Define to enable systemd support])
++fi
+ AC_SUBST(SYSTEMD_CFLAGS)
+ AC_SUBST(SYSTEMD_LIBS)
+
+@@ -1068,6 +1100,14 @@ fi
+ AC_SUBST(GDM_CUSTOM_CONF)
+ AC_SUBST(GDM_OLD_CONF, '${gdmconfdir}/gdm.conf')
+
++AC_ARG_WITH(consolekit-directory,
++ [AC_HELP_STRING([--with-consolekit-directory],
++ [Specify the directory of ck-get-x11-display-device @<:@default=libexecdir@:>@])],,
++ [with_consolekit_directory="\${libexecdir}"])
++
++CONSOLEKIT_DIR=$with_consolekit_directory
++AC_SUBST(CONSOLEKIT_DIR)
++
+ AC_ARG_WITH(gnome-settings-daemon-directory,
+ [AC_HELP_STRING([--with-gnome-settings-daemon-directory],
+ [Specify the directory of gnome-settings-daemon used by the chooser @<:@default=libexecdir@:>@])],,
+@@ -1549,6 +1589,7 @@ echo "
+ dmconfdir: ${dmconfdir}
+ localstatedir: ${localstatedir}
+ datadir: ${datadir}
++ consolekit location: ${with_consolekit_directory}
+ gnome-settings-daemon location: ${with_gnome_settings_daemon_directory}
+ gnome-session-check-accel location: ${with_check_accelerated_directory}
+ source code location: ${srcdir}
+@@ -1578,6 +1619,8 @@ echo \
+ " Xinerama support: ${XINERAMA_SUPPORT}
+ XDMCP support: ${XDMCP_SUPPORT}
+ SELinux support: ${use_selinux}
++ ConsoleKit support: ${use_console_kit}
++ systemd support: ${use_systemd}
+ systemd unit dir: ${with_systemdsystemunitdir}
+ plymouth support: ${use_plymouth}
+ wayland support: ${use_wayland}
+@@ -1586,3 +1629,4 @@ echo \
+ Enable documentation: ${enable_documentation}
+ Install GDM's Xsession: ${enable_gdm_xsession}
+ "
++
diff --git a/gdm/patches/patch-daemon_Makefile_am b/gdm/patches/patch-daemon_Makefile_am
new file mode 100644
index 0000000..4e14e0e
--- /dev/null
+++ b/gdm/patches/patch-daemon_Makefile_am
@@ -0,0 +1,41 @@
+$OpenBSD: patch-daemon_Makefile_am,v 1.1 2015/10/18 13:25:54 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@localhost>
+Date: Fri, 12 Jun 2015 13:28:01 -0400
+Subject: drop consolekit support
+
+--- daemon/Makefile.am.orig 2015-11-17 17:16:04.000000000 +0000
++++ daemon/Makefile.am
+@@ -20,6 +20,7 @@ AM_CPPFLAGS = \
+ -DGDM_SCREENSHOT_DIR=\"$(GDM_SCREENSHOT_DIR)\" \
+ -DGDM_CACHE_DIR=\""$(localstatedir)/cache/gdm"\" \
+ -DGDM_SESSION_DEFAULT_PATH=\"$(GDM_SESSION_DEFAULT_PATH)\" \
++ -DCONSOLEKIT_DIR=\"$(CONSOLEKIT_DIR)\" \
+ $(DISABLE_DEPRECATED_CFLAGS) \
+ $(DAEMON_CFLAGS) \
+ $(XLIB_CFLAGS) \
+@@ -264,6 +265,11 @@ EXTRA_gdm_SOURCES = \
+ $(XDMCP_SOURCES) \
+ $(NULL)
+
++CONSOLE_KIT_SOURCES = \
++ $(NULL)
++
++EXTRA_gdm_SOURCES += $(CONSOLE_KIT_SOURCES)
++
+ gdm_LDADD = \
+ $(top_builddir)/common/libgdmcommon.la \
+ $(XLIB_LIBS) \
+@@ -275,6 +281,10 @@ gdm_LDADD = \
+ $(EXTRA_DAEMON_LIBS) \
+ $(NULL)
+
++if WITH_CONSOLE_KIT
++gdm_SOURCES += $(CONSOLE_KIT_SOURCES)
++endif
++
+ CLEANFILES = \
+ gdm-display-glue.c \
+ gdm-local-display-factory-glue.c \
diff --git a/gdm/patches/patch-daemon_gdm-display_c b/gdm/patches/patch-daemon_gdm-display_c
new file mode 100644
index 0000000..4f4c769
--- /dev/null
+++ b/gdm/patches/patch-daemon_gdm-display_c
@@ -0,0 +1,24 @@
+$OpenBSD: patch-daemon_gdm-display_c,v 1.1 2015/04/03 18:39:06 ajacoutot Exp $
+
+XXX fix+push upstream
+
+--- daemon/gdm-display.c.orig Fri Apr 3 20:26:42 2015
++++ daemon/gdm-display.c Fri Apr 3 20:27:20 2015
+@@ -50,7 +50,7 @@
+ #include "gdm-dbus-util.h"
+ #include "gdm-xerrors.h"
+
+-#define INITIAL_SETUP_USERNAME "gnome-initial-setup"
++#define INITIAL_SETUP_USERNAME "_gnome-initial-setup"
+ #define GNOME_SESSION_SESSIONS_PATH DATADIR "/gnome-session/sessions"
+
+ #define GDM_DISPLAY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_DISPLAY, GdmDisplayPrivate))
+@@ -307,7 +307,7 @@ setup_xhost_auth (XHostAddress *host_entr
+ si_entries[1].value = GDM_USERNAME;
+ si_entries[1].valuelength = strlen (GDM_USERNAME);
+ si_entries[2].value = "gnome-initial-setup";
+- si_entries[2].valuelength = strlen ("gnome-initial-setup");
++ si_entries[2].valuelength = strlen ("_gnome-initial-setup");
+
+ host_entries[0].family = FamilyServerInterpreted;
+ host_entries[0].address = (char *) &si_entries[0];
diff --git a/gdm/patches/patch-daemon_gdm-launch-environment_c b/gdm/patches/patch-daemon_gdm-launch-environment_c
new file mode 100644
index 0000000..c63cfe3
--- /dev/null
+++ b/gdm/patches/patch-daemon_gdm-launch-environment_c
@@ -0,0 +1,46 @@
+$OpenBSD: patch-daemon_gdm-launch-environment_c,v 1.6 2015/10/18 13:25:54 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@localhost>
+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@localhost>
+Date: Fri, 12 Jun 2015 14:33:40 -0400
+Subject: session: drop session-type property
+
+--- daemon/gdm-launch-environment.c.orig Sun Oct 18 14:26:32 2015
++++ daemon/gdm-launch-environment.c Sun Oct 18 14:24:34 2015
+@@ -50,7 +50,7 @@
+ #include "gdm-settings-direct.h"
+ #include "gdm-settings-keys.h"
+
+-#define INITIAL_SETUP_USERNAME "gnome-initial-setup"
++#define INITIAL_SETUP_USERNAME "_gnome-initial-setup"
+ #define GNOME_SESSION_SESSIONS_PATH DATADIR "/gnome-session/sessions"
+
+ extern char **environ;
+@@ -176,6 +176,9 @@ build_launch_environment (GdmLaunchEnvironment *launch
+ char *seat_id;
+
+ seat_id = launch_environment->priv->x11_display_seat_id;
++ if (g_str_has_prefix (seat_id, "/org/freedesktop/ConsoleKit/")) {
++ seat_id += strlen ("/org/freedesktop/ConsoleKit/");
++ }
+
+ g_hash_table_insert (hash, g_strdup ("GDM_SEAT_ID"), g_strdup (seat_id));
+ }
+@@ -204,6 +207,8 @@ on_session_setup_complete (GdmSession *session,
+ gdm_session_set_environment_variable (launch_environment->priv->session, key, value);
+ }
+ g_hash_table_destroy (hash);
++
++ gdm_session_select_session_type (launch_environment->priv->session, "LoginWindow");
+ }
+
+ static void
diff --git a/gdm/patches/patch-daemon_gdm-local-display-factory_c b/gdm/patches/patch-daemon_gdm-local-display-factory_c
new file mode 100644
index 0000000..cf8c218
--- /dev/null
+++ b/gdm/patches/patch-daemon_gdm-local-display-factory_c
@@ -0,0 +1,167 @@
+$OpenBSD: patch-daemon_gdm-local-display-factory_c,v 1.3 2015/10/18 13:25:54 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@localhost>
+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@localhost>
+Date: Fri, 12 Jun 2015 13:48:52 -0400
+Subject: require logind support
+
+--- daemon/gdm-local-display-factory.c.orig 2015-11-17 17:16:04.000000000 +0000
++++ daemon/gdm-local-display-factory.c
+@@ -42,6 +42,7 @@
+
+ #define GDM_LOCAL_DISPLAY_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_LOCAL_DISPLAY_FACTORY, GdmLocalDisplayFactoryPrivate))
+
++#define CK_SEAT1_PATH "/org/freedesktop/ConsoleKit/Seat1"
+ #define SYSTEMD_SEAT0_PATH "seat0"
+
+ #define GDM_DBUS_PATH "/org/gnome/DisplayManager"
+@@ -59,8 +60,10 @@ struct GdmLocalDisplayFactoryPrivate
+ /* FIXME: this needs to be per seat? */
+ guint num_failures;
+
++#ifdef WITH_SYSTEMD
+ guint seat_new_id;
+ guint seat_removed_id;
++#endif
+ };
+
+ enum {
+@@ -190,8 +193,20 @@ store_display (GdmLocalDisplayFactory *f
+ static const char *
+ get_seat_of_transient_display (GdmLocalDisplayFactory *factory)
+ {
++ const char *seat_id = NULL;
++
+ /* FIXME: don't hardcode seat */
+- return SYSTEMD_SEAT0_PATH;
++#ifdef WITH_SYSTEMD
++ if (LOGIND_RUNNING() > 0) {
++ seat_id = SYSTEMD_SEAT0_PATH;
++ }
++#endif
++
++ if (seat_id == NULL) {
++ seat_id = CK_SEAT1_PATH;
++ }
++
++ return seat_id;
+ }
+
+ /*
+@@ -216,7 +231,19 @@ gdm_local_display_factory_create_transie
+
+ g_debug ("GdmLocalDisplayFactory: Creating transient display");
+
+- display = gdm_local_display_new ();
++#ifdef WITH_SYSTEMD
++ if (LOGIND_RUNNING() > 0) {
++ display = gdm_local_display_new ();
++ }
++#endif
++
++ if (display == NULL) {
++ guint32 num;
++
++ num = take_next_display_number (factory);
++
++ display = gdm_legacy_display_new (num);
++ }
+
+ seat_id = get_seat_of_transient_display (factory);
+ g_object_set (display,
+@@ -290,7 +317,7 @@ on_display_status_changed (GdmDisplay
+ /* reset num failures */
+ factory->priv->num_failures = 0;
+
+- gdm_local_display_factory_sync_seats (factory);
++ create_display (factory, seat_id, session_type, is_initial);
+ }
+ break;
+ case GDM_DISPLAY_FAILED:
+@@ -372,12 +399,14 @@ create_display (GdmLocalDisplayFactory *
+ g_debug ("GdmLocalDisplayFactory: Adding display on seat %s", seat_id);
+
+
++#ifdef WITH_SYSTEMD
+ if (g_strcmp0 (seat_id, "seat0") == 0) {
+ display = gdm_local_display_new ();
+ if (session_type != NULL) {
+ g_object_set (G_OBJECT (display), "session-type", session_type, NULL);
+ }
+ }
++#endif
+
+ if (display == NULL) {
+ guint32 num;
+@@ -402,6 +431,8 @@ create_display (GdmLocalDisplayFactory *
+ return display;
+ }
+
++#ifdef WITH_SYSTEMD
++
+ static void
+ delete_display (GdmLocalDisplayFactory *factory,
+ const char *seat_id) {
+@@ -538,6 +569,7 @@ gdm_local_display_factory_stop_monitor (
+ factory->priv->seat_removed_id = 0;
+ }
+ }
++#endif
+
+ static void
+ on_display_added (GdmDisplayStore *display_store,
+@@ -576,6 +608,7 @@ static gboolean
+ gdm_local_display_factory_start (GdmDisplayFactory *base_factory)
+ {
+ GdmLocalDisplayFactory *factory = GDM_LOCAL_DISPLAY_FACTORY (base_factory);
++ GdmDisplay *display;
+ GdmDisplayStore *store;
+
+ g_return_val_if_fail (GDM_IS_LOCAL_DISPLAY_FACTORY (factory), FALSE);
+@@ -592,8 +625,17 @@ gdm_local_display_factory_start (GdmDisp
+ G_CALLBACK (on_display_removed),
+ factory);
+
+- 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. */
++ display = create_display (factory, CK_SEAT1_PATH, NULL, TRUE);
++
++ return display != NULL;
+ }
+
+ static gboolean
+@@ -604,7 +646,9 @@ gdm_local_display_factory_stop (GdmDispl
+
+ 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));
+
+@@ -760,7 +804,9 @@ gdm_local_display_factory_finalize (GObj
+
+ g_hash_table_destroy (factory->priv->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);
+ }
diff --git a/gdm/patches/patch-daemon_gdm-manager_c b/gdm/patches/patch-daemon_gdm-manager_c
new file mode 100644
index 0000000..b908848
--- /dev/null
+++ b/gdm/patches/patch-daemon_gdm-manager_c
@@ -0,0 +1,721 @@
+$OpenBSD: patch-daemon_gdm-manager_c,v 1.9 2015/10/18 13:25:54 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@localhost>
+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@localhost>
+Date: Fri, 12 Jun 2015 13:48:52 -0400
+Subject: require logind support
+
+--- daemon/gdm-manager.c.orig 2015-11-17 17:16:04.000000000 +0000
++++ daemon/gdm-manager.c
+@@ -34,7 +34,9 @@
+ #include <glib/gstdio.h>
+ #include <glib-object.h>
+
++#ifdef WITH_SYSTEMD
+ #include <systemd/sd-login.h>
++#endif
+
+ #include "gdm-common.h"
+
+@@ -57,7 +59,16 @@
+ #define GDM_MANAGER_PATH GDM_DBUS_PATH "/Manager"
+ #define GDM_MANAGER_DISPLAYS_PATH GDM_DBUS_PATH "/Displays"
+
+-#define INITIAL_SETUP_USERNAME "gnome-initial-setup"
++#define INITIAL_SETUP_USERNAME "_gnome-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
+ {
+@@ -202,9 +213,10 @@ 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)
+ {
+ char *session, *gsession;
+ int ret;
+@@ -229,11 +241,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)
++{
++ GVariant *reply;
++ char *retval;
++
++ reply = g_dbus_connection_call_sync (connection,
++ "org.freedesktop.ConsoleKit",
++ "/org/freedesktop/ConsoleKit/Manager",
++ "org.freedesktop.ConsoleKit.Manager",
++ "GetSessionForUnixProcess",
++ g_variant_new ("(u)", pid),
++ G_VARIANT_TYPE ("(o)"),
++ G_DBUS_CALL_FLAGS_NONE,
++ -1,
++ NULL, error);
++ if (reply == NULL) {
++ return NULL;
++ }
++
++ g_variant_get (reply, "(o)", &retval);
++ g_variant_unref (reply);
++
++ 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)
+ {
+ int ret;
+
+@@ -250,6 +312,60 @@ get_uid_for_session_id (const char *ses
+
+ 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)
++{
++ GVariant *reply;
++ guint32 uid;
++
++ reply = g_dbus_connection_call_sync (connection,
++ "org.freedesktop.ConsoleKit",
++ session_id,
++ "org.freedesktop.ConsoleKit.Session",
++ "GetUnixUser",
++ NULL,
++ G_VARIANT_TYPE ("(u)"),
++ G_DBUS_CALL_FLAGS_NONE,
++ -1,
++ NULL,
++ error);
++ if (reply == NULL) {
++ 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,
+@@ -263,10 +379,50 @@ lookup_by_session_id (const char *id,
+ return g_strcmp0 (current, looking_for) == 0;
+ }
+
++#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)
++{
++ GVariant *reply;
++ char *session_type = NULL;
++
++ reply = g_dbus_connection_call_sync (connection,
++ "org.freedesktop.ConsoleKit",
++ session_id,
++ "org.freedesktop.ConsoleKit.Session",
++ "GetSessionType",
++ NULL,
++ G_VARIANT_TYPE ("(s)"),
++ G_DBUS_CALL_FLAGS_NONE,
++ -1,
++ NULL,
++ error);
++ if (reply == NULL) {
++ return FALSE;
++ }
++
++ 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;
+@@ -291,11 +447,32 @@ is_login_session (GdmManager *self,
+ g_free (session_class);
+ return TRUE;
+ }
++#endif
+
+ static gboolean
+-activate_session_id (GdmManager *manager,
+- const char *seat_id,
+- const char *session_id)
++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)
+ {
+ GError *error = NULL;
+ GVariant *reply;
+@@ -322,15 +499,74 @@ activate_session_id (GdmManager *manager
+
+ return TRUE;
+ }
++#endif
+
++#ifdef WITH_CONSOLE_KIT
+ static gboolean
+-session_unlock (GdmManager *manager,
+- const char *ssid)
++activate_session_id_for_ck (GdmManager *manager,
++ const char *seat_id,
++ const char *session_id)
+ {
+ GError *error = NULL;
+ GVariant *reply;
+
+- g_debug ("Unlocking session %s", ssid);
++ 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_SYSTEMD
++static gboolean
++session_unlock_for_systemd (GdmManager *manager,
++ const char *ssid)
++{
++ GError *error = NULL;
++ GVariant *reply;
+
+ reply = g_dbus_connection_call_sync (manager->priv->connection,
+ "org.freedesktop.login1",
+@@ -354,6 +590,59 @@ session_unlock (GdmManager *manager,
+
+ return TRUE;
+ }
++#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,
+@@ -385,10 +674,43 @@ find_session_for_user_on_seat (GdmManage
+ return NULL;
+ }
+
++#ifdef WITH_CONSOLE_KIT
++static gboolean
++is_consolekit_remote_session (GdmManager *self,
++ GDBusConnection *connection,
++ const char *session_id,
++ GError **error)
++{
++ GVariant *reply;
++ gboolean is_remote;
++
++ reply = g_dbus_connection_call_sync (connection,
++ "org.freedesktop.ConsoleKit",
++ session_id,
++ "org.freedesktop.ConsoleKit.Session",
++ "IsLocal",
++ NULL,
++ G_VARIANT_TYPE ("(b)"),
++ G_DBUS_CALL_FLAGS_NONE,
++ -1,
++ NULL,
++ error);
++ if (reply == NULL) {
++ return FALSE;
++ }
++
++ g_variant_get (reply, "(b)", &is_remote);
++ g_variant_unref (reply);
++
++ return is_remote;
++}
++#endif
++
++#ifdef WITH_SYSTEMD
+ static gboolean
+-is_remote_session (GdmManager *self,
+- const char *session_id,
+- GError **error)
++is_systemd_remote_session (GdmManager *self,
++ const char *session_id,
++ GError **error)
+ {
+ char *seat;
+ int ret;
+@@ -414,10 +736,31 @@ is_remote_session (GdmManager *self,
+
+ return is_remote;
+ }
++#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_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;
+@@ -442,10 +785,61 @@ get_seat_id_for_session_id (const char
+
+ return out_seat;
+ }
++#endif
+
++#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)
++{
++ GVariant *reply;
++ char *retval;
++
++ reply = g_dbus_connection_call_sync (connection,
++ "org.freedesktop.ConsoleKit",
++ session_id,
++ "org.freedesktop.ConsoleKit.Session",
++ "GetSeatId",
++ NULL,
++ G_VARIANT_TYPE ("(o)"),
++ G_DBUS_CALL_FLAGS_NONE,
++ -1,
++ NULL,
++ error);
++ if (reply == NULL) {
++ return NULL;
++ }
++
++ 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;
+@@ -469,6 +863,20 @@ get_tty_for_session_id (const char *ses
+
+ 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
++
++ return NULL;
++}
+
+ static void
+ get_display_and_details_for_bus_sender (GdmManager *self,
+@@ -512,7 +920,7 @@ get_display_and_details_for_bus_sender (
+ goto out;
+ }
+
+- session_id = get_session_id_for_pid (pid, &error);
++ session_id = get_session_id_for_pid (connection, pid, &error);
+
+ if (session_id == NULL) {
+ g_debug ("GdmManager: Error while retrieving session id for sender: %s",
+@@ -526,7 +934,7 @@ get_display_and_details_for_bus_sender (
+ }
+
+ if (out_is_login_screen != NULL) {
+- *out_is_login_screen = is_login_session (self, session_id, &error);
++ *out_is_login_screen = is_login_session (self, connection, session_id, &error);
+
+ if (error != NULL) {
+ g_debug ("GdmManager: Error while checking if sender is login screen: %s",
+@@ -536,7 +944,7 @@ get_display_and_details_for_bus_sender (
+ }
+ }
+
+- if (!get_uid_for_session_id (session_id, &session_uid, &error)) {
++ if (!get_uid_for_session_id (connection, session_id, &session_uid, &error)) {
+ g_debug ("GdmManager: Error while retrieving uid for session: %s",
+ error->message);
+ g_error_free (error);
+@@ -553,7 +961,7 @@ get_display_and_details_for_bus_sender (
+ }
+
+ if (out_seat_id != NULL) {
+- *out_seat_id = get_seat_id_for_session_id (session_id, &error);
++ *out_seat_id = get_seat_id_for_session_id (connection, session_id, &error);
+
+ if (error != NULL) {
+ g_debug ("GdmManager: Error while retrieving seat id for session: %s",
+@@ -563,7 +971,7 @@ get_display_and_details_for_bus_sender (
+ }
+
+ if (out_is_remote != NULL) {
+- *out_is_remote = is_remote_session (self, session_id, &error);
++ *out_is_remote = is_remote_session (self, connection, session_id, &error);
+
+ if (error != NULL) {
+ g_debug ("GdmManager: Error while retrieving remoteness for session: %s",
+@@ -927,7 +1335,8 @@ on_reauthentication_client_rejected (Gdm
+ * same audit session, ignore it since it doesn't "own" the
+ * reauthentication session
+ */
+- client_session_id = get_session_id_for_pid (pid_of_client,
++ client_session_id = get_session_id_for_pid (self->priv->connection,
++ pid_of_client,
+ NULL);
+ session_id = g_object_get_data (G_OBJECT (session), "caller-session-id");
+
+@@ -1139,16 +1548,20 @@ static gboolean
+ display_is_on_seat0 (GdmDisplay *display)
+ {
+ 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;
+
+- if (g_strcmp0 (seat_id, "seat0") != 0) {
+- is_on_seat0 = FALSE;
+- }
++ g_object_get (G_OBJECT (display), "seat-id", &seat_id, NULL);
+
+- g_free (seat_id);
++ if (g_strcmp0 (seat_id, "seat0") != 0) {
++ is_on_seat0 = FALSE;
++ }
+
++ g_free (seat_id);
++ }
++#endif
+ return is_on_seat0;
+ }
+
+@@ -1749,11 +2162,57 @@ on_user_session_died (GdmSession *sessio
+ }
+
+ static char *
++query_ck_for_display_device (GdmManager *manager,
++ GdmDisplay *display)
++{
++ char *out;
++ char *command;
++ char *display_name = NULL;
++ int status;
++ gboolean res;
++ GError *error;
++
++ g_object_get (G_OBJECT (display),
++ "x11-display-name", &display_name,
++ NULL);
++
++ error = NULL;
++ command = g_strdup_printf (CONSOLEKIT_DIR "/ck-get-x11-display-device --display %s",
++ display_name);
++ g_free (display_name);
++
++ g_debug ("GdmManager: Running helper %s", command);
++ out = NULL;
++ res = g_spawn_command_line_sync (command,
++ &out,
++ NULL,
++ &status,
++ &error);
++ if (! res) {
++ g_warning ("GdmManager: Could not run helper %s: %s", command, error->message);
++ g_error_free (error);
++ } else {
++ out = g_strstrip (out);
++ g_debug ("GdmManager: Got tty: '%s'", out);
++ }
++
++ 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
diff --git a/gdm/patches/patch-daemon_gdm-server_c b/gdm/patches/patch-daemon_gdm-server_c
new file mode 100644
index 0000000..16f98d4
--- /dev/null
+++ b/gdm/patches/patch-daemon_gdm-server_c
@@ -0,0 +1,288 @@
+$OpenBSD: patch-daemon_gdm-server_c,v 1.7 2015/10/18 13:25:54 ajacoutot Exp $
+
+REVERT - OpenBSD lacks sigwaitinfo(2)
+From 956d7d1c7a0cfbf2beacdb9e88e645e15ad32047 Mon Sep 17 00:00:00 2001
+From: Jasper St. Pierre <jstpierre%mecheye.net@localhost>
+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@localhost>
+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@localhost>
+Date: Fri, 12 Jun 2015 13:48:52 -0400
+Subject: require logind support
+
+--- daemon/gdm-server.c.orig 2015-11-17 17:16:04.000000000 +0000
++++ daemon/gdm-server.c
+@@ -43,7 +43,9 @@
+ #include <linux/vt.h>
+ #endif
+
++#ifdef WITH_SYSTEMD
+ #include <systemd/sd-daemon.h>
++#endif
+
+ #ifdef ENABLE_SYSTEMD_JOURNAL
+ #include <systemd/sd-journal.h>
+@@ -92,6 +94,7 @@ struct GdmServerPrivate
+ char *auth_file;
+
+ guint child_watch_id;
++ guint sigusr1_id;
+
+ gboolean is_initial;
+ };
+@@ -122,90 +125,76 @@ static void gdm_server_finalize
+
+ 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;
+-}
+-
+-static void
+-gdm_server_ready (GdmServer *server)
++static char *
++_gdm_server_query_ck_for_display_device (GdmServer *server)
+ {
+- g_debug ("GdmServer: Got USR1 from X server - emitting READY");
++ char *out;
++ char *command;
++ int status;
++ gboolean res;
++ GError *error;
++
++ g_return_val_if_fail (GDM_IS_SERVER (server), NULL);
++
++ error = NULL;
++ command = g_strdup_printf (CONSOLEKIT_DIR "/ck-get-x11-display-device --display %s",
++ server->priv->display_name);
++
++ g_debug ("GdmServer: Running helper %s", command);
++ out = NULL;
++ res = g_spawn_command_line_sync (command,
++ &out,
++ NULL,
++ &status,
++ &error);
++ if (! res) {
++ g_warning ("Could not run helper: %s", error->message);
++ g_error_free (error);
++ } else {
++ out = g_strstrip (out);
++ g_debug ("GdmServer: Got tty: '%s'", out);
++ }
+
+- gdm_run_script (GDMCONFDIR "/Init", GDM_USERNAME,
+- server->priv->display_name,
+- NULL, /* hostname */
+- server->priv->auth_file);
++ g_free (command);
+
+- g_signal_emit (server, signals[READY], 0);
++ return out;
+ }
+
+-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)
++char *
++gdm_server_get_display_device (GdmServer *server)
+ {
+- 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->priv->pid == pid)
+- gdm_server_ready (server);
++#ifdef WITH_SYSTEMD
++ if (LOGIND_RUNNING()) {
++ /* systemd finds the display device out on its own based on the display */
++ return NULL;
+ }
++#endif
+
+- return G_SOURCE_REMOVE;
+-}
+-
+-static gpointer
+-sigusr1_thread_main (gpointer user_data)
+-{
+- sigset_t sigusr1_mask;
+-
+- /* 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;
++ if (server->priv->display_device == NULL) {
++ server->priv->display_device =
++ _gdm_server_query_ck_for_display_device (server);
+
+- g_idle_add (got_sigusr1, GUINT_TO_POINTER (info.si_pid));
++ g_object_notify (G_OBJECT (server), "display-device");
+ }
+
+- return NULL;
++ return g_strdup (server->priv->display_device);
+ }
+
+-static void
+-gdm_server_launch_sigusr1_thread_if_needed (void)
++static gboolean
++on_sigusr1 (gpointer user_data)
++
+ {
+- static GThread *sigusr1_thread;
++ GdmServer *server = user_data;
+
+- if (sigusr1_thread == NULL) {
+- sigusr1_thread = g_thread_new ("gdm SIGUSR1 catcher", sigusr1_thread_main, NULL);
++ 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->priv->display_name,
++ NULL, /* hostname */
++ server->priv->auth_file);
++
++ g_signal_emit (server, signals[READY], 0);
++ return FALSE;
+ }
+
+ static void
+@@ -226,7 +215,9 @@ gdm_server_init_command (GdmServer *serv
+ debug_options = "";
+ }
+
+-#define X_SERVER_ARG_FORMAT " -background none -noreset -verbose %s%s"
++ #define X_SERVER_ARG_FORMAT " -background none -noreset -verbose %s%s"
++
++#ifdef WITH_SYSTEMD
+
+ /* This is a temporary hack to work around the fact that XOrg
+ * currently lacks support for multi-seat hotplugging for
+@@ -242,6 +233,10 @@ gdm_server_init_command (GdmServer *serv
+ * 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 */
+@@ -264,8 +259,9 @@ gdm_server_init_command (GdmServer *serv
+ return;
+
+ fallback:
+- server->priv->command = g_strdup_printf (X_SERVER X_SERVER_ARG_FORMAT, verbosity, debug_options);
++#endif
+
++ server->priv->command = g_strdup_printf (X_SERVER X_SERVER_ARG_FORMAT, verbosity, debug_options);
+ }
+
+ static gboolean
+@@ -315,10 +311,12 @@ gdm_server_resolve_command_line (GdmServ
+ argv[len++] = g_strdup (server->priv->auth_file);
+ }
+
+- if (server->priv->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->priv->display_seat_id);
+ }
++#endif
+
+ if (server->priv->disable_tcp && ! query_in_arglist) {
+ argv[len++] = g_strdup ("-nolisten");
+@@ -650,12 +648,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,
+@@ -693,15 +685,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,
+@@ -1037,11 +1020,16 @@ gdm_server_class_init (GdmServerClass *k
+ static void
+ gdm_server_init (GdmServer *server)
+ {
++
+ server->priv = GDM_SERVER_GET_PRIVATE (server);
+
+ server->priv->pid = -1;
+
+ server->priv->log_dir = g_strdup (LOGDIR);
++
++ server->priv->sigusr1_id = g_unix_signal_add (SIGUSR1,
++ on_sigusr1,
++ server);
+ }
+
+ static void
+@@ -1056,6 +1044,9 @@ gdm_server_finalize (GObject *object)
+
+ g_return_if_fail (server->priv != NULL);
+
++ if (server->priv->sigusr1_id > 0)
++ g_source_remove (server->priv->sigusr1_id);
++
+ gdm_server_stop (server);
+
+ g_free (server->priv->command);
diff --git a/gdm/patches/patch-daemon_gdm-session-record_c b/gdm/patches/patch-daemon_gdm-session-record_c
new file mode 100644
index 0000000..e1bb491
--- /dev/null
+++ b/gdm/patches/patch-daemon_gdm-session-record_c
@@ -0,0 +1,141 @@
+$OpenBSD: patch-daemon_gdm-session-record_c,v 1.7 2015/10/18 13:25:54 ajacoutot Exp $
+
+https://bugzilla.gnome.org/show_bug.cgi?id=722482
+
+--- daemon/gdm-session-record.c.orig Sun Oct 18 14:14:52 2015
++++ daemon/gdm-session-record.c Sun Oct 18 14:18:27 2015
+@@ -33,6 +33,16 @@
+ #include <utmp.h>
+ #endif
+
++#if defined(HAVE_UTIL_H)
++#include <util.h>
++#endif
++
++#if defined(HAVE_GETTTYENT)
++#include <fcntl.h> /* open(2) */
++#include <ttyent.h>
++static int fd = -1;
++#endif
++
+ #include <glib.h>
+ #include <glib/gi18n.h>
+ #include <glib/gstdio.h>
+@@ -43,6 +53,9 @@
+ #define GDM_BAD_SESSION_RECORDS_FILE "/var/log/btmp"
+ #endif
+
++static void write_utmp_login_manually (struct utmp *ut);
++static void write_utmp_logout_manually (char *);
++
+ #if !defined(GDM_NEW_SESSION_RECORDS_FILE)
+ # if defined(WTMPX_FILE)
+ # define GDM_NEW_SESSION_RECORDS_FILE WTMPX_FILE
+@@ -183,6 +196,84 @@ record_set_line (UTMP *u,
+ g_debug ("using ut_line %.*s", (int) sizeof (u->ut_line), u->ut_line);
+ }
+
++static void
++write_utmp_login_manually (struct utmp *ut)
++{
++#if defined(HAVE_GETTTYENT) && defined(HAVE_UTMP_H)
++ UTMP ubuf;
++ int topslot = -1;
++
++ g_debug ("Adding new utmp record");
++
++ /*
++ * First, loop through /etc/ttys, if needed, to initialize the
++ * top of the tty slots, since gdm has no tty.
++ */
++ if (topslot < 0) {
++ topslot = 0;
++ while (getttyent () != (struct ttyent *) NULL)
++ topslot++;
++ }
++ if ((topslot < 0) || ((fd < 0) &&
++ (fd = open (_PATH_UTMP, O_RDWR|O_CREAT, 0644)) < 0))
++ return;
++
++ /*
++ * Now find a slot that's not in use...
++ */
++ (void) lseek (fd, (off_t) (topslot * sizeof (struct utmp)), SEEK_SET);
++
++ while (1) {
++ if (read (fd, &ubuf, sizeof (struct utmp)) ==
++ sizeof (struct utmp)) {
++ if (!ubuf.ut_name[0]) {
++ (void) lseek (fd, -(off_t) sizeof (struct utmp),
++ SEEK_CUR);
++ break;
++ }
++ topslot++;
++ } else {
++ (void) lseek (fd, (off_t) (topslot *
++ sizeof (struct utmp)), SEEK_SET);
++ break;
++ }
++ }
++
++ (void) write (fd, ut, sizeof (struct utmp));
++#endif
++}
++
++static void
++write_utmp_logout_manually (char *line)
++{
++#if defined(HAVE_GETTTYENT) && defined(HAVE_UTMP_H)
++ int rval = 1;
++ struct timeval tv;
++ UTMP ut;
++
++ g_debug ("Removing utmp record");
++
++ if (fd >= 0) {
++ (void) lseek (fd, 0, SEEK_SET);
++ while (read (fd, &ut, sizeof (struct utmp)) == sizeof (struct utmp)) {
++ if (!ut.ut_name[0] ||
++ strncmp (ut.ut_line, line, UT_LINESIZE))
++ continue;
++ bzero (ut.ut_name, UT_NAMESIZE);
++ bzero (ut.ut_host, UT_HOSTSIZE);
++ gettimeofday (&tv, NULL);
++ ut.ut_time = tv.tv_sec;
++ (void) lseek (fd, -(off_t) sizeof (struct utmp), SEEK_CUR);
++ (void) write (fd, &ut, sizeof (struct utmp));
++ rval = 0;
++ }
++ }
++
++ if (rval != 0)
++ g_debug ("Failed to remove utmp record");
++#endif
++}
++
+ void
+ gdm_session_record_login (GPid session_pid,
+ const char *user_name,
+@@ -227,8 +318,9 @@ gdm_session_record_login (GPid sessio
+ #if defined(HAVE_GETUTXENT)
+ g_debug ("Adding or updating utmp record for login");
+ pututxline (&session_record);
+-#elif defined(HAVE_LOGIN)
+- login (&session_record);
++#else
++ if (strcmp (session_record.ut_name, "(unknown)") != 0)
++ write_utmp_login_manually (&session_record);
+ #endif
+ }
+
+@@ -270,8 +362,8 @@ gdm_session_record_logout (GPid sessi
+ #if defined(HAVE_GETUTXENT)
+ g_debug ("Adding or updating utmp record for logout");
+ pututxline (&session_record);
+-#elif defined(HAVE_LOGOUT)
+- logout (session_record.ut_line);
++#else
++ write_utmp_logout_manually (session_record.ut_line);
+ #endif
+ }
+
diff --git a/gdm/patches/patch-daemon_gdm-session-worker-job_c b/gdm/patches/patch-daemon_gdm-session-worker-job_c
new file mode 100644
index 0000000..cd7f6b0
--- /dev/null
+++ b/gdm/patches/patch-daemon_gdm-session-worker-job_c
@@ -0,0 +1,20 @@
+$OpenBSD: patch-daemon_gdm-session-worker-job_c,v 1.1 2015/10/18 13:25:54 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@localhost>
+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
+@@ -36,7 +36,9 @@
+ #include <sys/prctl.h>
+ #endif
+
++#ifdef WITH_SYSTEMD
+ #include <systemd/sd-daemon.h>
++#endif
+
+ #ifdef ENABLE_SYSTEMD_JOURNAL
+ #include <systemd/sd-journal.h>
diff --git a/gdm/patches/patch-daemon_gdm-session-worker_c b/gdm/patches/patch-daemon_gdm-session-worker_c
new file mode 100644
index 0000000..8482eac
--- /dev/null
+++ b/gdm/patches/patch-daemon_gdm-session-worker_c
@@ -0,0 +1,481 @@
+$OpenBSD: patch-daemon_gdm-session-worker_c,v 1.10 2015/10/18 13:25:54 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@localhost>
+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@localhost>
+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@localhost>
+Date: Fri, 12 Jun 2015 14:33:40 -0400
+Subject: session: drop session-type property
+
+--- daemon/gdm-session-worker.c.orig 2015-11-17 17:16:04.000000000 +0000
++++ daemon/gdm-session-worker.c
+@@ -28,9 +28,11 @@
+ #include <string.h>
+ #include <sys/types.h>
+ #include <sys/wait.h>
++#ifdef WITH_SYSTEMD
+ #include <sys/ioctl.h>
+ #include <sys/vt.h>
+ #include <sys/kd.h>
++#endif
+ #include <errno.h>
+ #include <grp.h>
+ #include <pwd.h>
+@@ -49,7 +51,9 @@
+
+ #include <X11/Xauth.h>
+
++#ifdef WITH_SYSTEMD
+ #include <systemd/sd-daemon.h>
++#endif
+
+ #ifdef ENABLE_SYSTEMD_JOURNAL
+ #include <systemd/sd-journal.h>
+@@ -88,7 +92,7 @@
+ #endif
+
+ #ifndef GDM_SESSION_DEFAULT_PATH
+-#define GDM_SESSION_DEFAULT_PATH "/usr/local/bin:/usr/bin:/bin"
++#define GDM_SESSION_DEFAULT_PATH "/usr/pkg/bin:/usr/bin:/bin"
+ #endif
+
+ #ifndef GDM_SESSION_ROOT_UID
+@@ -131,6 +135,10 @@ struct GdmSessionWorkerPrivate
+
+ int exit_code;
+
++#ifdef WITH_CONSOLE_KIT
++ char *session_cookie;
++#endif
++
+ pam_handle_t *pam_handle;
+
+ GPid child_pid;
+@@ -145,6 +153,7 @@ struct GdmSessionWorkerPrivate
+ char *hostname;
+ char *username;
+ char *log_file;
++ char *session_type;
+ char *session_id;
+ uid_t uid;
+ gid_t gid;
+@@ -207,6 +216,204 @@ G_DEFINE_TYPE_WITH_CODE (GdmSessionWorke
+ G_IMPLEMENT_INTERFACE (GDM_DBUS_TYPE_WORKER,
+ worker_interface_init))
+
++#ifdef WITH_CONSOLE_KIT
++static gboolean
++open_ck_session (GdmSessionWorker *worker)
++{
++ GDBusConnection *system_bus;
++ GVariantBuilder builder;
++ GVariant *parameters;
++ GVariant *in_args;
++ struct passwd *pwent;
++ GVariant *reply;
++ GError *error = NULL;
++ const char *display_name;
++ const char *display_device;
++ const char *display_hostname;
++ const char *session_type;
++ gint32 uid;
++
++ g_assert (worker->priv->session_cookie == NULL);
++
++ if (worker->priv->x11_display_name != NULL) {
++ display_name = worker->priv->x11_display_name;
++ } else {
++ display_name = "";
++ }
++ if (worker->priv->hostname != NULL) {
++ display_hostname = worker->priv->hostname;
++ } else {
++ display_hostname = "";
++ }
++ if (worker->priv->display_device != NULL) {
++ display_device = worker->priv->display_device;
++ } else {
++ display_device = "";
++ }
++
++ if (worker->priv->session_type != NULL) {
++ session_type = worker->priv->session_type;
++ } else {
++ session_type = "";
++ }
++
++ g_assert (worker->priv->username != NULL);
++
++ gdm_get_pwent_for_name (worker->priv->username, &pwent);
++ if (pwent == NULL) {
++ goto out;
++ }
++
++ uid = (gint32) pwent->pw_uid;
++
++ error = NULL;
++ system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
++
++ if (system_bus == NULL) {
++ g_warning ("Couldn't create connection to system bus: %s",
++ error->message);
++
++ g_error_free (error);
++ goto out;
++ }
++
++ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(sv)"));
++ g_variant_builder_add_parsed (&builder, "('unix-user', <%i>)", uid);
++ g_variant_builder_add_parsed (&builder, "('x11-display-device', <%s>)", display_device);
++ g_variant_builder_add_parsed (&builder, "('x11-display', <%s>)", display_name);
++ g_variant_builder_add_parsed (&builder, "('remote-host-name', <%s>)", display_hostname);
++ g_variant_builder_add_parsed (&builder, "('is-local', <%b>)", worker->priv->display_is_local);
++ g_variant_builder_add_parsed (&builder, "('session-type', <%s>)", session_type);
++
++ parameters = g_variant_builder_end (&builder);
++ in_args = g_variant_new_tuple (¶meters, 1);
++
++ reply = g_dbus_connection_call_sync (system_bus,
++ "org.freedesktop.ConsoleKit",
++ "/org/freedesktop/ConsoleKit/Manager",
++ "org.freedesktop.ConsoleKit.Manager",
++ "OpenSessionWithParameters",
++ in_args,
++ G_VARIANT_TYPE ("(s)"),
++ G_DBUS_CALL_FLAGS_NONE,
++ -1,
++ NULL,
++ &error);
++
++ if (! reply) {
++ g_warning ("%s\n", error->message);
++ g_clear_error (&error);
++ goto out;
++ }
++
++ g_variant_get (reply, "(s)", &worker->priv->session_cookie);
++
++ g_variant_unref (reply);
++
++out:
++ return worker->priv->session_cookie != NULL;
++}
++
++static void
++close_ck_session (GdmSessionWorker *worker)
++{
++ GDBusConnection *system_bus;
++ GVariant *reply;
++ GError *error = NULL;
++ gboolean was_closed;
++
++ if (worker->priv->session_cookie == NULL) {
++ return;
++ }
++
++ error = NULL;
++ system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
++
++ if (system_bus == NULL) {
++ g_warning ("Couldn't create connection to system bus: %s",
++ error->message);
++
++ g_error_free (error);
++ goto out;
++ }
++
++ reply = g_dbus_connection_call_sync (system_bus,
++ "org.freedesktop.ConsoleKit",
++ "/org/freedesktop/ConsoleKit/Manager",
++ "org.freedesktop.ConsoleKit.Manager",
++ "CloseSession",
++ g_variant_new ("(s)", worker->priv->session_cookie),
++ G_VARIANT_TYPE ("(b)"),
++ G_DBUS_CALL_FLAGS_NONE,
++ -1,
++ NULL,
++ &error);
++
++ if (! reply) {
++ g_warning ("%s", error->message);
++ g_clear_error (&error);
++ goto out;
++ }
++
++ g_variant_get (reply, "(b)", &was_closed);
++
++ if (!was_closed) {
++ g_warning ("Unable to close ConsoleKit session");
++ }
++
++ g_variant_unref (reply);
++
++out:
++ g_clear_pointer (&worker->priv->session_cookie,
++ (GDestroyNotify) g_free);
++}
++
++static char *
++get_ck_session_id (GdmSessionWorker *worker)
++{
++ GDBusConnection *system_bus;
++ GVariant *reply;
++ GError *error = NULL;
++ char *session_id = NULL;
++
++ error = NULL;
++ system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
++
++ if (system_bus == NULL) {
++ g_warning ("Couldn't create connection to system bus: %s",
++ error->message);
++
++ g_error_free (error);
++ goto out;
++ }
++
++ reply = g_dbus_connection_call_sync (system_bus,
++ "org.freedesktop.ConsoleKit",
++ "/org/freedesktop/ConsoleKit/Manager",
++ "org.freedesktop.ConsoleKit.Manager",
++ "GetSessionForCookie",
++ g_variant_new ("(s)", worker->priv->session_cookie),
++ G_VARIANT_TYPE ("(o)"),
++ G_DBUS_CALL_FLAGS_NONE,
++ -1,
++ NULL,
++ &error);
++
++ if (reply == NULL) {
++ g_warning ("%s", error->message);
++ g_clear_error (&error);
++ goto out;
++ }
++
++ g_variant_get (reply, "(o)", &session_id);
++
++ g_variant_unref (reply);
++
++out:
++ return session_id;
++}
++#endif
++
+ /* adapted from glib script_execute */
+ static void
+ script_execute (const gchar *file,
+@@ -754,6 +961,7 @@ gdm_session_worker_stop_auditor (GdmSess
+ worker->priv->auditor = NULL;
+ }
+
++#ifdef WITH_SYSTEMD
+ static void
+ on_release_display (int signal)
+ {
+@@ -879,6 +1087,7 @@ jump_to_vt (GdmSessionWorker *worker,
+
+ close (active_vt_tty_fd);
+ }
++#endif
+
+ static void
+ gdm_session_worker_uninitialize_pam (GdmSessionWorker *worker,
+@@ -909,9 +1118,11 @@ gdm_session_worker_uninitialize_pam (Gdm
+
+ gdm_session_worker_stop_auditor (worker);
+
++#ifdef WITH_SYSTEMD
+ if (worker->priv->login_vt != worker->priv->session_vt) {
+ jump_to_vt (worker, worker->priv->login_vt);
+ }
++#endif
+
+ worker->priv->login_vt = 0;
+ worker->priv->session_vt = 0;
+@@ -1036,10 +1247,12 @@ gdm_session_worker_initialize_pam (GdmSe
+ }
+ }
+
++#ifdef WITH_SYSTEMD
+ /* set seat ID */
+- if (seat_id != NULL && seat_id[0] != '\0') {
++ if (seat_id != NULL && seat_id[0] != '\0' && LOGIND_RUNNING()) {
+ 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");
+@@ -1342,7 +1555,7 @@ _lookup_passwd_info (const char *usernam
+ if (passwd_entry->pw_shell != NULL && passwd_entry->pw_shell[0] != '\0') {
+ *shellp = g_strdup (passwd_entry->pw_shell);
+ } else {
+- *shellp = g_strdup ("/bin/bash");
++ *shellp = g_strdup ("/bin/ksh");
+ }
+ }
+ ret = TRUE;
+@@ -1595,6 +1808,26 @@ gdm_session_worker_get_environment (GdmS
+ 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) {
++ gdm_session_worker_set_environment_variable (worker,
++ "XDG_SESSION_COOKIE",
++ worker->priv->session_cookie);
++ }
++}
++#endif
++
+ static gboolean
+ run_script (GdmSessionWorker *worker,
+ const char *dir)
+@@ -1625,6 +1858,9 @@ session_worker_child_watch (GPid
+ : WIFSIGNALED (status) ? WTERMSIG (status)
+ : -1);
+
++#ifdef WITH_CONSOLE_KIT
++ close_ck_session (worker);
++#endif
+
+ gdm_session_worker_uninitialize_pam (worker, PAM_SUCCESS);
+
+@@ -1813,12 +2049,14 @@ gdm_session_worker_start_session (GdmSes
+
+ error_code = PAM_SUCCESS;
+
++#ifdef WITH_SYSTEMD
+ /* 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. */
+ if (worker->priv->display_mode == GDM_SESSION_DISPLAY_MODE_NEW_VT) {
+ jump_to_vt (worker, worker->priv->session_vt);
+ }
++#endif
+
+ session_pid = fork ();
+
+@@ -1865,6 +2103,7 @@ gdm_session_worker_start_session (GdmSes
+ _exit (2);
+ }
+
++#ifdef WITH_SYSTEMD
+ /* Take control of the tty
+ */
+ if (needs_controlling_terminal) {
+@@ -1872,6 +2111,7 @@ gdm_session_worker_start_session (GdmSes
+ g_debug ("GdmSessionWorker: could not take control of tty: %m");
+ }
+ }
++#endif
+
+ #ifdef HAVE_LOGINCAP
+ if (setusercontext (NULL, passwd_entry, passwd_entry->pw_uid, LOGIN_SETALL) < 0) {
+@@ -2016,6 +2256,7 @@ gdm_session_worker_start_session (GdmSes
+ return TRUE;
+ }
+
++#ifdef WITH_SYSTEMD
+ static gboolean
+ set_up_for_new_vt (GdmSessionWorker *worker)
+ {
+@@ -2073,6 +2314,7 @@ fail:
+ close (fd);
+ return FALSE;
+ }
++#endif
+
+ static gboolean
+ set_up_for_current_vt (GdmSessionWorker *worker,
+@@ -2161,6 +2403,7 @@ gdm_session_worker_open_session (GdmSess
+ return FALSE;
+ }
+ break;
++#ifdef WITH_SYSTEMD
+ case GDM_SESSION_DISPLAY_MODE_NEW_VT:
+ case GDM_SESSION_DISPLAY_MODE_LOGIND_MANAGED:
+ if (!set_up_for_new_vt (worker)) {
+@@ -2171,6 +2414,7 @@ gdm_session_worker_open_session (GdmSess
+ return FALSE;
+ }
+ break;
++#endif
+ }
+
+ flags = 0;
+@@ -2200,7 +2444,9 @@ gdm_session_worker_open_session (GdmSess
+ g_debug ("GdmSessionWorker: state SESSION_OPENED");
+ worker->priv->state = GDM_SESSION_WORKER_STATE_SESSION_OPENED;
+
++#ifdef WITH_SYSTEMD
+ session_id = gdm_session_worker_get_environment_variable (worker, "XDG_SESSION_ID");
++#endif
+
+ /* FIXME: should we do something here?
+ * Note that error return status from PreSession script should
+@@ -2210,6 +2456,14 @@ gdm_session_worker_open_session (GdmSess
+ */
+ run_script (worker, GDMCONFDIR "/PreSession");
+
++#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;
+@@ -2314,6 +2568,19 @@ gdm_session_worker_handle_set_session_na
+ }
+
+ static gboolean
++gdm_session_worker_handle_set_session_type (GdmDBusWorker *object,
++ GDBusMethodInvocation *invocation,
++ const char *session_type)
++{
++ GdmSessionWorker *worker = GDM_SESSION_WORKER (object);
++ g_debug ("GdmSessionWorker: session type set to %s", session_type);
++ g_free (worker->priv->session_type);
++ worker->priv->session_type = g_strdup (session_type);
++ gdm_dbus_worker_complete_set_session_type (object, invocation);
++ return TRUE;
++}
++
++static gboolean
+ gdm_session_worker_handle_set_session_display_mode (GdmDBusWorker *object,
+ GDBusMethodInvocation *invocation,
+ const char *str)
+@@ -3121,6 +3388,7 @@ worker_interface_init (GdmDBusWorkerIfac
+ 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;
++ interface->handle_set_session_type = gdm_session_worker_handle_set_session_type;
+ interface->handle_set_session_display_mode = gdm_session_worker_handle_set_session_display_mode;
+ interface->handle_set_environment_variable = gdm_session_worker_handle_set_environment_variable;
+ interface->handle_start_program = gdm_session_worker_handle_start_program;
diff --git a/gdm/patches/patch-daemon_gdm-session-worker_xml b/gdm/patches/patch-daemon_gdm-session-worker_xml
new file mode 100644
index 0000000..cfe78ee
--- /dev/null
+++ b/gdm/patches/patch-daemon_gdm-session-worker_xml
@@ -0,0 +1,20 @@
+$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@localhost>
+Date: Fri, 12 Jun 2015 14:33:40 -0400
+Subject: session: drop session-type property
+
+--- 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
+@@ -13,6 +13,9 @@
+ <method name="SetSessionName">
+ <arg name="session_name" direction="in" type="s" />
+ </method>
++ <method name="SetSessionType">
++ <arg name="session_type" direction="in" type="s"/>
++ </method>
+ <method name="SetSessionDisplayMode">
+ <arg name="mode" direction="in" type="s"/>
+ </method>
diff --git a/gdm/patches/patch-daemon_gdm-session_c b/gdm/patches/patch-daemon_gdm-session_c
new file mode 100644
index 0000000..a22a806
--- /dev/null
+++ b/gdm/patches/patch-daemon_gdm-session_c
@@ -0,0 +1,55 @@
+$OpenBSD: patch-daemon_gdm-session_c,v 1.6 2015/11/17 17:48:40 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@localhost>
+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@localhost>
+Date: Fri, 12 Jun 2015 14:33:40 -0400
+Subject: session: drop session-type property
+
+--- daemon/gdm-session.c.orig 2015-11-17 17:16:04.000000000 +0000
++++ daemon/gdm-session.c
+@@ -3071,6 +3071,10 @@ gdm_session_get_display_mode (GdmSession
+ self->priv->is_program_session? "yes" : "no",
+ self->priv->display_seat_id);
+
++ if (!LOGIND_RUNNING()) {
++ return GDM_SESSION_DISPLAY_MODE_REUSE_VT;
++ }
++
+ #ifdef ENABLE_WAYLAND_SUPPORT
+ /* Wayland sessions are for now assumed to run in a
+ * mutter-launch-like environment, so we allocate
+@@ -3112,6 +3116,27 @@ gdm_session_select_program (GdmSession *
+ }
+
+ void
++gdm_session_select_session_type (GdmSession *self,
++ const char *text)
++{
++ GHashTableIter iter;
++ gpointer key, value;
++
++ g_debug ("GdmSession: selecting session type '%s'", text);
++
++ g_hash_table_iter_init (&iter, self->priv->conversations);
++ while (g_hash_table_iter_next (&iter, &key, &value)) {
++ GdmSessionConversation *conversation;
++
++ conversation = (GdmSessionConversation *) value;
++
++ gdm_dbus_worker_call_set_session_type (conversation->worker_proxy,
++ text,
++ NULL, NULL, NULL);
++ }
++}
++
++void
+ gdm_session_select_session (GdmSession *self,
+ const char *text)
+ {
diff --git a/gdm/patches/patch-daemon_gdm-session_h b/gdm/patches/patch-daemon_gdm-session_h
new file mode 100644
index 0000000..8ff1056
--- /dev/null
+++ b/gdm/patches/patch-daemon_gdm-session_h
@@ -0,0 +1,19 @@
+$OpenBSD: patch-daemon_gdm-session_h,v 1.3 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@localhost>
+Date: Fri, 12 Jun 2015 14:33:40 -0400
+Subject: session: drop session-type property
+
+--- daemon/gdm-session.h.orig Mon Sep 21 16:12:33 2015
++++ daemon/gdm-session.h Sun Oct 18 14:23:03 2015
+@@ -176,6 +176,8 @@ void gdm_session_answer_query
+ const char *text);
+ void gdm_session_select_program (GdmSession *session,
+ const char *command_line);
++void gdm_session_select_session_type (GdmSession *session,
++ const char *session_type);
+ void gdm_session_select_session (GdmSession *session,
+ const char *session_name);
+ void gdm_session_select_user (GdmSession *session,
diff --git a/gdm/patches/patch-daemon_main_c b/gdm/patches/patch-daemon_main_c
new file mode 100644
index 0000000..df8599f
--- /dev/null
+++ b/gdm/patches/patch-daemon_main_c
@@ -0,0 +1,39 @@
+$OpenBSD: patch-daemon_main_c,v 1.2 2015/04/03 18:39:06 ajacoutot Exp $
+
+REVERT - OpenBSD lacks sigwaitinfo(2)
+From 956d7d1c7a0cfbf2beacdb9e88e645e15ad32047 Mon Sep 17 00:00:00 2001
+From: Jasper St. Pierre <jstpierre%mecheye.net@localhost>
+Date: Fri, 14 Feb 2014 19:32:50 +0000
+Subject: server: Process SIGUSR1 more carefully
+
+--- daemon/main.c.orig 2015-11-17 17:16:04.000000000 +0000
++++ daemon/main.c
+@@ -289,19 +289,6 @@ is_debug_set (void)
+ return debug;
+ }
+
+-/* SIGUSR1 is used by the X server to tell us that we're ready, so
+- * block it. We'll unblock it in the worker thread in gdm-server.c
+- */
+-static void
+-block_sigusr1 (void)
+-{
+- sigset_t mask;
+-
+- sigemptyset (&mask);
+- sigaddset (&mask, SIGUSR1);
+- sigprocmask (SIG_BLOCK, &mask, NULL);
+-}
+-
+ int
+ main (int argc,
+ char **argv)
+@@ -322,8 +309,6 @@ main (int argc,
+ { NULL }
+ };
+
+- block_sigusr1 ();
+-
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ textdomain (GETTEXT_PACKAGE);
+ setlocale (LC_ALL, "");
diff --git a/gdm/patches/patch-data_Init_in b/gdm/patches/patch-data_Init_in
new file mode 100644
index 0000000..7f1013b
--- /dev/null
+++ b/gdm/patches/patch-data_Init_in
@@ -0,0 +1,25 @@
+$OpenBSD: patch-data_Init_in,v 1.7 2015/04/15 14:47:00 ajacoutot Exp $
+--- data/Init.in.orig 2015-11-17 17:16:04.000000000 +0000
++++ data/Init.in
+@@ -6,6 +6,9 @@
+ PATH="@X_PATH@:$PATH"
+ OLD_IFS=$IFS
+
++# enhance fade in look
++xsetroot -solid black
++
+ gdmwhich () {
+ COMMAND="$1"
+ OUTPUT=
+@@ -86,4 +89,11 @@ if [ "x$SETXKBMAP" != "x" ] ; then
+ fi
+ fi
+
++# /etc/X11/xdm/GiveConsole, fbtab(5)
++if [ -c /dev/drm0 ]; then
++ /sbin/chown _gdm /dev/drm0
++fi
++# XXX OpenBSD needs an implementation of XDG_RUNTIME_DIR
++rm -rf /var/db/gdm/.cache/gnome-shell/runtime-state-*
++
+ exit 0
diff --git a/gdm/patches/patch-data_Makefile_am b/gdm/patches/patch-data_Makefile_am
new file mode 100644
index 0000000..6a533e6
--- /dev/null
+++ b/gdm/patches/patch-data_Makefile_am
@@ -0,0 +1,63 @@
+$OpenBSD: patch-data_Makefile_am,v 1.1 2015/10/18 13:25:54 ajacoutot Exp $
+--- data/Makefile.am.orig 2015-11-17 17:16:04.000000000 +0000
++++ data/Makefile.am
+@@ -192,6 +192,7 @@ if ENABLE_GDM_XSESSION
+ Xsession: $(srcdir)/Xsession.in
+ sed -e 's,[@]XSESSION_SHELL[@],$(XSESSION_SHELL),g' \
+ -e 's,[@]libexecdir[@],$(libexecdir),g' \
++ -e 's,[@]X_PATH[@],$(X_PATH),g' \
+ <$(srcdir)/Xsession.in >Xsession
+ Xsession_files += Xsession
+ CLEANFILES += Xsession
+@@ -271,7 +272,7 @@ endif
+ if test '!' -d $(DESTDIR)$(logdir); then \
+ $(mkinstalldirs) $(DESTDIR)$(logdir); \
+ chmod 755 $(DESTDIR)$(logdir); \
+- chown root:root $(DESTDIR)$(logdir) || : ; \
++ chown root:wheel $(DESTDIR)$(logdir) || : ; \
+ fi
+
+ system=`uname`; \
+@@ -294,36 +295,36 @@ endif
+ if test '!' -d $(DESTDIR)$(xauthdir); then \
+ $(mkinstalldirs) $(DESTDIR)$(xauthdir); \
+ chmod 0711 $(DESTDIR)$(xauthdir); \
+- chown root:gdm $(DESTDIR)$(xauthdir) || : ; \
++ chown root:676 $(DESTDIR)$(xauthdir) || : ; \
+ fi
+
+ if test -n "$(systemdsystemunit)" -a '!' -d $(DESTDIR)$(SYSTEMD_SYSTEM_UNIT_DIR); then \
+ $(mkinstalldirs) $(DESTDIR)$(SYSTEMD_SYSTEM_UNIT_DIR); \
+ chmod 0755 $(DESTDIR)$(SYSTEMD_SYSTEM_UNIT_DIR); \
+- chown root:root $(DESTDIR)$(SYSTEMD_SYSTEM_UNIT_DIR) || : ; \
++ chown root:wheel $(DESTDIR)$(SYSTEMD_SYSTEM_UNIT_DIR) || : ; \
+ $(INSTALL_DATA) $(builddir)/$(systemdsystemunit) $(DESTDIR)$(SYSTEMD_SYSTEM_UNIT_DIR)/$(systemdsystemunit); \
+ fi
+
+ if test '!' -d $(DESTDIR)$(screenshotdir); then \
+ $(mkinstalldirs) $(DESTDIR)$(screenshotdir); \
+ chmod 0755 $(DESTDIR)$(screenshotdir); \
+- chown gdm:gdm $(DESTDIR)$(screenshotdir) || : ; \
++ chown 676:676 $(DESTDIR)$(screenshotdir) || : ; \
+ fi
+
+ if test '!' -d $(DESTDIR)$(workingdir); then \
+ $(mkinstalldirs) $(DESTDIR)$(workingdir); \
+ chmod 1770 $(DESTDIR)$(workingdir); \
+- chown root:gdm $(DESTDIR)$(workingdir) || : ; \
++ chown root:676 $(DESTDIR)$(workingdir) || : ; \
+ fi
+
+ if test '!' -d $(DESTDIR)$(workingdir)/.local/share/applications; then \
+ $(mkinstalldirs) $(DESTDIR)$(workingdir)/.local/share/applications; \
+ chmod 0755 $(DESTDIR)$(workingdir)/.local/share/applications; \
+- chown gdm:gdm $(DESTDIR)$(workingdir)/.local/share/applications || : ; \
++ chown 676:676 $(DESTDIR)$(workingdir)/.local/share/applications || : ; \
+ fi
+
+ if test '!' -d $(DESTDIR)$(cachedir); then \
+ $(mkinstalldirs) $(DESTDIR)$(cachedir); \
+ chmod 1755 $(DESTDIR)$(cachedir); \
+- chown root:gdm $(DESTDIR)$(cachedir) || : ; \
++ chown root:676 $(DESTDIR)$(cachedir) || : ; \
+ fi
diff --git a/gdm/patches/patch-data_PostSession_in b/gdm/patches/patch-data_PostSession_in
new file mode 100644
index 0000000..dc7f929
--- /dev/null
+++ b/gdm/patches/patch-data_PostSession_in
@@ -0,0 +1,12 @@
+$OpenBSD: patch-data_PostSession_in,v 1.3 2014/04/07 16:05:52 ajacoutot Exp $
+--- data/PostSession.in.orig Thu Dec 26 16:30:16 2013
++++ data/PostSession.in Thu Dec 26 16:31:15 2013
+@@ -1,3 +1,8 @@
+ #!/bin/sh
+
++# /etc/X11/xdm/TakeConsole, fbtab(5)
++if [ -c /dev/drm0 ]; then
++ /sbin/chown root /dev/drm0
++fi
++
+ exit 0
diff --git a/gdm/patches/patch-data_PreSession_in b/gdm/patches/patch-data_PreSession_in
new file mode 100644
index 0000000..ef3914f
--- /dev/null
+++ b/gdm/patches/patch-data_PreSession_in
@@ -0,0 +1,12 @@
+$OpenBSD: patch-data_PreSession_in,v 1.5 2014/04/07 16:05:52 ajacoutot Exp $
+--- data/PreSession.in.orig Thu Dec 26 16:04:18 2013
++++ data/PreSession.in Thu Dec 26 16:09:50 2013
+@@ -7,3 +7,8 @@
+ # Note that output goes into the .xsession-errors file for easy debugging
+ #
+ PATH="@X_PATH@:$PATH"
++
++# /etc/X11/xdm/GiveConsole, fbtab(5)
++if [ -c /dev/drm0 ]; then
++ /sbin/chown $USER /dev/drm0
++fi
diff --git a/gdm/patches/patch-libgdm_gdm-user-switching_c b/gdm/patches/patch-libgdm_gdm-user-switching_c
new file mode 100644
index 0000000..e04b5b3
--- /dev/null
+++ b/gdm/patches/patch-libgdm_gdm-user-switching_c
@@ -0,0 +1,426 @@
+$OpenBSD: patch-libgdm_gdm-user-switching_c,v 1.1 2015/10/18 13:25:54 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@localhost>
+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@localhost>
+Date: Fri, 12 Jun 2015 13:48:52 -0400
+Subject: require logind support
+
+--- libgdm/gdm-user-switching.c.orig 2015-11-17 17:16:04.000000000 +0000
++++ libgdm/gdm-user-switching.c
+@@ -31,12 +31,25 @@
+ #include <glib-object.h>
+ #include <gio/gio.h>
+
++#ifdef WITH_SYSTEMD
+ #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,12 +80,304 @@ create_transient_display (GDBusConnectio
+ return TRUE;
+ }
+
++#ifdef WITH_CONSOLE_KIT
++
++static gboolean
++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;
++}
++
++static 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,
++ seat_id,
++ CK_SEAT_INTERFACE,
++ "ActivateSession",
++ g_variant_new ("(o)", session_id),
++ NULL,
++ G_DBUS_CALL_FLAGS_NONE,
++ -1,
++ NULL, error);
++ if (reply == NULL) {
++ g_prefix_error (error, _("Unable to activate session: "));
++ return FALSE;
++ }
++
++ g_variant_unref (reply);
++
++ return TRUE;
++}
++
+ static gboolean
+-activate_session_id (GDBusConnection *connection,
+- GCancellable *cancellable,
+- const char *seat_id,
+- const char *session_id,
+- GError **error)
++session_is_login_window (GDBusConnection *connection,
++ const char *session_id)
++{
++ GError *local_error = NULL;
++ GVariant *reply;
++ const char *value;
++ gboolean ret;
++
++ reply = g_dbus_connection_call_sync (connection,
++ CK_NAME,
++ session_id,
++ CK_SESSION_INTERFACE,
++ "GetSessionType",
++ NULL,
++ G_VARIANT_TYPE ("(s)"),
++ G_DBUS_CALL_FLAGS_NONE,
++ -1,
++ NULL, &local_error);
++ if (reply == NULL) {
++ g_warning ("Unable to determine session type: %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;
++ }
++
++ g_variant_unref (reply);
++
++ return ret;
++}
++
++static gboolean
++seat_can_activate_sessions (GDBusConnection *connection,
++ const char *seat_id)
++{
++ GError *local_error = NULL;
++ GVariant *reply;
++ gboolean ret;
++
++ reply = g_dbus_connection_call_sync (connection,
++ CK_NAME,
++ seat_id,
++ CK_SEAT_INTERFACE,
++ "CanActivateSessions",
++ NULL,
++ G_VARIANT_TYPE ("(b)"),
++ G_DBUS_CALL_FLAGS_NONE,
++ -1,
++ NULL, &local_error);
++ if (reply == NULL) {
++ g_warning ("Unable to determine if can activate sessions: %s", local_error->message);
++ g_error_free (local_error);
++ return FALSE;
++ }
++
++ g_variant_get (reply, "(b)", &ret);
++ g_variant_unref (reply);
++
++ return ret;
++}
++
++static const char **
++seat_get_sessions (GDBusConnection *connection,
++ const char *seat_id)
++{
++ GError *local_error = NULL;
++ GVariant *reply;
++ const char **value;
++
++ reply = g_dbus_connection_call_sync (connection,
++ CK_NAME,
++ seat_id,
++ CK_SEAT_INTERFACE,
++ "GetSessions",
++ NULL,
++ G_VARIANT_TYPE ("(ao)"),
++ G_DBUS_CALL_FLAGS_NONE,
++ -1,
++ NULL, &local_error);
++ if (reply == NULL) {
++ g_warning ("Unable to list sessions: %s", local_error->message);
++ g_error_free (local_error);
++ return FALSE;
++ }
++
++ g_variant_get (reply, "(^ao)", &value);
++ g_variant_unref (reply);
++
++ return value;
++}
++
++static gboolean
++get_login_window_session_id_for_ck (GDBusConnection *connection,
++ const char *seat_id,
++ char **session_id)
++{
++ gboolean can_activate_sessions;
++ const char **sessions;
++ int i;
++
++ *session_id = NULL;
++ sessions = NULL;
++
++ g_debug ("checking if seat can activate 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;
++ }
++
++ sessions = seat_get_sessions (connection, seat_id);
++ for (i = 0; sessions [i] != NULL; i++) {
++ const char *ssid;
++
++ ssid = sessions [i];
++
++ if (session_is_login_window (connection, ssid)) {
++ *session_id = g_strdup (ssid);
++ break;
++ }
++ }
++ 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
++
++static gboolean
++activate_session_id_for_systemd (GDBusConnection *connection,
++ GCancellable *cancellable,
++ const char *seat_id,
++ const char *session_id,
++ GError **error)
+ {
+ GVariant *reply;
+
+@@ -97,8 +402,8 @@ activate_session_id (GDBusConnection *c
+ }
+
+ 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,9 +487,9 @@ out:
+ }
+
+ static gboolean
+-goto_login_session (GDBusConnection *connection,
+- GCancellable *cancellable,
+- GError **error)
++goto_login_session_for_systemd (GDBusConnection *connection,
++ GCancellable *cancellable,
++ GError **error)
+ {
+ gboolean ret;
+ int res;
+@@ -238,9 +543,9 @@ goto_login_session (GDBusConnection *co
+ 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) {
+ ret = TRUE;
+@@ -259,10 +564,11 @@ goto_login_session (GDBusConnection *co
+
+ return ret;
+ }
++#endif
+
+ gboolean
+ gdm_goto_login_session_sync (GCancellable *cancellable,
+- GError **error)
++ GError **error)
+ {
+ GDBusConnection *connection;
+ gboolean retval;
+@@ -271,8 +577,23 @@ gdm_goto_login_session_sync (GCancellabl
+ 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
+ }
Home |
Main Index |
Thread Index |
Old Index