pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/x11/libgdm



Module Name:    pkgsrc
Committed By:   cirnatdan
Date:           Fri Apr 16 13:57:52 UTC 2021

Added Files:
        pkgsrc/x11/libgdm: DESCR Makefile PLIST distinfo
        pkgsrc/x11/libgdm/patches: patch-build-aux_find-x-server.sh
            patch-common_gdm-address_c patch-common_gdm-common_c
            patch-common_gdm-common_h patch-common_gdm-log_c
            patch-common_meson.build patch-daemon_gdm-display-access-file.c
            patch-daemon_gdm-display_c patch-daemon_gdm-launch-environment_c
            patch-daemon_gdm-local-display-factory_c patch-daemon_gdm-manager_c
            patch-daemon_gdm-server_c patch-daemon_gdm-session-record_c
            patch-daemon_gdm-session-worker-job_c
            patch-daemon_gdm-session-worker_c
            patch-daemon_gdm-session-worker_xml patch-daemon_gdm-session_c
            patch-daemon_gdm-session_h patch-daemon_gdm-x-session.c
            patch-daemon_main_c patch-data_Init_in patch-data_PostSession_in
            patch-data_PreSession_in patch-data_gdm.conf-custom.in
            patch-data_meson.build patch-libgdm_gdm-user-switching_c
            patch-libgdm_meson.build patch-meson.build
            patch-pam__gdm_pam__gdm.c

Log Message:
x11/libgdm: import libgdm-40.0

The GNOME Display Manager is a system service that is responsible for
providing graphical log-ins and managing local and remote displays.
This package installs libgdm, which is the client part of GDM.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 pkgsrc/x11/libgdm/DESCR pkgsrc/x11/libgdm/Makefile \
    pkgsrc/x11/libgdm/PLIST pkgsrc/x11/libgdm/distinfo
cvs rdiff -u -r0 -r1.1 \
    pkgsrc/x11/libgdm/patches/patch-build-aux_find-x-server.sh \
    pkgsrc/x11/libgdm/patches/patch-common_gdm-address_c \
    pkgsrc/x11/libgdm/patches/patch-common_gdm-common_c \
    pkgsrc/x11/libgdm/patches/patch-common_gdm-common_h \
    pkgsrc/x11/libgdm/patches/patch-common_gdm-log_c \
    pkgsrc/x11/libgdm/patches/patch-common_meson.build \
    pkgsrc/x11/libgdm/patches/patch-daemon_gdm-display-access-file.c \
    pkgsrc/x11/libgdm/patches/patch-daemon_gdm-display_c \
    pkgsrc/x11/libgdm/patches/patch-daemon_gdm-launch-environment_c \
    pkgsrc/x11/libgdm/patches/patch-daemon_gdm-local-display-factory_c \
    pkgsrc/x11/libgdm/patches/patch-daemon_gdm-manager_c \
    pkgsrc/x11/libgdm/patches/patch-daemon_gdm-server_c \
    pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session-record_c \
    pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session-worker-job_c \
    pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session-worker_c \
    pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session-worker_xml \
    pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session_c \
    pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session_h \
    pkgsrc/x11/libgdm/patches/patch-daemon_gdm-x-session.c \
    pkgsrc/x11/libgdm/patches/patch-daemon_main_c \
    pkgsrc/x11/libgdm/patches/patch-data_Init_in \
    pkgsrc/x11/libgdm/patches/patch-data_PostSession_in \
    pkgsrc/x11/libgdm/patches/patch-data_PreSession_in \
    pkgsrc/x11/libgdm/patches/patch-data_gdm.conf-custom.in \
    pkgsrc/x11/libgdm/patches/patch-data_meson.build \
    pkgsrc/x11/libgdm/patches/patch-libgdm_gdm-user-switching_c \
    pkgsrc/x11/libgdm/patches/patch-libgdm_meson.build \
    pkgsrc/x11/libgdm/patches/patch-meson.build \
    pkgsrc/x11/libgdm/patches/patch-pam__gdm_pam__gdm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: pkgsrc/x11/libgdm/DESCR
diff -u /dev/null pkgsrc/x11/libgdm/DESCR:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/DESCR     Fri Apr 16 13:57:52 2021
@@ -0,0 +1,3 @@
+The GNOME Display Manager is a system service that is responsible for
+providing graphical log-ins and managing local and remote displays.
+This package installs libgdm, which is the client part of GDM.
Index: pkgsrc/x11/libgdm/Makefile
diff -u /dev/null pkgsrc/x11/libgdm/Makefile:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/Makefile  Fri Apr 16 13:57:52 2021
@@ -0,0 +1,94 @@
+# $NetBSD: Makefile,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+DISTNAME=      gdm-40.0
+PKGNAME=       ${DISTNAME:S/gdm/libgdm/}
+CATEGORIES=    x11 gnome
+MASTER_SITES=  ${MASTER_SITE_GITHUB:=GNOME/}
+
+MAINTAINER=    pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE=      https://www.gnome.org/
+COMMENT=       Gnome Display Manager - client library
+LICENSE=       gnu-gpl-v2
+
+DEPENDS+=      zenity>=3.32.0:../../x11/zenity
+
+USE_PKGLOCALEDIR=      YES
+GNU_CONFIGURE=         YES
+USE_LIBTOOL=           YES
+USE_TOOLS+=            msgfmt pkg-config
+BUILD_DEFS+=           VARBASE
+
+USE_LANGUAGES=         c c++
+
+CPPFLAGS+=             -DWITH_CONSOLE_KIT=1
+CPPFLAGS+=             -DCONSOLEKIT_DIR=\"${PREFIX}/libexec\"
+
+MESON_ARGS+=           -Dlocalstatedir=${VARBASE}
+MESON_ARGS+=           --sysconfdir=${EGDIR}
+MESON_ARGS+=           -Ddmconfdir=${PKG_SYSCONFDIR}/dm
+MESON_ARGS+=           -Dsysconfsubdir=
+MESON_ARGS+=           -Dprefetch=yes
+MESON_ARGS+=           -Dplymouth=disabled
+MESON_ARGS+=           -Dsystemd=disabled
+MESON_ARGS+=           -Dsystemd-journal=false
+MESON_ARGS+=           -Duser-display-server=false
+MESON_ARGS+=           -Duser=${GDMOWN}
+MESON_ARGS+=           -Dgroup=${GDMGRP}
+MESON_ARGS+=           -Ddbus-sys=${PREFIX}/share/examples/dbus-1/system.d
+MESON_ARGS+=           -Dgdm-xsession=true
+MESON_ARGS+=           -Dwayland-support=false
+MESON_ARGS+=           -Ddefault-path="/usr/local/bin:/usr/local/sbin:${PREFIX}/bin:${PREFIX}/sbin:/usr/bin:/usr/sbin:/bin/sbin"
+INSTALL_MAKE_FLAGS+=   ${MAKE_FLAGS}
+INSTALL_MAKE_FLAGS+=   GDM_CUSTOM_CONF=${EGDIR}/custom.conf
+INSTALL_MAKE_FLAGS+=   sysconfdir=${EGDIR}
+MAKE_ENV+=             CHMOD=${CHMOD:Q} CHOWN=${CHOWN:Q}
+
+# only install libgdm, without the daemon and login screen
+INSTALLATION_DIRS+=    include/gdm
+INSTALLATION_DIRS+=    lib/girepository-1.0
+INSTALLATION_DIRS+=    lib/
+INSTALLATION_DIRS+=    lib/pkgconfig
+INSTALLATION_DIRS+=    share/gir-1.0 share/glib-2.0/schemas
+
+INSTALL_DIRS=  # disable meson install
+
+do-install:
+       ${INSTALL_DATA} ${WRKSRC}/output/libgdm/gdm-client-glue.h \
+               ${DESTDIR}${PREFIX}/include/gdm
+       ${INSTALL_DATA} ${WRKSRC}/libgdm/gdm-client.h \
+               ${DESTDIR}${PREFIX}/include/gdm
+       ${INSTALL_DATA} ${WRKSRC}/libgdm/gdm-sessions.h \
+               ${DESTDIR}${PREFIX}/include/gdm
+       ${INSTALL_DATA} ${WRKSRC}/libgdm/gdm-user-switching.h \
+               ${DESTDIR}${PREFIX}/include/gdm
+
+       ${INSTALL_DATA} ${WRKSRC}/output/libgdm/Gdm-1.0.typelib \
+               ${DESTDIR}${PREFIX}/lib/girepository-1.0
+       ${INSTALL_LIB} ${WRKSRC}/output/libgdm/libgdm.so \
+               ${DESTDIR}${PREFIX}/lib
+       ${INSTALL_LIB} ${WRKSRC}/output/libgdm/libgdm.so.1 \
+               ${DESTDIR}${PREFIX}/lib
+       ${INSTALL_LIB} ${WRKSRC}/output/libgdm/libgdm.so.1.0.0 \
+               ${DESTDIR}${PREFIX}/lib
+
+       ${INSTALL_DATA} ${WRKSRC}/output/meson-private/gdm.pc \
+               ${DESTDIR}${PREFIX}/lib/pkgconfig
+
+       ${INSTALL_DATA} ${WRKSRC}/output/libgdm/Gdm-1.0.gir \
+               ${DESTDIR}${PREFIX}/share/gir-1.0
+       ${INSTALL_DATA} ${WRKSRC}/data/org.gnome.login-screen.gschema.xml \
+               ${DESTDIR}${PREFIX}/share/glib-2.0/schemas
+
+.include "../../devel/meson/build.mk"
+#.include "../../sysutils/gsettings-desktop-schemas/buildlink3.mk"
+BUILDLINK_DEPMETHOD.openpam=   build
+.include "../../security/openpam/buildlink3.mk"
+BUILDLINK_DEPMETHOD.dconf=             build
+.include "../../devel/dconf/buildlink3.mk"
+.include "../../audio/libcanberra/buildlink3.mk"
+BUILDLINK_DEPMETHOD.gtk3=              build
+.include "../../x11/gtk3/buildlink3.mk"
+.include "../../sysutils/accountsservice/buildlink3.mk"
+.include "../../devel/gettext-lib/buildlink3.mk"
+.include "../../devel/glib2/schemas.mk"
+.include "../../mk/bsd.pkg.mk"
Index: pkgsrc/x11/libgdm/PLIST
diff -u /dev/null pkgsrc/x11/libgdm/PLIST:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/PLIST     Fri Apr 16 13:57:52 2021
@@ -0,0 +1,12 @@
+@comment $NetBSD: PLIST,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+include/gdm/gdm-client-glue.h
+include/gdm/gdm-client.h
+include/gdm/gdm-sessions.h
+include/gdm/gdm-user-switching.h
+lib/girepository-1.0/Gdm-1.0.typelib
+lib/libgdm.so
+lib/libgdm.so.1
+lib/libgdm.so.1.0.0
+lib/pkgconfig/gdm.pc
+share/gir-1.0/Gdm-1.0.gir
+share/glib-2.0/schemas/org.gnome.login-screen.gschema.xml
Index: pkgsrc/x11/libgdm/distinfo
diff -u /dev/null pkgsrc/x11/libgdm/distinfo:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/distinfo  Fri Apr 16 13:57:52 2021
@@ -0,0 +1,35 @@
+$NetBSD: distinfo,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+SHA1 (gdm-40.0.tar.gz) = f16d102b1052ff3ae0b64cac47dd3910b9b2ae74
+RMD160 (gdm-40.0.tar.gz) = aef9fa9d25f92b671166b9b2a56f9f5811e912cc
+SHA512 (gdm-40.0.tar.gz) = e1280b2e7011f76732d1c7901025f31693c58fd4eaa1483ffa0d7e24a1f14aaf3de64b0fa4d4423be72b77329f36c7a8552406dec9272f67b4756bb1ccbe1ef9
+Size (gdm-40.0.tar.gz) = 1588680 bytes
+SHA1 (patch-build-aux_find-x-server.sh) = 3ef259ca4f867d91aba24fcf1b6b02045b404248
+SHA1 (patch-common_gdm-address_c) = dbcf524882299d890103ed1d90b5d20af28cf667
+SHA1 (patch-common_gdm-common_c) = 347e9a527b22a79bfee6fd2e6f41f0e75e34cec2
+SHA1 (patch-common_gdm-common_h) = dfdb0758c65bc5426b214dd8f4a47a7f9df48aa4
+SHA1 (patch-common_gdm-log_c) = 270e98fd085ac2e7d39a48daa2c52954f7527869
+SHA1 (patch-common_meson.build) = 9c9aeaabb14bd20032ea8f2ae12a25a243dbde15
+SHA1 (patch-daemon_gdm-display-access-file.c) = 527d5c50d126875501955b20caefbdcb5b407146
+SHA1 (patch-daemon_gdm-display_c) = db972d3248c6e2cd5ac24cc72b838e6d1a8529c3
+SHA1 (patch-daemon_gdm-launch-environment_c) = 8804435a54afe85145cd995eb709096d9928a2b7
+SHA1 (patch-daemon_gdm-local-display-factory_c) = 1b768d9ec8004b2d3cee49f200f689c6331da4cb
+SHA1 (patch-daemon_gdm-manager_c) = 1136db38704181bc2c8de4649d3ff0f1466aa7f5
+SHA1 (patch-daemon_gdm-server_c) = 738e9e17c2b8102ff3d248fbac017b3bf3b114ea
+SHA1 (patch-daemon_gdm-session-record_c) = 367e4b9351a41abf78b4ac47e501e40ed9a93fe5
+SHA1 (patch-daemon_gdm-session-worker-job_c) = 11b5f2c1dde26aa6b6ff25d7913eff009c707724
+SHA1 (patch-daemon_gdm-session-worker_c) = a43c1c415946438a93892b6981b3b8f304952de3
+SHA1 (patch-daemon_gdm-session-worker_xml) = e384aed90c0ffc6483dad9c806e55a8e9d9f3e13
+SHA1 (patch-daemon_gdm-session_c) = 6cb462c9aebb6958624a6c11416a1dcdbdab0aa4
+SHA1 (patch-daemon_gdm-session_h) = b350278af12865e4f0565e69a0e52238ff9aa4b0
+SHA1 (patch-daemon_gdm-x-session.c) = 495762d51ed7676048c4e9d25bbbd77a142ec2d9
+SHA1 (patch-daemon_main_c) = 95d05534528a22f66315dc4b0b841aab760fc3d2
+SHA1 (patch-data_Init_in) = 12fbf2603c43055f411e6ce0e6076a2b739ce436
+SHA1 (patch-data_PostSession_in) = 0951d9c4e1404478c1ac9fba996bc96b41ed4d5b
+SHA1 (patch-data_PreSession_in) = cf1fec76b9555a911b0af6d3e32a838a94c57ca1
+SHA1 (patch-data_gdm.conf-custom.in) = 20560cc6889df034ce6adcb5e09516ad754f1d58
+SHA1 (patch-data_meson.build) = 51a40a90618dc21f9f0955e590a45b4fe6370189
+SHA1 (patch-libgdm_gdm-user-switching_c) = 91ebba68b5496c1de00108e1609f47c6019eadcc
+SHA1 (patch-libgdm_meson.build) = 6341327da7925597c9f15370faeacfd88a686802
+SHA1 (patch-meson.build) = d2c5bfe7d65b753722409860afc807031f9ee336
+SHA1 (patch-pam__gdm_pam__gdm.c) = a2906c96c8c5dc49e2663123b6dcd39821c7b47d

