:: Re: [devuan-dev] Libseat support fo…
Pàgina inicial
Delete this message
Reply to this message
Autor: Adam Sampson
Data:  
A: devuan developers internal list, dng
Assumpte: Re: [devuan-dev] Libseat support for xorg
Hi Mark,

On Tue, Dec 13, 2022 at 06:49:46PM +0000, Mark Hindley wrote:
> rrq and I have been looking at the possibility of patching the xorg
> server to use libseat[1] (and therefore either seatd itself or logind)
> for providing management of video and input resources for rootless
> startx.


Thanks very much for implementing this -- it's something I'd been
wondering about as well. I've given it some testing on my (non-Devuan
but Linux) systems and it all appears to behave correctly under seatd,
including VT switches and hotplugging input devices. Nice!

On the assumption that you plan to submit this for upstream review at
some point, I've attached some patches to bring it closer to the xserver
style guidelines, which you should be able to squash into your existing
patch. This is mostly updating spacing/comment styles, but there's one
minor change to get rid of a VLA in the code.

I wonder if it would be worth renaming the configure option and
functions to just "libseat" rather than "seatd-libseat" -- in theory
you should be able to use logind/elogind through libseat as well...

Cheers,

-- 
Adam Sampson <ats@???>                         <http://offog.org/>

>From 8ca5473946d48b7c2b37f6fdafbb56eca2c66984 Mon Sep 17 00:00:00 2001
From: Adam Sampson <ats@???>
Date: Sun, 18 Dec 2022 16:25:50 +0000
Subject: [PATCH 1/5] Move seatd-libseat.d into include and add to EXTRA_DIST.

This matches systemd-logind.h and ensures it's included in tarball
releases.
---
 include/Makefile.am                            | 1 +
 {hw/xfree86/common => include}/seatd-libseat.h | 0
 2 files changed, 1 insertion(+)
 rename {hw/xfree86/common => include}/seatd-libseat.h (100%)


diff --git a/include/Makefile.am b/include/Makefile.am
index 25b3a9033..d66103f85 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -75,6 +75,7 @@ EXTRA_DIST =     \
     eventconvert.h eventstr.h inpututils.h \
     probes.h \
     protocol-versions.h \
+    seatd-libseat.h \
     swaprep.h \
     swapreq.h \
     systemd-logind.h \
diff --git a/hw/xfree86/common/seatd-libseat.h b/include/seatd-libseat.h
similarity index 100%
rename from hw/xfree86/common/seatd-libseat.h
rename to include/seatd-libseat.h
-- 
2.39.0


>From f2cf49ab8776b8a1bcc27c46647f697b8b75139d Mon Sep 17 00:00:00 2001
From: Adam Sampson <ats@???>
Date: Sun, 18 Dec 2022 16:42:44 +0000
Subject: [PATCH 2/5] Make the libseat code match the xserver coding style.

---
 configure.ac                                |   8 +-
 hw/xfree86/common/xf86Events.c              |   6 +-
 hw/xfree86/common/xf86Init.c                |   2 +-
 hw/xfree86/common/xf86Xinput.c              |   6 +-
 hw/xfree86/os-support/linux/lnx_platform.c  |  19 +--
 hw/xfree86/os-support/linux/seatd-libseat.c | 162 ++++++++++++--------
 include/seatd-libseat.h                     |   4 +-
 7 files changed, 117 insertions(+), 90 deletions(-)


diff --git a/configure.ac b/configure.ac
index 4b7689345..88b8f0aa6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -892,12 +892,12 @@ if test "x$SEATD_LIBSEAT" = xauto; then
         fi
 fi
 if test "x$SEATD_LIBSEAT" = xyes; then
-    if ! test "x$CONFIG_UDEV" = xyes ; then
-        AC_MSG_ERROR([seatd-libseat is only supported in combination with udev configuration.])
+        if ! test "x$CONFIG_UDEV" = xyes ; then
+                AC_MSG_ERROR([seatd-libseat is only supported in combination with udev configuration.])
         fi
-    REQUIRED_LIBS="$REQUIRED_LIBS libseat"
+        REQUIRED_LIBS="$REQUIRED_LIBS libseat"
         AC_DEFINE(SEATD_LIBSEAT, 1, [Enable libseat integration])