Index: pkgsrc/x11/libgdm/patches/patch-build-aux_find-x-server.sh
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-build-aux_find-x-server.sh:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-build-aux_find-x-server.sh  Fri Apr 16 13:57:52 2021
@@ -0,0 +1,15 @@
+$NetBSD: patch-build-aux_find-x-server.sh,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+Help build script find NetBSD base X server
+
+--- build-aux/find-x-server.sh.orig    2021-03-16 20:48:04.000000000 +0000
++++ build-aux/find-x-server.sh
+@@ -21,6 +21,8 @@ elif test ! -h /usr/X11 -a -x /usr/X11/b
+     echo "/usr/X11/bin/X"
+ elif test -x /usr/X11R6/bin/X; then
+     echo "/usr/X11R6/bin/X"
++elif test -x /usr/X11R7/bin/X; then
++    echo "/usr/X11R7/bin/X"
+ elif test -x /usr/bin/Xorg; then
+     echo "/usr/bin/Xorg"
+ elif test -x /usr/X11/bin/X; then
Index: pkgsrc/x11/libgdm/patches/patch-common_gdm-address_c
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-common_gdm-address_c:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-common_gdm-address_c        Fri Apr 16 13:57:52 2021
@@ -0,0 +1,31 @@
+$NetBSD: patch-common_gdm-address_c,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$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>
+ 
Index: pkgsrc/x11/libgdm/patches/patch-common_gdm-common_c
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-common_gdm-common_c:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-common_gdm-common_c Fri Apr 16 13:57:52 2021
@@ -0,0 +1,575 @@
+$NetBSD: patch-common_gdm-common_c,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$OpenBSD: patch-common_gdm-common_c,v 1.8 2020/05/14 15:25:54 ajacoutot Exp $
+
+REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
+From fcba1e1a5d556ce7b52101dbd2d1ba4a19469161 Mon Sep 17 00:00:00 2001
+From: Iain Lane <iain%orangesquash.org.uk@localhost>
+Date: Fri, 5 Jan 2018 11:53:34 +0000
+Subject: [PATCH] manager: Find user's current graphical session, not session of caller
+
+REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
+From 9be58c9ec9a3a411492a5182ac4b0d51fdc3a323 Mon Sep 17 00:00:00 2001
+From: Ray Strode <rstrode%redhat.com@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
+
+Index: common/gdm-common.c
+--- common/gdm-common.c.orig   2020-05-04 20:11:25.000000000 +0000
++++ common/gdm-common.c
+@@ -36,12 +36,25 @@
+ 
+ #include "gdm-common.h"
+ 
++#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);
+ 
+ gboolean
+@@ -352,8 +365,87 @@ create_transient_display (GDBusConnectio
+         return TRUE;
+ }
+ 
++#ifdef WITH_CONSOLE_KIT
+ gboolean
+-gdm_activate_session_by_id (GDBusConnection *connection,
++get_current_session_id (GDBusConnection  *connection,
++                        char            **session_id)
++{
++        GError *local_error = NULL;
++        GVariant *reply;
++
++        reply = g_dbus_connection_call_sync (connection,
++                                             CK_NAME,
++                                             CK_MANAGER_PATH,
++                                             CK_MANAGER_INTERFACE,
++                                             "GetCurrentSession",
++                                             NULL, /* parameters */
++                                             G_VARIANT_TYPE ("(o)"),
++                                             G_DBUS_CALL_FLAGS_NONE,
++                                             -1,
++                                             NULL, &local_error);
++        if (reply == NULL) {
++                g_warning ("Unable to determine session: %s", local_error->message);
++                g_error_free (local_error);
++                return FALSE;
++        }
++
++        g_variant_get (reply, "(o)", session_id);
++        g_variant_unref (reply);
++
++        return TRUE;
++}
++
++static gboolean
++get_seat_id_for_session (GDBusConnection  *connection,
++                         const char       *session_id,
++                         char            **seat_id)
++{
++        GError *local_error = NULL;
++        GVariant *reply;
++
++        reply = g_dbus_connection_call_sync (connection,
++                                             CK_NAME,
++                                             session_id,
++                                             CK_SESSION_INTERFACE,
++                                             "GetSeatId",
++                                             NULL, /* parameters */
++                                             G_VARIANT_TYPE ("(o)"),
++                                             G_DBUS_CALL_FLAGS_NONE,
++                                             -1,
++                                             NULL, &local_error);
++        if (reply == NULL) {
++                g_warning ("Unable to determine seat: %s", local_error->message);
++                g_error_free (local_error);
++                return FALSE;
++        }
++
++        g_variant_get (reply, "(o)", seat_id);
++        g_variant_unref (reply);
++
++        return TRUE;
++}
++
++static char *
++get_current_seat_id (GDBusConnection *connection)
++{
++        gboolean res;
++        char    *session_id;
++        char    *seat_id;
++
++        session_id = NULL;
++        seat_id = NULL;
++
++        res = get_current_session_id (connection, &session_id);
++        if (res) {
++                res = get_seat_id_for_session (connection, session_id, &seat_id);
++        }
++        g_free (session_id);
++
++        return seat_id;
++}
++
++gboolean
++activate_session_id_for_ck (GDBusConnection *connection,
+                             const char      *seat_id,
+                             const char      *session_id)
+ {
+@@ -361,6 +453,217 @@ gdm_activate_session_by_id (GDBusConnect
+         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
++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
++
++gboolean
++activate_session_id_for_systemd (GDBusConnection *connection,
++                                 const char      *seat_id,
++                                 const char      *session_id)
++{
++        GError *local_error = NULL;
++        GVariant *reply;
++
++        reply = g_dbus_connection_call_sync (connection,
+                                              "org.freedesktop.login1",
+                                              "/org/freedesktop/login1",
+                                              "org.freedesktop.login1.Manager",
+@@ -382,8 +685,8 @@ gdm_activate_session_by_id (GDBusConnect
+ }
+ 
+ gboolean
+-gdm_get_login_window_session_id (const char  *seat_id,
+-                                 char       **session_id)
++get_login_window_session_id_for_systemd (const char  *seat_id,
++                                         char       **session_id)
+ {
+         gboolean   ret;
+         int        res, i;
+@@ -476,15 +779,14 @@ out:
+ }
+ 
+ static gboolean
+-goto_login_session (GDBusConnection  *connection,
+-                    GError          **error)
++goto_login_session_for_systemd (GDBusConnection  *connection,
++                                GError          **error)
+ {
+         gboolean        ret;
+         int             res;
+         char           *our_session;
+         char           *session_id;
+         char           *seat_id;
+-        GError         *local_error = NULL;
+ 
+         ret = FALSE;
+         session_id = NULL;
+@@ -497,8 +799,10 @@ goto_login_session (GDBusConnection  *co
+          * since the data allocated is from libsystemd-logind, which
+          * does not use GLib's g_malloc (). */
+ 
+-        if (!gdm_find_display_session (0, getuid (), &our_session, &local_error)) {
+-                g_propagate_prefixed_error (error, local_error, _("Could not identify the current session: "));
++        res = sd_pid_get_session (0, &our_session);
++        if (res < 0) {
++                g_debug ("failed to determine own session: %s", strerror (-res));
++                g_set_error (error, GDM_COMMON_ERROR, 0, _("Could not identify the current session."));
+ 
+                 return FALSE;
+         }
+@@ -530,9 +834,9 @@ goto_login_session (GDBusConnection  *co
+                 return FALSE;
+         }
+ 
+-        res = gdm_get_login_window_session_id (seat_id, &session_id);
++        res = get_login_window_session_id_for_systemd (seat_id, &session_id);
+         if (res && session_id != NULL) {
+-                res = gdm_activate_session_by_id (connection, seat_id, session_id);
++                res = activate_session_id_for_systemd (connection, seat_id, session_id);
+ 
+                 if (res) {
+                         ret = TRUE;
+@@ -551,6 +855,7 @@ goto_login_session (GDBusConnection  *co
+ 
+         return ret;
+ }
++#endif
+ 
+ gboolean
+ gdm_goto_login_session (GError **error)
+@@ -566,7 +871,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
+@@ -842,135 +1157,3 @@ gdm_shell_expand (const char *str,
+         }
+         return g_string_free (s, FALSE);
+ }
+-
+-static gboolean
+-_systemd_session_is_graphical (const char *session_id)
+-{
+-        const gchar * const graphical_session_types[] = { "wayland", "x11", "mir", NULL };
+-        int saved_errno;
+-        g_autofree gchar *type = NULL;
+-
+-        saved_errno = sd_session_get_type (session_id, &type);
+-        if (saved_errno < 0) {
+-                g_warning ("Couldn't get type for session '%s': %s",
+-                           session_id,
+-                           g_strerror (-saved_errno));
+-                return FALSE;
+-        }
+-
+-        if (!g_strv_contains (graphical_session_types, type)) {
+-                g_debug ("Session '%s' is not a graphical session (type: '%s')",
+-                         session_id,
+-                         type);
+-                return FALSE;
+-        }
+-
+-        return TRUE;
+-}
+-
+-static gboolean
+-_systemd_session_is_active (const char *session_id)
+-{
+-        const gchar * const active_states[] = { "active", "online", NULL };
+-        int saved_errno;
+-        g_autofree gchar *state = NULL;
+-
+-        /*
+-         * display sessions can be 'closing' if they are logged out but some
+-         * processes are lingering; we shouldn't consider these (this is
+-         * checking for a race condition since we specified
+-         * GDM_SYSTEMD_SESSION_REQUIRE_ONLINE)
+-         */
+-        saved_errno = sd_session_get_state (session_id, &state);
+-        if (saved_errno < 0) {
+-                g_warning ("Couldn't get state for session '%s': %s",
+-                           session_id,
+-                           g_strerror (-saved_errno));
+-                return FALSE;
+-        }
+-
+-        if (!g_strv_contains (active_states, state)) {
+-                g_debug ("Session '%s' is not active or online", session_id);
+-                return FALSE;
+-        }
+-
+-        return TRUE;
+-}
+-
+-gboolean
+-gdm_find_display_session (GPid        pid,
+-                          const uid_t uid,
+-                          char      **out_session_id,
+-                          GError    **error)
+-{
+-        char *local_session_id = NULL;
+-        g_auto(GStrv) sessions = NULL;
+-        int n_sessions;
+-        int res;
+-
+-        g_return_val_if_fail (out_session_id != NULL, FALSE);
+-
+-        /* First try to look up the session using the pid. We need this
+-         * at least for the greeter, because it currently runs multiple
+-         * sessions under the same user.
+-         * See also commit 2b52d8933c8ab38e7ee83318da2363d00d8c5581
+-         * which added an explicit dbus-run-session for all but seat0.
+-         */
+-        res = sd_pid_get_session (pid, &local_session_id);
+-        if (res >= 0) {
+-                g_debug ("GdmCommon: Found session %s for PID %d, using", local_session_id, pid);
+-
+-                *out_session_id = g_strdup (local_session_id);
+-                free (local_session_id);
+-
+-                return TRUE;
+-        } else {
+-                if (res != -ENODATA)
+-                        g_warning ("GdmCommon: Failed to retrieve session information for pid %d: %s",
+-                                   pid, strerror (-res));
+-        }
+-
+-        g_debug ("Finding a graphical session for user %d", uid);
+-
+-        n_sessions = sd_uid_get_sessions (uid,
+-                                          GDM_SYSTEMD_SESSION_REQUIRE_ONLINE,
+-                                          &sessions);
+-
+-        if (n_sessions < 0) {
+-                g_set_error (error,
+-                             GDM_COMMON_ERROR,
+-                             0,
+-                             "Failed to get sessions for user %d",
+-                             uid);
+-                return FALSE;
+-        }
+-
+-        for (int i = 0; i < n_sessions; ++i) {
+-                g_debug ("Considering session '%s'", sessions[i]);
+-
+-                if (!_systemd_session_is_graphical (sessions[i]))
+-                        continue;
+-
+-                if (!_systemd_session_is_active (sessions[i]))
+-                        continue;
+-
+-                /*
+-                 * We get the sessions from newest to oldest, so take the last
+-                 * one we find that's good
+-                 */
+-                local_session_id = sessions[i];
+-        }
+-
+-        if (local_session_id == NULL) {
+-                g_set_error (error,
+-                             GDM_COMMON_ERROR,
+-                             0,
+-                             "Could not find a graphical session for user %d",
+-                             uid);
+-                return FALSE;
+-        }
+-
+-        *out_session_id = g_strdup (local_session_id);
+-
+-        return TRUE;
+-}
Index: pkgsrc/x11/libgdm/patches/patch-common_gdm-common_h
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-common_gdm-common_h:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-common_gdm-common_h Fri Apr 16 13:57:52 2021
@@ -0,0 +1,54 @@
+$NetBSD: patch-common_gdm-common_h,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$OpenBSD: patch-common_gdm-common_h,v 1.5 2020/05/14 15:25:54 ajacoutot Exp $
+
+REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
+From fcba1e1a5d556ce7b52101dbd2d1ba4a19469161 Mon Sep 17 00:00:00 2001
+From: Iain Lane <iain%orangesquash.org.uk@localhost>
+Date: Fri, 5 Jan 2018 11:53:34 +0000
+Subject: [PATCH] manager: Find user's current graphical session, not session of caller
+
+REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
+From 9be58c9ec9a3a411492a5182ac4b0d51fdc3a323 Mon Sep 17 00:00:00 2001
+From: Ray Strode <rstrode%redhat.com@localhost>
+Date: Fri, 12 Jun 2015 13:48:52 -0400
+Subject: require logind support
+
+Index: common/gdm-common.h
+--- common/gdm-common.h.orig   2020-05-04 20:11:25.000000000 +0000
++++ common/gdm-common.h
+@@ -37,6 +37,11 @@
+ 
+ #define GDM_SYSTEMD_SESSION_REQUIRE_ONLINE 0
+ 
++/* check if logind is running */
++#define LOGIND_RUNNING() (access("/run/systemd/seats/", F_OK) >= 0)
++
++#define GDM_SYSTEMD_SESSION_REQUIRE_ONLINE 0
++
+ GQuark gdm_common_error_quark (void);
+ #define GDM_COMMON_ERROR gdm_common_error_quark()
+ 
+@@ -51,11 +56,6 @@ int            gdm_wait_on_and_disown_pi
+ int            gdm_signal_pid            (int pid,
+                                           int signal);
+ 
+-gboolean       gdm_find_display_session (GPid        pid,
+-                                         const uid_t uid,
+-                                         char      **out_session_id,
+-                                         GError    **error);
+-
+ gboolean       gdm_get_pwent_for_name    (const char     *name,
+                                           struct passwd **pwentp);
+ 
+@@ -83,10 +83,6 @@ char *        gdm_shell_expand          
+                                            GdmExpandVarFunc expand_func,
+                                            gpointer user_data);
+ 
+-gboolean      gdm_activate_session_by_id (GDBusConnection *connection,
+-                                          const char      *seat_id,
+-                                          const char      *session_id);
+-
+ G_END_DECLS
+ 
+ #endif /* _GDM_COMMON_H */
Index: pkgsrc/x11/libgdm/patches/patch-common_gdm-log_c
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-common_gdm-log_c:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-common_gdm-log_c    Fri Apr 16 13:57:52 2021
@@ -0,0 +1,59 @@
+$NetBSD: patch-common_gdm-log_c,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$OpenBSD: patch-common_gdm-log_c,v 1.2 2018/04/24 08:37:00 ajacoutot Exp $
+
+REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
+From 9be58c9ec9a3a411492a5182ac4b0d51fdc3a323 Mon Sep 17 00:00:00 2001
+From: Ray Strode <rstrode%redhat.com@localhost>
+Date: Fri, 12 Jun 2015 13:48:52 -0400
+Subject: require logind support
+
+Index: common/gdm-log.c
+--- common/gdm-log.c.orig
++++ common/gdm-log.c
+@@ -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>
+@@ -125,12 +127,35 @@ gdm_log_set_debug (gboolean debug)
+ void
+ gdm_log_init (void)
+ {
++      const char *prg_name;
++      int         options;
++
+         if (initialized)
+                 return;
+ 
+         initialized = TRUE;
+ 
++#ifdef WITH_SYSTEMD
++        is_sd_booted = sd_booted () > 0;
++#endif
++
+         g_log_set_default_handler (gdm_log_default_handler, NULL);
++
++        /* Only set up syslog if !systemd, otherwise with systemd
++         * enabled, we keep the default GLib log handler which goes to
++         * stderr, which is routed to the appropriate place in the
++         * systemd service file.
++         */
++        if (!is_sd_booted) {
++                prg_name = g_get_prgname ();
++
++                options = LOG_PID;
++#ifdef LOG_PERROR
++                options |= LOG_PERROR;
++#endif
++
++                openlog (prg_name, options, LOG_DAEMON);
++        }
+ }
+ 
+ void
Index: pkgsrc/x11/libgdm/patches/patch-common_meson.build
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-common_meson.build:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-common_meson.build  Fri Apr 16 13:57:52 2021
@@ -0,0 +1,14 @@
+$NetBSD: patch-common_meson.build,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+Disable Linux-only systemd dependency
+
+--- common/meson.build.orig    2020-12-15 18:16:43.000000000 +0000
++++ common/meson.build
+@@ -11,7 +11,6 @@ libgdmcommon_src = files(
+ )
+ 
+ libgdmcommon_deps = [
+-  libsystemd_dep,
+   gobject_dep,
+   gio_dep,
+   gio_unix_dep,
Index: pkgsrc/x11/libgdm/patches/patch-daemon_gdm-display-access-file.c
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-daemon_gdm-display-access-file.c:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-daemon_gdm-display-access-file.c    Fri Apr 16 13:57:52 2021
@@ -0,0 +1,19 @@
+$NetBSD: patch-daemon_gdm-display-access-file.c,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+HOST_NAME_MAX is not available on NetBSD
+Maybe replace this with MAXHOSTNAMELEN?
+
+--- daemon/gdm-display-access-file.c.orig      2020-12-15 18:16:43.000000000 +0000
++++ daemon/gdm-display-access-file.c
+@@ -441,9 +441,9 @@ _get_auth_info_for_display (GdmDisplayAc
+                  *
+                  * https://bugs.freedesktop.org/show_bug.cgi?id=43425
+                  */
+-                char localhost[HOST_NAME_MAX + 1] = "";
++                char localhost[_POSIX_HOST_NAME_MAX + 1] = "";
+                 *family = FamilyLocal;
+-                if (gethostname (localhost, HOST_NAME_MAX) == 0) {
++                if (gethostname (localhost, _POSIX_HOST_NAME_MAX) == 0) {
+                         *address = g_strdup (localhost);
+                 } else {
+                         *address = g_strdup ("localhost");
Index: pkgsrc/x11/libgdm/patches/patch-daemon_gdm-display_c
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-daemon_gdm-display_c:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-daemon_gdm-display_c        Fri Apr 16 13:57:52 2021
@@ -0,0 +1,20 @@
+$NetBSD: patch-daemon_gdm-display_c,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$OpenBSD: patch-daemon_gdm-display_c,v 1.8 2019/11/02 15:34:07 ajacoutot Exp $
+
+XXX fix+push upstream
+
+Index: daemon/gdm-display.c
+--- daemon/gdm-display.c.orig
++++ daemon/gdm-display.c
+@@ -242,8 +242,8 @@ setup_xhost_auth (XHostAddress              *host_entr
+         host_entries[1].address   = "localuser\0" GDM_USERNAME;
+         host_entries[1].length    = sizeof ("localuser\0" GDM_USERNAME);
+         host_entries[2].family    = FamilyServerInterpreted;
+-        host_entries[2].address   = "localuser\0gnome-initial-setup";
+-        host_entries[2].length    = sizeof ("localuser\0gnome-initial-setup");
++        host_entries[2].address   = "localuser\0_gnome-initial-setup";
++        host_entries[2].length    = sizeof ("localuser\0_gnome-initial-setup");
+ }
+ 
+ gboolean
Index: pkgsrc/x11/libgdm/patches/patch-daemon_gdm-launch-environment_c
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-daemon_gdm-launch-environment_c:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-daemon_gdm-launch-environment_c     Fri Apr 16 13:57:52 2021
@@ -0,0 +1,49 @@
+$NetBSD: patch-daemon_gdm-launch-environment_c,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$OpenBSD: patch-daemon_gdm-launch-environment_c,v 1.10 2019/11/02 15:34:07 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
+
+Index: daemon/gdm-launch-environment.c
+--- daemon/gdm-launch-environment.c.orig
++++ daemon/gdm-launch-environment.c
+@@ -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 GDM_SESSION_MODE "gdm"
+ #define INITIAL_SETUP_SESSION_MODE "initial-setup"
+ #define GNOME_SESSION_SESSIONS_PATH DATADIR "/gnome-session/sessions"
+@@ -212,6 +212,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));
+         }
+@@ -237,6 +240,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
Index: pkgsrc/x11/libgdm/patches/patch-daemon_gdm-local-display-factory_c
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-daemon_gdm-local-display-factory_c:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-daemon_gdm-local-display-factory_c  Fri Apr 16 13:57:52 2021
@@ -0,0 +1,204 @@
+$NetBSD: patch-daemon_gdm-local-display-factory_c,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$OpenBSD: patch-daemon_gdm-local-display-factory_c,v 1.13 2019/11/02 15:34:07 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
+
+Index: daemon/gdm-local-display-factory.c
+--- daemon/gdm-local-display-factory.c.orig    2021-03-16 20:48:04.000000000 +0000
++++ daemon/gdm-local-display-factory.c
+@@ -28,7 +28,9 @@
+ #include <glib-object.h>
+ #include <gio/gio.h>
+ 
++#ifdef WITH_SYSTEMD
+ #include <systemd/sd-login.h>
++#endif
+ 
+ #include "gdm-common.h"
+ #include "gdm-manager.h"
+@@ -42,6 +44,8 @@
+ #include "gdm-local-display.h"
+ #include "gdm-legacy-display.h"
+ 
++#define CK_SEAT1_PATH                       "/org/freedesktop/ConsoleKit/Seat1"
++
+ #define GDM_DBUS_PATH                       "/org/gnome/DisplayManager"
+ #define GDM_LOCAL_DISPLAY_FACTORY_DBUS_PATH GDM_DBUS_PATH "/LocalDisplayFactory"
+ #define GDM_MANAGER_DBUS_NAME               "org.gnome.DisplayManager.LocalDisplayFactory"
+@@ -60,9 +64,10 @@ struct _GdmLocalDisplayFactory
+ 
+         /* FIXME: this needs to be per seat? */
+         guint            num_failures;
+-
++#ifdef WITH_SYSTEMD
+         guint            seat_new_id;
+         guint            seat_removed_id;
++#endif
+         guint            seat_properties_changed_id;
+ 
+         gboolean         seat0_graphics_check_timed_out;
+@@ -89,8 +94,9 @@ static void     ensure_display_for_seat 
+ static void     on_display_status_changed               (GdmDisplay                  *display,
+                                                          GParamSpec                  *arg1,
+                                                          GdmLocalDisplayFactory      *factory);
+-
++#ifdef WITH_SYSTEMD
+ static gboolean gdm_local_display_factory_sync_seats    (GdmLocalDisplayFactory *factory);
++#endif
+ static gpointer local_display_factory_object = NULL;
+ static gboolean lookup_by_session_id (const char *id,
+                                       GdmDisplay *display,
+@@ -235,7 +241,7 @@ gdm_local_display_factory_create_transie
+ 
+         g_debug ("GdmLocalDisplayFactory: Creating transient display");
+ 
+-#ifdef ENABLE_USER_DISPLAY_SERVER
++#if defined(ENABLE_USER_DISPLAY_SERVER) && defined(WITH_SYSTEMD)
+         display = gdm_local_display_new ();
+         if (gdm_local_display_factory_use_wayland ())
+                 g_object_set (G_OBJECT (display), "session-type", "wayland", NULL);
+@@ -376,7 +382,7 @@ on_display_status_changed (GdmDisplay   
+                         /* reset num failures */
+                         factory->num_failures = 0;
+ 
+-                        gdm_local_display_factory_sync_seats (factory);
++                      ensure_display_for_seat (factory, seat_id);
+                 }
+                 break;
+         case GDM_DISPLAY_FAILED:
+@@ -480,9 +486,10 @@ ensure_display_for_seat (GdmLocalDisplay
+         const char *session_type = "wayland";
+         GdmDisplayStore *store;
+         GdmDisplay      *display = NULL;
++#ifdef WITH_SYSTEMD
+         g_autofree char *login_session_id = NULL;
+ 
+-        ret = sd_seat_can_graphical (seat_id);
++      ret = sd_seat_can_graphical (seat_id);
+ 
+         if (ret < 0) {
+                 g_critical ("Failed to query CanGraphical information for seat %s", seat_id);
+@@ -496,7 +503,7 @@ ensure_display_for_seat (GdmLocalDisplay
+                 g_debug ("GdmLocalDisplayFactory: System supports graphics");
+                 seat_supports_graphics = TRUE;
+         }
+-
++#endif
+         if (g_strcmp0 (seat_id, "seat0") == 0) {
+                 is_seat0 = TRUE;
+ 
+@@ -575,7 +582,7 @@ ensure_display_for_seat (GdmLocalDisplay
+                 g_debug ("GdmLocalDisplayFactory: display already created");
+                 return;
+         }
+-
++#ifdef WITH_SYSTEMD
+         /* If we already have a login window, switch to it */
+         if (gdm_get_login_window_session_id (seat_id, &login_session_id)) {
+                 GdmDisplay *display;
+@@ -589,14 +596,14 @@ ensure_display_for_seat (GdmLocalDisplay
+                         g_object_set (G_OBJECT (display), "status", GDM_DISPLAY_MANAGED, NULL);
+                         g_debug ("GdmLocalDisplayFactory: session %s found, activating.",
+                                  login_session_id);
+-                        gdm_activate_session_by_id (factory->connection, seat_id, login_session_id);
++                        activate_session_by_id (factory->connection, seat_id, login_session_id);
+                         return;
+                 }
+         }
+-
++#endif
+         g_debug ("GdmLocalDisplayFactory: Adding display on seat %s", seat_id);
+ 
+-#ifdef ENABLE_USER_DISPLAY_SERVER
++#if defined(ENABLE_USER_DISPLAY_SERVER) && defined(WITH_SYSTEMD)
+         if (is_seat0) {
+                 display = gdm_local_display_new ();
+                 if (session_type != NULL) {
+@@ -627,7 +634,7 @@ ensure_display_for_seat (GdmLocalDisplay
+ 
+         return;
+ }
+-
++#ifdef WITH_SYSTEMD
+ static void
+ delete_display (GdmLocalDisplayFactory *factory,
+                 const char             *seat_id) {
+@@ -791,7 +798,7 @@ lookup_by_tty (const char *id,
+         return g_strcmp0 (tty_to_check, tty_to_find) == 0;
+ }
+ 
+-#if defined(ENABLE_USER_DISPLAY_SERVER)
++#if defined(ENABLE_USER_DISPLAY_SERVER) && defined(WITH_SYSTEMD)
+ static void
+ maybe_stop_greeter_in_background (GdmLocalDisplayFactory *factory,
+                                   GdmDisplay             *display)
+@@ -1046,7 +1053,7 @@ gdm_local_display_factory_stop_monitor (
+         }
+ #endif
+ }
+-
++#endif
+ static void
+ on_display_added (GdmDisplayStore        *display_store,
+                   const char             *id,
+@@ -1079,6 +1086,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);
+@@ -1097,8 +1105,15 @@ gdm_local_display_factory_start (GdmDisp
+                                  factory,
+                                  0);
+ 
+-        gdm_local_display_factory_start_monitor (factory);
+-        return gdm_local_display_factory_sync_seats (factory);
++#ifdef WITH_SYSTEMD
++        if (LOGIND_RUNNING()) {
++                gdm_local_display_factory_start_monitor (factory);
++              return gdm_local_display_factory_sync_seats (factory);
++        }
++#endif
++      /* On ConsoleKit just create Seat1, and that's it. */
++        ensure_display_for_seat (factory, CK_SEAT1_PATH);
++      return TRUE;
+ }
+ 
+ static gboolean
+@@ -1108,9 +1123,9 @@ gdm_local_display_factory_stop (GdmDispl
+         GdmDisplayStore *store;
+ 
+         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));
+ 
+         g_signal_handlers_disconnect_by_func (G_OBJECT (store),
+@@ -1262,9 +1277,9 @@ gdm_local_display_factory_finalize (GObj
+         g_clear_object (&factory->skeleton);
+ 
+         g_hash_table_destroy (factory->used_display_numbers);
+-
++#ifdef WITH_SYSTEMD
+         gdm_local_display_factory_stop_monitor (factory);
+-
++#endif
+         G_OBJECT_CLASS (gdm_local_display_factory_parent_class)->finalize (object);
+ }
+ 
Index: pkgsrc/x11/libgdm/patches/patch-daemon_gdm-manager_c
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-daemon_gdm-manager_c:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-daemon_gdm-manager_c        Fri Apr 16 13:57:52 2021
@@ -0,0 +1,829 @@
+$NetBSD: patch-daemon_gdm-manager_c,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$OpenBSD: patch-daemon_gdm-manager_c,v 1.24 2020/05/14 15:25:54 ajacoutot Exp $
+
+REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
+From fcba1e1a5d556ce7b52101dbd2d1ba4a19469161 Mon Sep 17 00:00:00 2001
+From: Iain Lane <iain%orangesquash.org.uk@localhost>
+Date: Fri, 5 Jan 2018 11:53:34 +0000
+Subject: [PATCH] manager: Find user's current graphical session, not session of caller
+
+REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
+From 21905303afbd508f3bf599ad219c9209413c53a2 Mon Sep 17 00:00:00 2001
+From: Ray Strode <rstrode%redhat.com@localhost>
+Date: Wed, 5 Apr 2017 12:11:20 -0400
+Subject: manager: stop transient greeter session when done with it
+
+REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
+From 22c332baaf8ad6d7082c5b01250bae70934c2fd1 Mon Sep 17 00:00:00 2001
+From: Ray Strode <rstrode%redhat.com@localhost>
+Date: Tue, 4 Apr 2017 17:07:04 -0400
+Subject: manager: make sure we end up on a login screen
+
+REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
+From 1ac67f522f5690c27023d98096ca817f12f7eb88 Mon Sep 17 00:00:00 2001
+From: Ray Strode <rstrode%redhat.com@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
+
+Index: daemon/gdm-manager.c
+--- daemon/gdm-manager.c.orig  2021-03-16 20:48:04.000000000 +0000
++++ daemon/gdm-manager.c
+@@ -36,7 +36,9 @@
+ 
+ #include <act/act-user-manager.h>
+ 
++#ifdef WITH_SYSTEMD
+ #include <systemd/sd-login.h>
++#endif
+ 
+ #include "gdm-common.h"
+ 
+@@ -61,9 +63,18 @@
+ #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 ALREADY_RAN_INITIAL_SETUP_ON_THIS_BOOT GDM_RUN_DIR "/gdm.ran-initial-setup"
+ 
++#define CK_NAME      "org.freedesktop.ConsoleKit"
++#define CK_PATH      "/org/freedesktop/ConsoleKit"
++#define CK_INTERFACE "org.freedesktop.ConsoleKit"
++
++#define CK_MANAGER_PATH      "/org/freedesktop/ConsoleKit/Manager"
++#define CK_MANAGER_INTERFACE "org.freedesktop.ConsoleKit.Manager"
++#define CK_SEAT_INTERFACE    "org.freedesktop.ConsoleKit.Seat"
++#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
++
+ typedef struct
+ {
+         GdmManager *manager;
+@@ -205,9 +216,10 @@ plymouth_quit_without_transition (void)
+ }
+ #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;
+@@ -232,11 +244,61 @@ get_session_id_for_pid (pid_t    pid,
+                 return NULL;
+         }
+ }
++#endif
++
++#ifdef WITH_CONSOLE_KIT
++static char *
++get_session_id_for_pid_consolekit (GDBusConnection  *connection,
++                                   pid_t             pid,
++                                   GError          **error)
++{
++        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;
+ 
+@@ -253,6 +315,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,
+@@ -266,10 +382,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;
+@@ -294,29 +450,140 @@ is_login_session (GdmManager  *self,
+         g_free (session_class);
+         return TRUE;
+ }
++#endif
+ 
+ static gboolean
+-session_unlock (GdmManager *manager,
+-                const char *ssid)
++is_login_session (GdmManager       *self,
++                  GDBusConnection  *connection,
++                  const char       *session_id,
++                  GError          **error)
++{
++#ifdef WITH_SYSTEMD
++        if (LOGIND_RUNNING()) {
++                return is_systemd_login_session (self, session_id, error);
++        }
++#endif
++
++#ifdef WITH_CONSOLE_KIT
++        return is_consolekit_login_session (self, connection, session_id, error);
++#endif
++
++        return FALSE;
++}
++
++#ifdef WITH_SYSTEMD
++static gboolean
++activate_session_id_for_systemd (GdmManager   *manager,
++                                 const char *seat_id,
++                                 const char *session_id)
+ {
+         GError *error = NULL;
+         GVariant *reply;
+ 
+-        g_debug ("Unlocking session %s", ssid);
+-
+         reply = g_dbus_connection_call_sync (manager->priv->connection,
+                                              "org.freedesktop.login1",
+                                              "/org/freedesktop/login1",
+                                              "org.freedesktop.login1.Manager",
+-                                             "UnlockSession",
+-                                             g_variant_new ("(s)", ssid),
++                                             "ActivateSessionOnSeat",
++                                             g_variant_new ("(ss)", session_id, seat_id),
++                                             NULL, /* expected reply */
++                                             G_DBUS_CALL_FLAGS_NONE,
++                                             -1,
++                                             NULL,
++                                             &error);
++        if (reply == NULL) {
++                g_debug ("GdmManager: logind 'ActivateSessionOnSeat' %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
++
++#ifdef WITH_CONSOLE_KIT
++static gboolean
++activate_session_id_for_ck (GdmManager *manager,
++                            const char *seat_id,
++                            const char *session_id)
++{
++        GError *error = NULL;
++        GVariant *reply;
++
++        reply = g_dbus_connection_call_sync (manager->priv->connection,
++                                             CK_NAME,
++                                             seat_id,
++                                             "org.freedesktop.ConsoleKit.Seat",
++                                             "ActivateSession",
++                                             g_variant_new ("(o)", session_id),
++                                             NULL, /* expected reply */
++                                             G_DBUS_CALL_FLAGS_NONE,
++                                             -1,
++                                             NULL,
++                                             &error);
++        if (reply == NULL) {
++                g_debug ("GdmManager: ConsoleKit %s raised:\n %s\n\n",
++                         g_dbus_error_get_remote_error (error), error->message);
++                g_error_free (error);
++
++                /* It is very likely that the "error" just reported is
++                 * that the session is already active.  Unfortunately,
++                 * ConsoleKit doesn't use proper error codes and it
++                 * translates the error message, so we have no real way
++                 * to detect this case...
++                 */
++                return TRUE;
++        }
++
++        g_variant_unref (reply);
++
++        return TRUE;
++}
++#endif
++
++static gboolean
++activate_session_id (GdmManager *manager,
++                     const char *seat_id,
++                     const char *session_id)
++{
++
++#ifdef WITH_SYSTEMD
++        if (LOGIND_RUNNING()) {
++                return activate_session_id_for_systemd (manager, seat_id, session_id);
++        }
++#endif
++
++#ifdef WITH_CONSOLE_KIT
++        return activate_session_id_for_ck (manager, seat_id, session_id);
++#else
++       return FALSE;
++#endif
++}
++
++#ifdef WITH_CONSOLE_KIT
++static gboolean
++session_unlock_for_ck (GdmManager *manager,
++                       const char *ssid)
++{
++        GError *error = NULL;
++        GVariant *reply;
++
++        reply = g_dbus_connection_call_sync (manager->priv->connection,
++                                             CK_NAME,
++                                             ssid,
++                                             CK_SESSION_INTERFACE,
++                                             "Unlock",
++                                             NULL, /* parameters */
+                                              NULL, /* expected reply */
+                                              G_DBUS_CALL_FLAGS_NONE,
+                                              -1,
+                                              NULL,
+                                              &error);
+         if (reply == NULL) {
+-                g_debug ("GdmManager: logind 'UnlockSession' %s raised:\n %s\n\n",
++                g_debug ("GdmManager: ConsoleKit %s raised:\n %s\n\n",
+                          g_dbus_error_get_remote_error (error), error->message);
+                 g_error_free (error);
+                 return FALSE;
+@@ -326,6 +593,27 @@ session_unlock (GdmManager *manager,
+ 
+         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,
+@@ -374,10 +662,43 @@ find_session_for_user_on_seat (GdmManage
+         return NULL;
+ }
+ 
++#ifdef WITH_CONSOLE_KIT
+ static gboolean
+-is_remote_session (GdmManager  *self,
+-                   const char  *session_id,
+-                   GError     **error)
++is_consolekit_remote_session (GdmManager       *self,
++                             GDBusConnection  *connection,
++                             const char       *session_id,
++                             GError          **error)
++{
++        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_systemd_remote_session (GdmManager  *self,
++                           const char  *session_id,
++                           GError     **error)
+ {
+         char *seat;
+         int ret;
+@@ -403,10 +724,12 @@ is_remote_session (GdmManager  *self,
+ 
+         return is_remote;
+ }
++#endif
+ 
++#ifdef WITH_SYSTEMD
+ static char *
+-get_seat_id_for_session_id (const char  *session_id,
+-                            GError     **error)
++get_seat_id_for_systemd_session_id (const char  *session_id,
++                                    GError     **error)
+ {
+         int ret;
+         char *seat, *out_seat;
+@@ -431,11 +754,85 @@ get_seat_id_for_session_id (const char  
+ 
+         return out_seat;
+ }
++#endif
++
++static gboolean
++is_remote_session (GdmManager       *self,
++                  GDBusConnection  *connection,
++                  const char       *session_id,
++                  GError          **error)
++{
++#ifdef WITH_SYSTEMD
++        if (LOGIND_RUNNING()) {
++                return is_systemd_remote_session (self, session_id, error);
++        }
++#endif
++
++#ifdef WITH_CONSOLE_KIT
++        return is_consolekit_remote_session (self, connection, session_id, error);
++#endif
++
++        return FALSE;
++}
+ 
++#ifdef WITH_CONSOLE_KIT
+ static char *
+-get_tty_for_session_id (const char  *session_id,
+-                        GError     **error)
++get_seat_id_for_consolekit_session_id (GDBusConnection  *connection,
++                                       const char       *session_id,
++                                       GError          **error)
+ {
++        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;
+ 
+@@ -458,6 +855,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,
+@@ -501,11 +912,10 @@ get_display_and_details_for_bus_sender (
+                 goto out;
+         }
+ 
+-        ret = gdm_find_display_session (pid, caller_uid, &session_id, &error);
++        session_id = get_session_id_for_pid (connection, pid, &error);
+ 
+-        if (!ret) {
+-                g_debug ("GdmManager: Unable to find display session for uid %d: %s",
+-                         (int) caller_uid,
++        if (session_id == NULL) {
++                g_debug ("GdmManager: Error while retrieving session id for sender: %s",
+                          error->message);
+                 g_error_free (error);
+                 goto out;
+@@ -516,7 +926,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",
+@@ -526,7 +936,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);
+@@ -543,7 +953,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",
+@@ -553,7 +963,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",
+@@ -610,7 +1020,7 @@ switch_to_compatible_user_session (GdmMa
+         if (existing_session != NULL) {
+                 ssid_to_activate = gdm_session_get_session_id (existing_session);
+                 if (seat_id != NULL) {
+-                        res = gdm_activate_session_by_id (manager->priv->connection, seat_id, ssid_to_activate);
++                        res = activate_session_id (manager, seat_id, ssid_to_activate);
+                         if (! res) {
+                                 g_debug ("GdmManager: unable to activate session: %s", ssid_to_activate);
+                                 goto out;
+@@ -712,29 +1122,6 @@ out:
+         return recorded;
+ }
+ 
+-static GdmSession *
+-find_user_session_for_display (GdmManager *self,
+-                               GdmDisplay *display)
+-{
+-
+-        GList *node = self->priv->user_sessions;
+-
+-        while (node != NULL) {
+-                GdmSession *session = node->data;
+-                GdmDisplay *candidate_display;
+-                GList *next_node = node->next;
+-
+-                candidate_display = get_display_for_user_session (session);
+-
+-                if (candidate_display == display)
+-                        return session;
+-
+-                node = next_node;
+-        }
+-
+-        return NULL;
+-}
+-
+ static gboolean
+ gdm_manager_handle_register_display (GdmDBusManager        *manager,
+                                      GDBusMethodInvocation *invocation,
+@@ -774,7 +1161,7 @@ gdm_manager_handle_register_display (Gdm
+                 }
+         }
+ 
+-        session = find_user_session_for_display (self, display);
++        session = get_user_session_for_display (display);
+ 
+         if (session != NULL) {
+                 GPid pid;
+@@ -981,7 +1368,8 @@ on_reauthentication_client_rejected (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");
+ 
+@@ -1200,16 +1588,19 @@ 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);
+-
+-        if (g_strcmp0 (seat_id, "seat0") != 0) {
+-            is_on_seat0 = FALSE;
+-        }
++#ifdef WITH_SYSTEMD
++        if (LOGIND_RUNNING()) {
++                char *seat_id = NULL;
++                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;
+ }
+ 
+@@ -2019,11 +2410,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
+@@ -2033,25 +2470,6 @@ on_session_reauthenticated (GdmSession *
+ {
+         gboolean fail_if_already_switched = FALSE;
+ 
+-        if (gdm_session_get_display_mode (session) == GDM_SESSION_DISPLAY_MODE_REUSE_VT) {
+-                const char *seat_id;
+-                char *session_id;
+-
+-                seat_id = gdm_session_get_display_seat_id (session);
+-                if (gdm_get_login_window_session_id (seat_id, &session_id)) {
+-                        GdmDisplay *display = gdm_display_store_find (manager->priv->display_store,
+-                                                                      lookup_by_session_id,
+-                                                                      (gpointer) session_id);
+-
+-                        if (display != NULL) {
+-                                gdm_display_stop_greeter_session (display);
+-                                gdm_display_unmanage (display);
+-                                gdm_display_finish (display);
+-                        }
+-                        g_free (session_id);
+-                }
+-        }
+-
+         /* There should already be a session running, so jump to its
+          * VT. In the event we're already on the right VT, (i.e. user
+          * used an unlock screen instead of a user switched login screen),
Index: pkgsrc/x11/libgdm/patches/patch-daemon_gdm-server_c
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-daemon_gdm-server_c:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-daemon_gdm-server_c Fri Apr 16 13:57:52 2021
@@ -0,0 +1,283 @@
+$NetBSD: patch-daemon_gdm-server_c,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$OpenBSD: patch-daemon_gdm-server_c,v 1.12 2019/05/08 21:58:04 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
+
+Index: daemon/gdm-server.c
+--- daemon/gdm-server.c.orig   2020-05-04 20:11:25.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>
+@@ -84,6 +86,7 @@ struct _GdmServer
+         char    *auth_file;
+ 
+         guint    child_watch_id;
++        guint    sigusr1_id;
+ 
+         gboolean is_initial;
+ };
+@@ -114,90 +117,74 @@ 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->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->display_name,
+-                        NULL, /* hostname */
+-                        server->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->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;
+-
+-                g_idle_add (got_sigusr1, GUINT_TO_POINTER (info.si_pid));
++        if (server->display_device == NULL) {
++                server->display_device =
++                    _gdm_server_query_ck_for_display_device (server);
++                g_object_notify (G_OBJECT (server), "display-device");
+         }
+ 
+-        return NULL;
++        return g_strdup (server->display_device);
+ }
+ 
+-static void
+-gdm_server_launch_sigusr1_thread_if_needed (void)
++static gboolean
++on_sigusr1 (gpointer user_data)
+ {
+-        static GThread *sigusr1_thread;
++        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->display_name,
++                        NULL, /* hostname */
++                        server->auth_file);
++
++        g_signal_emit (server, signals[READY], 0);
++        return FALSE;
+ }
+ 
+ static void
+@@ -218,7 +205,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
+@@ -234,6 +223,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 */
+@@ -256,8 +249,8 @@ gdm_server_init_command (GdmServer *serv
+         return;
+ 
+ fallback:
++#endif
+         server->command = g_strdup_printf (X_SERVER X_SERVER_ARG_FORMAT, verbosity, debug_options);
+-
+ }
+ 
+ static gboolean
+@@ -307,10 +300,12 @@ gdm_server_resolve_command_line (GdmServ
+                 argv[len++] = g_strdup (server->auth_file);
+         }
+ 
+-        if (server->display_seat_id != NULL) {
++#ifdef WITH_SYSTEMD
++        if (LOGIND_RUNNING() && server->priv->display_seat_id != NULL) {
+                 argv[len++] = g_strdup ("-seat");
+                 argv[len++] = g_strdup (server->display_seat_id);
+         }
++#endif
+ 
+         /* If we were compiled with Xserver >= 1.17 we need to specify
+          * '-listen tcp' as the X server dosen't listen on tcp sockets
+@@ -655,12 +650,6 @@ server_child_watch (GPid       pid,
+         g_object_unref (server);
+ }
+ 
+-static void
+-prune_active_servers_list (GdmServer *server)
+-{
+-        active_servers = g_slist_remove (active_servers, server);
+-}
+-
+ static gboolean
+ gdm_server_spawn (GdmServer    *server,
+                   const char   *vtarg,
+@@ -698,15 +687,6 @@ gdm_server_spawn (GdmServer    *server,
+         g_debug ("GdmServer: Starting X server process: %s", freeme);
+         g_free (freeme);
+ 
+-        active_servers = g_slist_append (active_servers, server);
+-
+-        g_object_weak_ref (G_OBJECT (server),
+-                           (GWeakNotify)
+-                           prune_active_servers_list,
+-                           server);
+-
+-        gdm_server_launch_sigusr1_thread_if_needed ();
+-
+         if (!g_spawn_async_with_pipes (NULL,
+                                        argv,
+                                        (char **)env->pdata,
+@@ -1043,6 +1023,10 @@ gdm_server_init (GdmServer *server)
+         server->pid = -1;
+ 
+         server->log_dir = g_strdup (LOGDIR);
++
++        server->sigusr1_id = g_unix_signal_add (SIGUSR1,
++                                                      on_sigusr1,
++                                                      server);
+ }
+ 
+ static void
+@@ -1055,6 +1039,9 @@ gdm_server_finalize (GObject *object)
+ 
+         server = GDM_SERVER (object);
+ 
++        if (server->sigusr1_id > 0)
++                g_source_remove (server->sigusr1_id);
++
+         gdm_server_stop (server);
+ 
+         g_free (server->command);
Index: pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session-record_c
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session-record_c:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session-record_c Fri Apr 16 13:57:52 2021
@@ -0,0 +1,144 @@
+$NetBSD: patch-daemon_gdm-session-record_c,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$OpenBSD: patch-daemon_gdm-session-record_c,v 1.11 2019/11/02 15:34:07 ajacoutot Exp $
+
+https://bugzilla.gnome.org/show_bug.cgi?id=722482
+
+Index: daemon/gdm-session-record.c
+--- daemon/gdm-session-record.c.orig   2020-05-04 20:11:25.000000000 +0000
++++ daemon/gdm-session-record.c
+@@ -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
+@@ -168,6 +181,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) && !defined(HAVE_GETUTXENT)
++        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,
+@@ -214,8 +305,9 @@ gdm_session_record_login (GPid          
+         setutxent();
+         pututxline (&session_record);
+         endutxent();
+-#elif defined(HAVE_LOGIN)
+-      login (&session_record);
++#else
++        if (strcmp (session_record.ut_name, "(unknown)") != 0)
++          write_utmp_login_manually (&session_record);
+ #endif
+ }
+ 
+@@ -259,8 +351,8 @@ gdm_session_record_logout (GPid         
+         setutxent();
+         pututxline (&session_record);
+         endutxent();
+-#elif defined(HAVE_LOGOUT)
+-        logout (session_record.ut_line);
++#else
++        write_utmp_logout_manually (session_record.ut_line);
+ #endif
+ }
+ 
Index: pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session-worker-job_c
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session-worker-job_c:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session-worker-job_c     Fri Apr 16 13:57:52 2021
@@ -0,0 +1,22 @@
+$NetBSD: patch-daemon_gdm-session-worker-job_c,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$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>
Index: pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session-worker_c
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session-worker_c:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session-worker_c Fri Apr 16 13:57:52 2021
@@ -0,0 +1,565 @@
+$NetBSD: patch-daemon_gdm-session-worker_c,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$OpenBSD: patch-daemon_gdm-session-worker_c,v 1.21 2020/05/14 15: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
+
+REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit)
+From 6942fb9b16bab7173bbd295fb19a9770289dbe0e Mon Sep 17 00:00:00 2001
+From: Tim Lunn <tim%feathertop.org@localhost>
+Date: Mon, 11 Apr 2016 23:18:10 +1000
+Subject: gdm-session: set PAM_TTY when initialising pam
+
+Index: daemon/gdm-session-worker.c
+--- daemon/gdm-session-worker.c.orig   2021-03-30 13:25:30.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>
+@@ -126,6 +130,10 @@ struct GdmSessionWorkerPrivate
+ 
+         int               exit_code;
+ 
++#ifdef WITH_CONSOLE_KIT
++        char             *session_cookie;
++#endif
++
+         pam_handle_t     *pam_handle;
+ 
+         GPid              child_pid;
+@@ -140,6 +148,7 @@ struct GdmSessionWorkerPrivate
+         char             *hostname;
+         char             *username;
+         char             *log_file;
++        char             *session_type;
+         char             *session_id;
+         uid_t             uid;
+         gid_t             gid;
+@@ -214,6 +223,204 @@ G_DEFINE_TYPE_WITH_CODE (GdmSessionWorke
+                                                 worker_interface_init)
+                          G_ADD_PRIVATE (GdmSessionWorker))
+ 
++#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 (&parameters, 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,
+@@ -665,7 +872,9 @@ gdm_session_worker_process_pam_message (
+         char    *user_answer;
+         gboolean res;
+         char    *utf8_msg;
++#ifdef PAM_RADIO_TYPE
+         char  *msg;
++#endif
+ 
+         if (response != NULL) {
+                 *response = NULL;
+@@ -915,6 +1124,7 @@ gdm_session_worker_stop_auditor (GdmSess
+         worker->priv->auditor = NULL;
+ }
+ 
++#ifdef WITH_SYSTEMD
+ static void
+ on_release_display (int signal)
+ {
+@@ -1057,6 +1267,7 @@ jump_to_vt (GdmSessionWorker  *worker,
+ 
+         close (active_vt_tty_fd);
+ }
++#endif
+ 
+ static void
+ gdm_session_worker_set_state (GdmSessionWorker      *worker,
+@@ -1161,7 +1372,6 @@ gdm_session_worker_initialize_pam (GdmSe
+ {
+         struct pam_conv        pam_conversation;
+         int                    error_code;
+-        char tty_string[256];
+ 
+         g_assert (worker->priv->pam_handle == NULL);
+ 
+@@ -1228,10 +1438,12 @@ gdm_session_worker_initialize_pam (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");
+@@ -1240,12 +1452,14 @@ gdm_session_worker_initialize_pam (GdmSe
+         g_debug ("GdmSessionWorker: state SETUP_COMPLETE");
+         gdm_session_worker_set_state (worker, GDM_SESSION_WORKER_STATE_SETUP_COMPLETE);
+ 
++#ifdef WITH_SYSTEMD
+         /* Temporarily set PAM_TTY with the login VT,
+            PAM_TTY will be reset with the users VT right before the user session is opened */
+         g_snprintf (tty_string, 256, "/dev/tty%d", GDM_INITIAL_VT);
+         pam_set_item (worker->priv->pam_handle, PAM_TTY, tty_string);
+         if (!display_is_local)
+                 worker->priv->password_is_required = TRUE;
++#endif
+ 
+  out:
+         if (error_code != PAM_SUCCESS) {
+@@ -1548,7 +1762,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;
+@@ -1800,6 +2014,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)
+@@ -1877,6 +2111,10 @@ 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);
+ 
+         worker->priv->child_pid = -1;
+@@ -2089,6 +2327,7 @@ 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. */
+@@ -2097,6 +2336,7 @@ gdm_session_worker_start_session (GdmSes
+                         jump_to_vt (worker, worker->priv->session_vt);
+                 }
+         }
++#endif
+ 
+         if (!worker->priv->is_program_session && !run_script (worker, GDMCONFDIR "/PostLogin")) {
+                 g_set_error (error,
+@@ -2159,6 +2399,7 @@ gdm_session_worker_start_session (GdmSes
+                         _exit (EXIT_FAILURE);
+                 }
+ 
++#ifdef WITH_SYSTEMD
+                 /* Take control of the tty
+                  */
+                 if (needs_controlling_terminal) {
+@@ -2166,6 +2407,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) {
+@@ -2297,11 +2539,13 @@ gdm_session_worker_start_session (GdmSes
+         return TRUE;
+ }
+ 
++#ifdef WITH_SYSTEMD
+ static gboolean
+ set_up_for_new_vt (GdmSessionWorker *worker)
+ {
+         int initial_vt_fd;
+         char vt_string[256], tty_string[256];
++        struct vt_stat vt_state = { 0 };
+         int session_vt = 0;
+ 
+         /* open the initial vt.  We need it for two scenarios:
+@@ -2319,6 +2563,11 @@ set_up_for_new_vt (GdmSessionWorker *wor
+                 return FALSE;
+         }
+ 
++        if (ioctl (fd, VT_GETSTATE, &vt_state) < 0) {
++                g_debug ("GdmSessionWorker: couldn't get current VT: %m");
++                goto fail;
++        }
++
+         if (worker->priv->display_is_initial) {
+                 session_vt = GDM_INITIAL_VT;
+         } else {
+@@ -2332,6 +2581,7 @@ set_up_for_new_vt (GdmSessionWorker *wor
+                 }
+         }
+ 
++        worker->priv->login_vt = vt_state.v_active;
+         worker->priv->session_vt = session_vt;
+ 
+         g_assert (session_vt > 0);
+@@ -2397,6 +2647,7 @@ fail:
+         close (fd);
+         return FALSE;
+ }
++#endif
+ 
+ static gboolean
+ set_up_for_current_vt (GdmSessionWorker  *worker,
+@@ -2464,12 +2715,14 @@ set_up_for_current_vt (GdmSessionWorker 
+          }
+ #endif
+ 
++#ifdef WITH_SYSTEMD
+         if (g_strcmp0 (worker->priv->display_seat_id, "seat0") == 0) {
+                 g_debug ("GdmSessionWorker: setting XDG_VTNR to current vt");
+                 set_xdg_vtnr_to_current_vt (worker);
+         } else {
+                 g_debug ("GdmSessionWorker: not setting XDG_VTNR since not seat0");
+         }
++#endif
+ 
+         return TRUE;
+ out:
+@@ -2495,6 +2748,7 @@ gdm_session_worker_open_session (GdmSess
+                 break;
+         case GDM_SESSION_DISPLAY_MODE_NEW_VT:
+         case GDM_SESSION_DISPLAY_MODE_LOGIND_MANAGED:
++#ifdef WITH_SYSTEMD
+                 if (!set_up_for_new_vt (worker)) {
+                         g_set_error (error,
+                                      GDM_SESSION_WORKER_ERROR,
+@@ -2502,6 +2756,7 @@ gdm_session_worker_open_session (GdmSess
+                                      "Unable to open VT");
+                         return FALSE;
+                 }
++#endif
+                 break;
+         }
+ 
+@@ -2524,7 +2779,17 @@ gdm_session_worker_open_session (GdmSess
+         g_debug ("GdmSessionWorker: state SESSION_OPENED");
+         gdm_session_worker_set_state (worker, GDM_SESSION_WORKER_STATE_SESSION_OPENED);
+ 
++#ifdef WITH_SYSTEMD
+         session_id = gdm_session_worker_get_environment_variable (worker, "XDG_SESSION_ID");
++#endif
++
++#ifdef WITH_CONSOLE_KIT
++        register_ck_session (worker);
++
++        if (session_id == NULL) {
++                session_id = get_ck_session_id (worker);
++        }
++#endif
+ 
+         if (session_id != NULL) {
+                 g_free (worker->priv->session_id);
+@@ -2634,6 +2899,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)
+@@ -3060,6 +3338,7 @@ gdm_session_worker_handle_open (GdmDBusW
+         return TRUE;
+ }
+ 
++#ifdef SUPPORTS_PAM_EXTENSIONS
+ static char **
+ filter_extensions (const char * const *extensions)
+ {
+@@ -3085,6 +3364,7 @@ filter_extensions (const char * const *e
+ 
+         return filtered_extensions;
+ }
++#endif
+ 
+ static gboolean
+ gdm_session_worker_handle_initialize (GdmDBusWorker         *object,
+@@ -3104,8 +3384,10 @@ gdm_session_worker_handle_initialize (Gd
+         while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) {
+                 if (g_strcmp0 (key, "service") == 0) {
+                         worker->priv->service = g_variant_dup_string (value, NULL);
++#ifdef SUPPORTS_PAM_EXTENSIONS
+                 } else if (g_strcmp0 (key, "extensions") == 0) {
+                         worker->priv->extensions = filter_extensions (g_variant_get_strv (value, NULL));
++#endif
+                 } else if (g_strcmp0 (key, "username") == 0) {
+                         worker->priv->username = g_variant_dup_string (value, NULL);
+                 } else if (g_strcmp0 (key, "is-program-session") == 0) {
+@@ -3545,6 +3827,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;
Index: pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session-worker_xml
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session-worker_xml:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session-worker_xml       Fri Apr 16 13:57:52 2021
@@ -0,0 +1,22 @@
+$NetBSD: patch-daemon_gdm-session-worker_xml,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$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>
Index: pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session_c
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session_c:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session_c        Fri Apr 16 13:57:52 2021
@@ -0,0 +1,58 @@
+$NetBSD: patch-daemon_gdm-session_c,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$OpenBSD: patch-daemon_gdm-session_c,v 1.22 2020/05/14 15: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 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
+
+Index: daemon/gdm-session.c
+--- daemon/gdm-session.c.orig  2020-05-04 20:11:25.000000000 +0000
++++ daemon/gdm-session.c
+@@ -3238,6 +3238,10 @@ gdm_session_bypasses_xsession (GdmSessio
+         g_return_val_if_fail (self != NULL, FALSE);
+         g_return_val_if_fail (GDM_IS_SESSION (self), FALSE);
+ 
++        if (!LOGIND_RUNNING()) {
++                return GDM_SESSION_DISPLAY_MODE_REUSE_VT;
++        }
++
+ #ifdef ENABLE_WAYLAND_SUPPORT
+         if (gdm_session_is_wayland_session (self)) {
+                 bypasses_xsession = TRUE;
+@@ -3333,6 +3337,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->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)
+ {
Index: pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session_h
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session_h:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-daemon_gdm-session_h        Fri Apr 16 13:57:52 2021
@@ -0,0 +1,21 @@
+$NetBSD: patch-daemon_gdm-session_h,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$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,
Index: pkgsrc/x11/libgdm/patches/patch-daemon_gdm-x-session.c
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-daemon_gdm-x-session.c:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-daemon_gdm-x-session.c      Fri Apr 16 13:57:52 2021
@@ -0,0 +1,24 @@
+$NetBSD: patch-daemon_gdm-x-session.c,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+Replace unsupported HOST_NAME_MAX with _POSIX_HOST_NAME_MAX
+
+--- daemon/gdm-x-session.c.orig        2020-12-15 18:16:43.000000000 +0000
++++ daemon/gdm-x-session.c
+@@ -114,7 +114,7 @@ prepare_auth_file (void)
+         GError   *error = NULL;
+         gboolean  prepared = FALSE;
+         Xauth     auth_entry = { 0 };
+-        char      localhost[HOST_NAME_MAX + 1] = "";
++        char      localhost[_POSIX_HOST_NAME_MAX + 1] = "";
+ 
+         g_debug ("Preparing auth file for X server");
+ 
+@@ -124,7 +124,7 @@ prepare_auth_file (void)
+                 return NULL;
+         }
+ 
+-        if (gethostname (localhost, HOST_NAME_MAX) < 0) {
++        if (gethostname (localhost, _POSIX_HOST_NAME_MAX) < 0) {
+                 strncpy (localhost, "localhost", sizeof (localhost) - 1);
+         }
+ 
Index: pkgsrc/x11/libgdm/patches/patch-daemon_main_c
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-daemon_main_c:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-daemon_main_c       Fri Apr 16 13:57:52 2021
@@ -0,0 +1,41 @@
+$NetBSD: patch-daemon_main_c,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$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, "");
Index: pkgsrc/x11/libgdm/patches/patch-data_Init_in
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-data_Init_in:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-data_Init_in        Fri Apr 16 13:57:52 2021
@@ -0,0 +1,26 @@
+$NetBSD: patch-data_Init_in,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$OpenBSD: patch-data_Init_in,v 1.7 2015/04/15 14:47:00 ajacoutot Exp $
+
+--- data/Init.in.orig  2021-03-30 13:25:30.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=
+@@ -94,4 +97,9 @@ if [ "x$SETXKBMAP" != "x" ] ; then
+   fi
+ fi
+ 
++# /etc/X11/xdm/GiveConsole, fbtab(5)
++if [ -c /dev/drm0 ]; then
++    /sbin/chown _gdm /dev/drm0
++fi
++
+ exit 0
Index: pkgsrc/x11/libgdm/patches/patch-data_PostSession_in
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-data_PostSession_in:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-data_PostSession_in Fri Apr 16 13:57:52 2021
@@ -0,0 +1,15 @@
+$NetBSD: patch-data_PostSession_in,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$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
Index: pkgsrc/x11/libgdm/patches/patch-data_PreSession_in
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-data_PreSession_in:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-data_PreSession_in  Fri Apr 16 13:57:52 2021
@@ -0,0 +1,15 @@
+$NetBSD: patch-data_PreSession_in,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$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
Index: pkgsrc/x11/libgdm/patches/patch-data_gdm.conf-custom.in
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-data_gdm.conf-custom.in:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-data_gdm.conf-custom.in     Fri Apr 16 13:57:52 2021
@@ -0,0 +1,15 @@
+$NetBSD: patch-data_gdm.conf-custom.in,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+Wayland backend not ported to NetBSD, disable by default
+
+--- data/gdm.conf-custom.in.orig       2020-05-04 20:11:25.000000000 +0000
++++ data/gdm.conf-custom.in
+@@ -2,7 +2,7 @@
+ 
+ [daemon]
+ # Uncomment the line below to force the login screen to use Xorg
+-#WaylandEnable=false
++WaylandEnable=false
+ 
+ [security]
+ 
Index: pkgsrc/x11/libgdm/patches/patch-data_meson.build
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-data_meson.build:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-data_meson.build    Fri Apr 16 13:57:52 2021
@@ -0,0 +1,65 @@
+$NetBSD: patch-data_meson.build,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+Remove Linux-only systemd rules
+
+--- data/meson.build.orig      2021-03-16 20:48:04.000000000 +0000
++++ data/meson.build
+@@ -149,15 +149,6 @@ foreach _pam_filename : pam_data_files
+   )
+ endforeach
+ 
+-gdm_rules = configure_file(
+-  input: '61-gdm.rules.in',
+-  output: '@BASENAME@',
+-  configuration: {
+-    'libexecdir': gdm_prefix / get_option('libexecdir'),
+-  },
+-  install_dir: udev_dir,
+-)
+-
+ # DBus service files
+ service_config = configuration_data()
+ service_config.set('sbindir', gdm_prefix / get_option('sbindir'))
+@@ -169,42 +160,11 @@ else
+   service_config.set('PLYMOUTH_QUIT_SERVICE', '')
+ endif
+ 
+-if get_option('systemdsystemunitdir') != ''
+-  systemd_systemunitdir = get_option('systemdsystemunitdir')
+-else
+-  systemd_systemunitdir = systemd_dep.get_pkgconfig_variable('systemdsystemunitdir')
+-endif
+-
+-if get_option('systemduserunitdir') != ''
+-  systemd_userunitdir = get_option('systemduserunitdir')
+-else
+-  systemd_userunitdir = systemd_dep.get_pkgconfig_variable('systemduserunitdir',
+-                                                           define_variable: ['prefix', get_option('prefix')])
+-endif
+-
+-configure_file(
+-  input: 'gdm.service.in',
+-  output: '@BASENAME@',
+-  configuration: service_config,
+-  install_dir: systemd_systemunitdir,
+-  format: 'cmake'
+-)
+-
+ gdm_gnome_session_wanted_targets = []
+ foreach component: gdm_gnome_user_session_wanted_components
+   gdm_gnome_session_wanted_targets += 'Wants=@0@.target'.format(component)
+ endforeach
+ 
+-configure_file(
+-  input: 'session.conf.in',
+-  output: 'session.conf',
+-  configuration: {
+-    'requires_component': gdm_gnome_shell_component,
+-    'wants_required_components': '\n'.join(gdm_gnome_session_wanted_targets),
+-  },
+-  install_dir: systemd_userunitdir / 'gnome-session@gnome-login.target.d',
+-)
+-
+ # XSession
+ if get_option('gdm-xsession')
+   configure_file(
Index: pkgsrc/x11/libgdm/patches/patch-libgdm_gdm-user-switching_c
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-libgdm_gdm-user-switching_c:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-libgdm_gdm-user-switching_c Fri Apr 16 13:57:52 2021
@@ -0,0 +1,428 @@
+$NetBSD: patch-libgdm_gdm-user-switching_c,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+$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   2020-05-04 20:11:25.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
++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 (GDBusConnection  *connection,
+-                     GCancellable     *cancellable,
+-                     const char       *seat_id,
+-                     const char       *session_id,
+-                     GError          **error)
++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;
+@@ -236,9 +541,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;
+@@ -257,10 +562,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;
+@@ -269,8 +575,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
+ }
Index: pkgsrc/x11/libgdm/patches/patch-libgdm_meson.build
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-libgdm_meson.build:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-libgdm_meson.build  Fri Apr 16 13:57:52 2021
@@ -0,0 +1,14 @@
+$NetBSD: patch-libgdm_meson.build,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+Remove linux-only systemd dependency
+
+--- libgdm/meson.build.orig    2020-12-15 18:16:43.000000000 +0000
++++ libgdm/meson.build
+@@ -56,7 +56,6 @@ libgdm_deps = [
+   glib_dep,
+   gio_dep,
+   gio_unix_dep,
+-  libsystemd_dep,
+   libgdmcommon_dep,
+ ]
+ 
Index: pkgsrc/x11/libgdm/patches/patch-meson.build
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-meson.build:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-meson.build Fri Apr 16 13:57:52 2021
@@ -0,0 +1,80 @@
+$NetBSD: patch-meson.build,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+Remove Linux-only dependencies
+
+--- meson.build.orig   2021-03-16 20:48:04.000000000 +0000
++++ meson.build
+@@ -17,7 +17,6 @@ gdm_prefix = get_option('prefix')
+ 
+ gdmconfdir = (get_option('sysconfsubdir') == '')? gdm_prefix / get_option('sysconfdir') : gdm_prefix / get_option('sysconfdir') / get_option('sysconfsubdir')
+ dmconfdir = (get_option('dmconfdir') != '')? get_option('dmconfdir') : gdm_prefix / get_option('sysconfdir') / 'dm'
+-udev_dir = get_option('udev-dir')
+ at_spi_registryd_dir = (get_option('at-spi-registryd-dir') != '')? get_option('at-spi-registryd-dir') : gdm_prefix / get_option('libexecdir')
+ lang_config_file = (get_option('lang-file') != '')? get_option('lang-file') : gdm_prefix / get_option('sysconfdir') / 'locale.conf'
+ pam_mod_dir = (get_option('pam-mod-dir') != '')? get_option('pam-mod-dir') : gdm_prefix / get_option('libdir') / 'security'
+@@ -37,7 +36,6 @@ gdm_screenshot_dir = (get_option('screen
+ config_h_dir = include_directories('.')
+ 
+ # Dependencies
+-udev_dep = dependency('udev')
+ 
+ glib_min_version = '2.56.0'
+ 
+@@ -52,16 +50,6 @@ xcb_dep = dependency('xcb')
+ keyutils_dep = dependency('libkeyutils', required: false)
+ libselinux_dep = dependency('libselinux', required: get_option('selinux'))
+ 
+-# udev
+-if udev_dir == ''
+-  if udev_dep.found()
+-    udev_prefix = udev_dep.get_pkgconfig_variable('udevdir')
+-  else
+-    udev_prefix = gdm_prefix / 'lib' / 'udev'
+-  endif
+-  udev_dir = udev_prefix / 'rules.d'
+-endif
+-
+ # X11
+ x_deps = declare_dependency(
+   dependencies: [
+@@ -92,21 +80,6 @@ xdmcp_dep = cc.find_library('Xdmcp', req
+ if xdmcp_dep.found() and get_option('tcp-wrappers')
+   libwrap_dep = cc.find_library('libwrap')
+ endif
+-# systemd
+-systemd_dep = dependency('systemd')
+-libsystemd_dep = dependency('libsystemd')
+-if meson.version().version_compare('>= 0.53')
+-  systemd_multiseat_x = find_program('systemd-multi-seat-x',
+-    required: false,
+-    dirs: [
+-      systemd_dep.get_pkgconfig_variable('systemdutildir'),
+-      '/lib/systemd',
+-      '/usr/lib/systemd',
+-    ])
+-else
+-  systemd_multiseat_x = find_program('systemd-multi-seat-x', required: false)
+-endif
+-systemd_x_server = systemd_multiseat_x.found()? systemd_multiseat_x.path() : '/lib/systemd/systemd-multi-seat-x'
+ # Plymouth
+ plymouth_dep = dependency('ply-boot-client', required: get_option('plymouth'))
+ # Check for Solaris auditing API (ADT)
+@@ -236,7 +209,6 @@ conf.set_quoted('GDM_SESSION_DEFAULT_PAT
+ conf.set_quoted('GDM_USERNAME', get_option('user'))
+ conf.set_quoted('GDM_GROUPNAME', get_option('group'))
+ conf.set('HAVE_LIBXDMCP', xdmcp_dep.found())
+-conf.set_quoted('SYSTEMD_X_SERVER', systemd_x_server)
+ conf.set('WITH_PLYMOUTH', plymouth_dep.found())
+ conf.set_quoted('X_SERVER', x_bin)
+ conf.set_quoted('X_PATH', x_path)
+@@ -300,10 +272,8 @@ summary({
+     'AT SPI registryd': at_spi_registryd_dir,
+     'Lang config file': lang_config_file,
+     'Pam MOD': pam_mod_dir,
+-    'Udev rules': udev_dir,
+     'XServer': x_bin,
+     'XPath': x_path,
+-    'Systemd XServer': systemd_x_server,
+   },
+   section: 'Paths',
+ )
Index: pkgsrc/x11/libgdm/patches/patch-pam__gdm_pam__gdm.c
diff -u /dev/null pkgsrc/x11/libgdm/patches/patch-pam__gdm_pam__gdm.c:1.1
--- /dev/null   Fri Apr 16 13:57:52 2021
+++ pkgsrc/x11/libgdm/patches/patch-pam__gdm_pam__gdm.c Fri Apr 16 13:57:52 2021
@@ -0,0 +1,21 @@
+$NetBSD: patch-pam__gdm_pam__gdm.c,v 1.1 2021/04/16 13:57:52 cirnatdan Exp $
+
+Include only supported pam headers
+
+--- pam_gdm/pam_gdm.c.orig     2020-12-15 18:16:43.000000000 +0000
++++ pam_gdm/pam_gdm.c
+@@ -21,11 +21,13 @@
+ 
+ #include <unistd.h>
+ 
++#ifdef __linux__
+ #include <security/_pam_macros.h>
+ #include <security/pam_ext.h>
+ #include <security/pam_misc.h>
+-#include <security/pam_modules.h>
+ #include <security/pam_modutil.h>
++#endif
++#include <security/pam_modules.h>
+ 
+ #ifdef HAVE_KEYUTILS
+ #include <keyutils.h>



Home | Main Index | Thread Index | Old Index