-    SYSTEMD_LOGIND=no
+        SYSTEMD_LOGIND=no
 fi
 AM_CONDITIONAL(SEATD_LIBSEAT, [test "x$SEATD_LIBSEAT" = xyes])


diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 085d870aa..d4dfeb8c5 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -311,7 +311,7 @@ xf86DisableInputDeviceForVTSwitch(InputInfoPtr pInfo)
     xf86ReleaseKeys(pInfo->dev);
     ProcessInputEvents();
 #ifdef SEATD_LIBSEAT
-    seatd_libseat_close_device( pInfo );
+    seatd_libseat_close_device(pInfo);
 #endif
     DisableDevice(pInfo->dev, TRUE);
 }
@@ -475,8 +475,8 @@ xf86VTEnter(void)


     for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) {
 #ifdef SEATD_LIBSEAT
-    seatd_libseat_open_device( pInfo ); // Assign device fd
-    xf86EnableInputDeviceForVTSwitch( pInfo );
+        seatd_libseat_open_device(pInfo);       /* assign device fd */
+        xf86EnableInputDeviceForVTSwitch(pInfo);
 #else
         /* Devices with server managed fds get enabled on logind resume */
         if (!(pInfo->flags & XI86_SERVER_FD))
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 55f1ec13d..6c3668229 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -341,7 +341,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)


         dbus_core_init();
 #ifdef SEATD_LIBSEAT
-    seatd_libseat_init();
+        seatd_libseat_init();
 #endif
         systemd_logind_init();


diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 1ee44c61b..59066ca37 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -816,7 +816,7 @@ xf86DeleteInput(InputInfoPtr pInp, int flags)
     FreeInputAttributes(pInp->attrs);


 #ifdef SEATD_LIBSEAT
-    seatd_libseat_close_device( pInp );
+    seatd_libseat_close_device(pInp);
 #else
     if (pInp->flags & XI86_SERVER_FD) {
         systemd_logind_release_fd(pInp->major, pInp->minor, pInp->fd);
@@ -948,9 +948,9 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
     if (path && pInfo->major == 0 && pInfo->minor == 0)
         xf86stat(path, &pInfo->major, &pInfo->minor);


-    if (path && (drv->capabilities & XI86_DRV_CAP_SERVER_FD)){
+    if (path && (drv->capabilities & XI86_DRV_CAP_SERVER_FD)) {
 #ifdef SEATD_LIBSEAT
-    seatd_libseat_open_device( pInfo );
+        seatd_libseat_open_device(pInfo);
 #endif
 #ifdef SYSTEMD_LOGIND
         int fd = systemd_logind_take_fd(pInfo->major, pInfo->minor,
diff --git a/hw/xfree86/os-support/linux/lnx_platform.c b/hw/xfree86/os-support/linux/lnx_platform.c
index d6168899f..e78fa91d4 100644
--- a/hw/xfree86/os-support/linux/lnx_platform.c
+++ b/hw/xfree86/os-support/linux/lnx_platform.c
@@ -32,10 +32,11 @@ get_drm_info(struct OdevAttributes *attribs, char *path, int delayed_index)
     LogMessage(X_INFO, "Platform probe for %s\n", attribs->syspath);


 #ifdef SEATD_LIBSEAT
-    fd = seatd_libseat_open_graphics( path );
-    if ( fd == -1 ) {
-    LogMessage(X_INFO, "seatd_libseat cannot open graphics\n" );
-    } else {
+    fd = seatd_libseat_open_graphics(path);
+    if (fd == -1) {
+        LogMessage(X_INFO, "seatd_libseat cannot open graphics\n");
+    }
+    else {
         attribs->fd = fd;
         server_fd = TRUE;
     }
@@ -53,12 +54,12 @@ get_drm_info(struct OdevAttributes *attribs, char *path, int delayed_index)
     }
 #endif
     if (fd == -1) {
-    // Try opening the path directly
+        /* try opening the path directly */
         fd = open(path, O_RDWR | O_CLOEXEC, 0);
-    if (fd == -1) {
-        xf86Msg(X_ERROR, "cannot open %s\n", path);
-        return FALSE;
-    }
+        if (fd == -1) {
+            xf86Msg(X_ERROR, "cannot open %s\n", path);
+            return FALSE;
+        }
     }


     /* for a delayed probe we've already added the device */
diff --git a/hw/xfree86/os-support/linux/seatd-libseat.c b/hw/xfree86/os-support/linux/seatd-libseat.c
index 6c1db6945..604a0a222 100644
--- a/hw/xfree86/os-support/linux/seatd-libseat.c
+++ b/hw/xfree86/os-support/linux/seatd-libseat.c
@@ -44,8 +44,7 @@
 #include "globals.h"
 #include "seatd-libseat.h"


-// ==========================================================
-// ============ libseat client adapter ======================
+/* ===== libseat client adapter ===== */

 struct libseat_info {
     char *session;
@@ -65,9 +64,11 @@ static struct libseat_info seat_info;
  * seat devices to ensure that they are operational, as existing fds
  * may have had their functionality blocked or revoked.
  */
-static void enable_seat(struct libseat *seat,void *userdata) {
+static void
+enable_seat(struct libseat *seat, void *userdata)
+{
     (void) userdata;
-    LogMessage( X_INFO, "seatd_libseat enable\n" );
+    LogMessage(X_INFO, "seatd_libseat enable\n");
     seat_info.active = TRUE;
     seat_info.vt_active = TRUE;
     xf86VTEnter();
@@ -81,13 +82,15 @@ static void enable_seat(struct libseat *seat,void *userdata) {
  * If the recepient fails to acknowledge the event in time, seat
  * devices may be forcibly revoked by the seat provider.
  */
-static void disable_seat(struct libseat *seat, void *userdata) {
+static void
+disable_seat(struct libseat *seat, void *userdata)
+{
     (void) userdata;
-    LogMessage( X_INFO, "seatd_libseat disable\n" );
+    LogMessage(X_INFO, "seatd_libseat disable\n");
     seat_info.vt_active = FALSE;
     xf86VTLeave();
-    if ( libseat_disable_seat( seat ) ) {
-    LogMessage( X_ERROR, "seatd_libseat disable failed: %d\n", errno );
+    if (libseat_disable_seat(seat)) {
+        LogMessage(X_ERROR, "seatd_libseat disable failed: %d\n", errno);
     }
 }


@@ -102,14 +105,16 @@ static struct libseat_seat_listener client_callbacks = {
 /*
  * Check libseat is initialised and active.
  */
-static Bool libseat_active(void) {
-    if ( ! seat_info.client ) {
-    LogMessage( X_ERROR, "seatd_libseat not initialised!\n" );
+static Bool
+libseat_active(void)
+{
+    if (!seat_info.client) {
+        LogMessage(X_ERROR, "seatd_libseat not initialised!\n");
         return FALSE;
     }
-    if ( ! seat_info.active ) {
-    LogMessage( X_ERROR, "seatd_libseat not active\n" );
-    return FALSE;
+    if (!seat_info.active) {
+        LogMessage(X_ERROR, "seatd_libseat not active\n");
+        return FALSE;
     }
     return TRUE;
 }
@@ -117,10 +122,13 @@ static Bool libseat_active(void) {
 /*
  * Handle libseat events
  */
-static int libseat_handle_events(int timeout) {
+static int
+libseat_handle_events(int timeout)
+{
     int ret;
-    while ( (ret = libseat_dispatch( seat_info.client, timeout )) > 0)
-        LogMessage( X_INFO, "seatd_libseat handled %i events\n", ret);
+
+    while ((ret = libseat_dispatch(seat_info.client, timeout)) > 0)
+        LogMessage(X_INFO, "seatd_libseat handled %i events\n", ret);
     if (ret == -1) {
         LogMessage(X_ERROR, "libseat_dispatch() failed: %s\n", strerror(errno));
         return -1;
@@ -131,11 +139,12 @@ static int libseat_handle_events(int timeout) {
 /*
  * Handle libseat logging.
  */
-static void log_libseat(enum libseat_log_level level,
-                        const char *fmt,
-                        va_list args) {
+static void
+log_libseat(enum libseat_log_level level, const char *fmt, va_list args)
+{
     MessageType xmt;
-    char xfmt[strlen(fmt)+2];
+    char xfmt[strlen(fmt) + 2];
+
     snprintf(xfmt, sizeof(xfmt), "%s\n", fmt);
     switch (level) {
     case LIBSEAT_LOG_LEVEL_INFO:
@@ -145,13 +154,12 @@ static void log_libseat(enum libseat_log_level level,
         xmt = X_ERROR;
         break;
     default:
-         xmt = X_DEBUG;
+        xmt = X_DEBUG;
     }
     LogVMessageVerb(xmt, 0, xfmt, args);
 }


-// ==========================================================
-// ============== seatd-libseat.h API functions =============
+/* ===== seatd-libseat.h API functions ===== */

 /*
  * Initialise the libseat client.
@@ -161,35 +169,39 @@ static void log_libseat(enum libseat_log_level level,
  *   -EPERM (-1) if it was already initialised
  *   -EPIPE (-32) if the seat opening failed.
  */
-int seatd_libseat_init(void) {
+int
+seatd_libseat_init(void)
+{
     libseat_set_log_level(LIBSEAT_LOG_LEVEL_DEBUG);
     libseat_set_log_handler(log_libseat);
-    LogMessage( X_INFO, "seatd_libseat init\n" );
+    LogMessage(X_INFO, "seatd_libseat init\n");
     if (libseat_active()) {
-    LogMessage( X_ERROR, "seatd_libseat already initialised\n" );
-    return -EPERM;
+        LogMessage(X_ERROR, "seatd_libseat already initialised\n");
+        return -EPERM;
     }
     seat_info.graphics_id = -1;
-    seat_info.client = libseat_open_seat( &client_callbacks, NULL );
-    if ( ! seat_info.client ) {
-    LogMessage( X_ERROR, "Cannot set up seatd_libseat client\n" );
-    return -EPIPE;
+    seat_info.client = libseat_open_seat(&client_callbacks, NULL);
+    if (!seat_info.client) {
+        LogMessage(X_ERROR, "Cannot set up seatd_libseat client\n");
+        return -EPIPE;
     }
     if (libseat_handle_events(100) < 0) {
         libseat_close_seat(seat_info.client);
         return -EPIPE;
     }
-    LogMessage( X_INFO, "seatd_libseat client activated\n" );
+    LogMessage(X_INFO, "seatd_libseat client activated\n");
     return 0;
 }


 /*
  * Shutdown the libseat client.
  */
-void seatd_libseat_fini(void) {
-    LogMessage( X_INFO, "seatd_libseat fini\n" );
-    if ( seat_info.client )
-        libseat_close_seat( seat_info.client );
+void
+seatd_libseat_fini(void)
+{
+    LogMessage(X_INFO, "seatd_libseat fini\n");
+    if (seat_info.client)
+        libseat_close_seat(seat_info.client);
     seat_info.graphics_id = -1;
     seat_info.active = FALSE;
     seat_info.client = NULL;
@@ -204,17 +216,23 @@ void seatd_libseat_fini(void) {
  *   -EAGAIN (-11) if the VT is not active
  *   -errno from libseat_open_device if device access failed
  */
-int seatd_libseat_open_graphics(const char *path) {
+int
+seatd_libseat_open_graphics(const char *path)
+{
     int fd, id;
-    LogMessage( X_INFO, "seatd_libseat try open graphics %s\n", path );
-    if ( ! libseat_active() ) {
-    return -EPERM;
+
+    LogMessage(X_INFO, "seatd_libseat try open graphics %s\n", path);
+    if (!libseat_active()) {
+        return -EPERM;
+    }
+    if ((id = libseat_open_device(seat_info.client, path, &fd)) == -1) {
+        fd = -errno;
+        LogMessage(X_ERROR, "seatd_libseat open graphics %s (%d) failed: %d\n",
+                   path, id, fd);
     }
-    if ( (id = libseat_open_device( seat_info.client, path, &fd )) == -1 ) {
-    fd = -errno;
-        LogMessage( X_ERROR, "seatd_libseat open graphics %s (%d) failed: %d\n", path, id, fd );
-    } else {
-        LogMessage( X_INFO, "seatd_libseat opened graphics: %s (%d:%d)\n", path, id, fd );
+    else {
+        LogMessage(X_INFO, "seatd_libseat opened graphics: %s (%d:%d)\n", path,
+                   id, fd);
     }
     seat_info.graphics_id = id;
     return fd;
@@ -226,43 +244,51 @@ int seatd_libseat_open_graphics(const char *path) {
  * The function sets the p->options "libseat_id" for the device when
  * successful.
  */
-void seatd_libseat_open_device(InputInfoPtr p) {
+void
+seatd_libseat_open_device(InputInfoPtr p)
+{
     int id, fd;
     char *path = xf86CheckStrOption(p->options, "Device", NULL);
-    LogMessage( X_INFO, "seatd_libseat try open %s\n", path );
-    if ( ! libseat_active() ) {
-    return;
+
+    LogMessage(X_INFO, "seatd_libseat try open %s\n", path);
+    if (!libseat_active()) {
+        return;
+    }
+    if ((id = libseat_open_device(seat_info.client, path, &fd)) == -1) {
+        fd = -errno;
+        LogMessage(X_ERROR, "seatd_libseat open %s (%d) failed: %d\n", path, id,
+                   fd);
     }
-    if ( (id = libseat_open_device( seat_info.client, path, &fd) ) == -1 ) {
-    fd = -errno;
-        LogMessage( X_ERROR, "seatd_libseat open %s (%d) failed: %d\n", path, id,  fd );
-    } else {
-        p->options = xf86ReplaceIntOption( p->options, "fd", fd );
-        p->options = xf86ReplaceIntOption( p->options, "libseat_id", id );
-        LogMessage( X_INFO, "seatd_libseat opened %s (%d:%d)\n", path, id,  fd );
+    else {
+        p->options = xf86ReplaceIntOption(p->options, "fd", fd);
+        p->options = xf86ReplaceIntOption(p->options, "libseat_id", id);
+        LogMessage(X_INFO, "seatd_libseat opened %s (%d:%d)\n", path, id, fd);
     }
 }


 /*
  * Release an input device.
  */
-void seatd_libseat_close_device(InputInfoPtr p) {
+void
+seatd_libseat_close_device(InputInfoPtr p)
+{
     char *path = xf86CheckStrOption(p->options, "Device", NULL);
     int fd = xf86CheckIntOption(p->options, "fd", -1);
     int id = xf86CheckIntOption(p->options, "libseat_id", -1);
-    LogMessage( X_INFO, "seatd_libseat try close %s (%d:%d)\n", path, id, fd );
+
+    LogMessage(X_INFO, "seatd_libseat try close %s (%d:%d)\n", path, id, fd);
     if (!libseat_active())
         return;
-    if ( fd < 0 ) {
-        LogMessage( X_ERROR, "seatd_libseat device not open (%s)\n", path );
-    return;
+    if (fd < 0) {
+        LogMessage(X_ERROR, "seatd_libseat device not open (%s)\n", path);
+        return;
     }
-    if ( id < 0 ) {
-        LogMessage( X_ERROR, "seatd_libseat no libseat ID\n" );
-    return;
+    if (id < 0) {
+        LogMessage(X_ERROR, "seatd_libseat no libseat ID\n");
+        return;
     }
-    if ( libseat_close_device( seat_info.client, id ) ) {
-    LogMessage( X_ERROR, "seatd_libseat close failed %d\n", -errno );
+    if (libseat_close_device(seat_info.client, id)) {
+        LogMessage(X_ERROR, "seatd_libseat close failed %d\n", -errno);
     }
-    close( fd );
+    close(fd);
 }
diff --git a/include/seatd-libseat.h b/include/seatd-libseat.h
index b592574fa..324267cac 100644
--- a/include/seatd-libseat.h
+++ b/include/seatd-libseat.h
@@ -27,14 +27,14 @@
 #ifndef SEATD_LIBSEAT_H
 #define SEATD_LIBSEAT_H


-#ifdef SEATD_LIBSEAT
#include <xf86Xinput.h>
+
+#ifdef SEATD_LIBSEAT
extern int seatd_libseat_init(void);
extern void seatd_libseat_fini(void);
extern int seatd_libseat_open_graphics(const char *path);
extern void seatd_libseat_open_device(InputInfoPtr p);
extern void seatd_libseat_close_device(InputInfoPtr p);
-
#endif

#endif
--
2.39.0

>From 24f45e464a2d9e0aa31f764e16dc6b028640843e Mon Sep 17 00:00:00 2001
From: Adam Sampson <ats@???>
Date: Sun, 18 Dec 2022 16:43:06 +0000
Subject: [PATCH 3/5] Don't specify a value in #undef.

The systemd code had the same problem here.
---
include/dix-config.h.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index a78075d20..a001c2c5a 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -416,10 +416,10 @@
#undef CONFIG_HAL

/* Enable libseat integration */
-#undef SEATD_LIBSEAT 1
+#undef SEATD_LIBSEAT

/* Enable systemd-logind integration */
-#undef SYSTEMD_LOGIND 1
+#undef SYSTEMD_LOGIND

/* Have a monotonic clock from clock_gettime() */
#undef MONOTONIC_CLOCK
--
2.39.0

>From 6a52ff13383a08d6c8457350dc25af0bbb7584e8 Mon Sep 17 00:00:00 2001
From: Adam Sampson <ats@???>
Date: Sun, 18 Dec 2022 16:50:16 +0000
Subject: [PATCH 4/5] Don't use a VLA in log_libseat.

VLAs aren't one of the C99 extensions allowed by the coding style, and
there's no way to handle running out of stack. Use malloc instead.
---
hw/xfree86/os-support/linux/seatd-libseat.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/hw/xfree86/os-support/linux/seatd-libseat.c b/hw/xfree86/os-support/linux/seatd-libseat.c
index 604a0a222..ad2e8f6ff 100644
--- a/hw/xfree86/os-support/linux/seatd-libseat.c
+++ b/hw/xfree86/os-support/linux/seatd-libseat.c
@@ -29,6 +29,7 @@
#endif

 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
@@ -143,9 +144,14 @@ static void
 log_libseat(enum libseat_log_level level, const char *fmt, va_list args)
 {
     MessageType xmt;
-    char xfmt[strlen(fmt) + 2];
+    size_t xfmt_size = strlen(fmt) + 2;
+    char *xfmt;
+
+    xfmt = malloc(xfmt_size);
+    if (xfmt == NULL)
+        return;
+    snprintf(xfmt, xfmt_size, "%s\n", fmt);


-    snprintf(xfmt, sizeof(xfmt), "%s\n", fmt);
     switch (level) {
     case LIBSEAT_LOG_LEVEL_INFO:
         xmt = X_INFO;
@@ -157,6 +163,8 @@ log_libseat(enum libseat_log_level level, const char *fmt, va_list args)
         xmt = X_DEBUG;
     }
     LogVMessageVerb(xmt, 0, xfmt, args);
+
+    free(xfmt);
 }


/* ===== seatd-libseat.h API functions ===== */
--
2.39.0

>From 31475f614487f590024b89e804cc797006f641a8 Mon Sep 17 00:00:00 2001
From: Adam Sampson <ats@???>
Date: Sun, 18 Dec 2022 17:40:22 +0000
Subject: [PATCH 5/5] Make seatd_libseat_{init,fini} do nothing if disabled.

This matches how the systemd-logind equivalents work, and avoids
conditionals in the code that calls them.
---
 hw/xfree86/common/xf86Init.c | 4 ----
 include/seatd-libseat.h      | 3 +++
 2 files changed, 3 insertions(+), 4 deletions(-)


diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 6c3668229..0119d912f 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -340,9 +340,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
             DoShowOptions();


         dbus_core_init();
-#ifdef SEATD_LIBSEAT
         seatd_libseat_init();
-#endif
         systemd_logind_init();


         /* Do a general bus probe.  This will be a PCI probe for x86 platforms */
@@ -851,9 +849,7 @@ ddxGiveUp(enum ExitCode error)
     if (xorgHWOpenConsole)
         xf86CloseConsole();


-#ifdef SEATD_LIBSEAT
     seatd_libseat_fini();
-#endif
     systemd_logind_fini();
     dbus_core_fini();


diff --git a/include/seatd-libseat.h b/include/seatd-libseat.h
index 324267cac..5ce908379 100644
--- a/include/seatd-libseat.h
+++ b/include/seatd-libseat.h
@@ -35,6 +35,9 @@ extern void seatd_libseat_fini(void);
extern int seatd_libseat_open_graphics(const char *path);
extern void seatd_libseat_open_device(InputInfoPtr p);
extern void seatd_libseat_close_device(InputInfoPtr p);
+#else
+#define seatd_libseat_init()
+#define seatd_libseat_fini()
#endif

#endif
--
2.39.0