Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package seatd for openSUSE:Factory checked 
in at 2023-06-30 19:59:41
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/seatd (Old)
 and      /work/SRC/openSUSE:Factory/.seatd.new.13546 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "seatd"

Fri Jun 30 19:59:41 2023 rev:9 rq:1096072 version:0.7.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/seatd/seatd.changes      2022-02-25 
21:25:56.203647571 +0100
+++ /work/SRC/openSUSE:Factory/.seatd.new.13546/seatd.changes   2023-06-30 
19:59:59.514043042 +0200
@@ -1,0 +2,9 @@
+Fri Jun 23 05:49:32 UTC 2023 - Michael Vetter <mvet...@suse.com>
+
+- Update to 0.7.0:
+  * Support for NetBSD and wscons devices
+  * Fix for a polling bug in the logind libseat backend
+  * Removal of SEATD_SOCK and runtime socket path configuration
+  * Removal of SEATD_LOGLEVEL, replaced by a command-line argument
+
+-------------------------------------------------------------------

Old:
----
  seatd-0.6.4.obscpio

New:
----
  seatd-0.7.0.obscpio

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ seatd.spec ++++++
--- /var/tmp/diff_new_pack.KJeLHp/_old  2023-06-30 20:00:00.246047396 +0200
+++ /var/tmp/diff_new_pack.KJeLHp/_new  2023-06-30 20:00:00.250047420 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package seatd
 #
-# Copyright (c) 2022 SUSE LLC
+# Copyright (c) 2023 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
 
 
 Name:           seatd
-Version:        0.6.4
+Version:        0.7.0
 Release:        0
 Summary:        Seat management daemon
 License:        MIT

++++++ _service ++++++
--- /var/tmp/diff_new_pack.KJeLHp/_old  2023-06-30 20:00:00.282047610 +0200
+++ /var/tmp/diff_new_pack.KJeLHp/_new  2023-06-30 20:00:00.286047634 +0200
@@ -3,7 +3,7 @@
   <service name="obs_scm" mode="disabled">
     <param name="url">https://git.sr.ht/~kennylevinsen/seatd</param>
     <param name="scm">git</param>
-    <param name="revision">0.6.4</param>
+    <param name="revision">0.7.0</param>
     <param name="versionformat">@PARENT_TAG@+@TAG_OFFSET@</param>
     <param name="versionrewrite-pattern">(.*)\+0</param>
     <param name="versionrewrite-replacement">\1</param>

++++++ seatd-0.6.4.obscpio -> seatd-0.7.0.obscpio ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/.builds/alpine.yml 
new/seatd-0.7.0/.builds/alpine.yml
--- old/seatd-0.6.4/.builds/alpine.yml  2022-02-21 22:52:04.000000000 +0100
+++ new/seatd-0.7.0/.builds/alpine.yml  2022-05-23 22:03:38.000000000 +0200
@@ -20,7 +20,7 @@
       ninja -C build scan-build
       [ -z "$(ls -A build/meson-logs/scanbuild/ 2>/dev/null)" ]
    - smoketest: |
-      timeout -s KILL 30s sudo SEATD_LOGLEVEL=debug ./build/seatd-launch 
./build/simpletest /dev/dri/card0
+      timeout -s KILL 30s sudo ./build/seatd-launch -l debug -- 
./build/simpletest /dev/dri/card0
    - smoketest-builtin: |
       timeout -s KILL 30s sudo LIBSEAT_BACKEND=builtin ./build/simpletest 
/dev/dri/card0
    - check-format: |
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/.builds/archlinux.yml 
new/seatd-0.7.0/.builds/archlinux.yml
--- old/seatd-0.6.4/.builds/archlinux.yml       2022-02-21 22:52:04.000000000 
+0100
+++ new/seatd-0.7.0/.builds/archlinux.yml       2022-05-23 22:03:38.000000000 
+0200
@@ -19,7 +19,7 @@
       ninja -C build scan-build
       [ -z "$(ls -A build/meson-logs/scanbuild/ 2>/dev/null)" ]
    - smoketest: |
-      timeout -s KILL 30s sudo SEATD_LOGLEVEL=debug ./build/seatd-launch 
./build/simpletest /dev/input/event0
+      timeout -s KILL 30s sudo ./build/seatd-launch -l debug -- 
./build/simpletest /dev/input/event0
    - smoketest-builtin: |
       timeout -s KILL 30s sudo LIBSEAT_BACKEND=builtin ./build/simpletest 
/dev/input/event0
    - smoketest-logind: |
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/.builds/freebsd.yml 
new/seatd-0.7.0/.builds/freebsd.yml
--- old/seatd-0.6.4/.builds/freebsd.yml 2022-02-21 22:52:04.000000000 +0100
+++ new/seatd-0.7.0/.builds/freebsd.yml 2022-05-23 22:03:38.000000000 +0200
@@ -15,6 +15,6 @@
       meson -Db_lundef=false -Db_sanitize=address -Dlibseat-seatd=enabled 
-Dlibseat-builtin=enabled -Dexamples=enabled -Dlibseat-logind=disabled build 
seatd
       ninja -C build
       sudo ninja -C build install
-      timeout -s KILL 30s sudo SEATD_LOGLEVEL=debug ./build/seatd-launch 
./build/simpletest /dev/input/event0
+      timeout -s KILL 30s sudo ./build/seatd-launch -l debug -- 
./build/simpletest /dev/input/event0
    - smoketest-builtin: |
       timeout -s KILL 30s sudo LIBSEAT_BACKEND=builtin ./build/simpletest 
/dev/input/event0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/.builds/netbsd.yml 
new/seatd-0.7.0/.builds/netbsd.yml
--- old/seatd-0.6.4/.builds/netbsd.yml  1970-01-01 01:00:00.000000000 +0100
+++ new/seatd-0.7.0/.builds/netbsd.yml  2022-05-23 22:03:38.000000000 +0200
@@ -0,0 +1,24 @@
+image: netbsd/latest
+packages:
+   - meson
+sources:
+   - https://git.sr.ht/~kennylevinsen/seatd
+tasks:
+   - wscons: |
+      echo 'wscons=YES' | sudo tee -a /etc/rc.conf
+      sudo /etc/rc.d/wscons start
+      sudo /etc/rc.d/ttys restart
+   - prepare: |
+      meson -Dlibseat-seatd=enabled -Dlibseat-builtin=enabled 
-Dlibseat-logind=disabled build seatd
+   - build: |
+      ninja -C build
+   - unittest: |
+      ninja -C build test
+   - smoketest: |
+      rm -rf build
+      meson -Db_lundef=false -Db_sanitize=address -Dlibseat-seatd=enabled 
-Dlibseat-builtin=enabled -Dexamples=enabled -Dlibseat-logind=disabled build 
seatd
+      ninja -C build
+      sudo ninja -C build install
+      timeout -s SIGKILL 30s sudo SEATD_LOGLEVEL=debug ./build/seatd-launch 
./build/simpletest /dev/wskbd
+   - smoketest-builtin: |
+      timeout -s SIGKILL 30s sudo LIBSEAT_BACKEND=builtin ./build/simpletest 
/dev/wskbd
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/README.md new/seatd-0.7.0/README.md
--- old/seatd-0.6.4/README.md   2022-02-21 22:52:04.000000000 +0100
+++ new/seatd-0.7.0/README.md   2022-05-23 22:03:38.000000000 +0200
@@ -2,7 +2,7 @@
 
 A minimal seat management daemon, and a universal seat management library.
 
-Currently supports Linux and FreeBSD.
+Currently supports Linux and FreeBSD, and has experimental NetBSD support.
 
 ## What is seat management?
 
@@ -43,4 +43,4 @@
 
 ## How to discuss
 
-Go to #kennylevinsen @ irc.libera.chat to discuss, or use 
[~kennylevinsen/seatd-de...@lists.sr.ht](https://lists.sr.ht/~kennylevinsen/seatd-devel).
+Go to [#kennylevinsen @ 
irc.libera.chat](ircs://irc.libera.chat/#kennylevinsen) to discuss, or use 
[~kennylevinsen/seatd-de...@lists.sr.ht](https://lists.sr.ht/~kennylevinsen/seatd-devel).
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/common/drm.c new/seatd-0.7.0/common/drm.c
--- old/seatd-0.6.4/common/drm.c        2022-02-21 22:52:04.000000000 +0100
+++ new/seatd-0.7.0/common/drm.c        2022-05-23 22:03:38.000000000 +0200
@@ -2,10 +2,6 @@
 #include <sys/ioctl.h>
 #include <sys/types.h>
 
-#if defined(__linux__)
-#include <sys/sysmacros.h>
-#endif
-
 #include "drm.h"
 
 // From libdrm
@@ -24,16 +20,12 @@
        return ioctl(fd, DRM_IOCTL_DROP_MASTER, 0);
 }
 
-#if defined(__linux__)
+#if defined(__linux__) || defined(__NetBSD__)
 int path_is_drm(const char *path) {
        static const char prefix[] = "/dev/dri/";
        static const int prefixlen = STRLEN(prefix);
        return strncmp(prefix, path, prefixlen) == 0;
 }
-
-int dev_is_drm(dev_t device) {
-       return major(device) == 226;
-}
 #elif defined(__FreeBSD__)
 int path_is_drm(const char *path) {
        static const char prefix[] = "/dev/drm/";
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/common/evdev.c 
new/seatd-0.7.0/common/evdev.c
--- old/seatd-0.6.4/common/evdev.c      2022-02-21 22:52:04.000000000 +0100
+++ new/seatd-0.7.0/common/evdev.c      2022-05-23 22:03:38.000000000 +0200
@@ -9,14 +9,13 @@
 #include <sys/sysmacros.h>
 #elif defined(__FreeBSD__)
 #include <dev/evdev/input.h>
-#else
-#error Unsupported platform
 #endif
 
 #include "evdev.h"
 
 #define STRLEN(s) ((sizeof(s) / sizeof(s[0])) - 1)
 
+#if defined(__linux__) || defined(__FreeBSD__)
 int path_is_evdev(const char *path) {
        static const char prefix[] = "/dev/input/event";
        static const size_t prefixlen = STRLEN(prefix);
@@ -26,9 +25,15 @@
 int evdev_revoke(int fd) {
        return ioctl(fd, EVIOCREVOKE, NULL);
 }
-
-#if defined(__linux__)
-int dev_is_evdev(dev_t device) {
-       return major(device) == INPUT_MAJOR;
+#elif defined(__NetBSD__)
+int path_is_evdev(const char *path) {
+       (void)path;
+       return 0;
 }
+int evdev_revoke(int fd) {
+       (void)fd;
+       return 0;
+}
+#else
+#error Unsupported platform
 #endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/common/terminal.c 
new/seatd-0.7.0/common/terminal.c
--- old/seatd-0.6.4/common/terminal.c   2022-02-21 22:52:04.000000000 +0100
+++ new/seatd-0.7.0/common/terminal.c   2022-05-23 22:03:38.000000000 +0200
@@ -21,6 +21,11 @@
 #define K_ENABLE  K_XLATE
 #define K_DISABLE K_RAW
 #define FRSIG     SIGIO
+#elif defined(__NetBSD__)
+#include <dev/wscons/wsdisplay_usl_io.h>
+#define K_ENABLE  K_XLATE
+#define K_DISABLE K_RAW
+#define FRSIG     0 // unimplemented
 #else
 #error Unsupported platform
 #endif
@@ -134,6 +139,14 @@
        }
        return 0;
 }
+#elif defined(__NetBSD__)
+static int get_tty_path(int tty, char path[static TTYPATHLEN]) {
+       assert(tty >= 0);
+       if (snprintf(path, TTYPATHLEN, "/dev/ttyE%d", tty) == -1) {
+               return -1;
+       }
+       return 0;
+}
 #else
 #error Unsupported platform
 #endif
@@ -153,7 +166,7 @@
 }
 
 int terminal_current_vt(int fd) {
-#if defined(__linux__)
+#if defined(__linux__) || defined(__NetBSD__)
        struct vt_stat st;
        int res = ioctl(fd, VT_GETSTATE, &st);
        close(fd);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/common/wscons.c 
new/seatd-0.7.0/common/wscons.c
--- old/seatd-0.6.4/common/wscons.c     1970-01-01 01:00:00.000000000 +0100
+++ new/seatd-0.7.0/common/wscons.c     2022-05-23 22:03:38.000000000 +0200
@@ -0,0 +1,27 @@
+#include <stdlib.h>
+#include <string.h>
+
+#if defined(__NetBSD__)
+#include <stdlib.h>
+#include <sys/stat.h>
+#endif
+
+#include "wscons.h"
+
+#define STRLEN(s) ((sizeof(s) / sizeof(s[0])) - 1)
+
+#if defined(__NetBSD__)
+int path_is_wscons(const char *path) {
+       static const char wskbd[] = "/dev/wskbd";
+       static const char wsmouse[] = "/dev/wsmouse";
+       static const char wsmux[] = "/dev/wsmux";
+       return strncmp(path, wskbd, STRLEN(wskbd)) == 0 ||
+              strncmp(path, wsmouse, STRLEN(wsmouse)) == 0 ||
+              strncmp(path, wsmux, STRLEN(wsmouse)) == 0;
+}
+#else
+int path_is_wscons(const char *path) {
+       (void)path;
+       return 0;
+}
+#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/include/drm.h 
new/seatd-0.7.0/include/drm.h
--- old/seatd-0.6.4/include/drm.h       2022-02-21 22:52:04.000000000 +0100
+++ new/seatd-0.7.0/include/drm.h       2022-05-23 22:03:38.000000000 +0200
@@ -5,9 +5,4 @@
 int drm_drop_master(int fd);
 int path_is_drm(const char *path);
 
-#if defined(__linux__)
-#include <sys/types.h>
-int dev_is_drm(dev_t device);
-#endif
-
 #endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/include/evdev.h 
new/seatd-0.7.0/include/evdev.h
--- old/seatd-0.6.4/include/evdev.h     2022-02-21 22:52:04.000000000 +0100
+++ new/seatd-0.7.0/include/evdev.h     2022-05-23 22:03:38.000000000 +0200
@@ -4,9 +4,4 @@
 int evdev_revoke(int fd);
 int path_is_evdev(const char *path);
 
-#if defined(__linux__)
-#include <sys/types.h>
-int dev_is_evdev(dev_t device);
-#endif
-
 #endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/include/seat.h 
new/seatd-0.7.0/include/seat.h
--- old/seatd-0.6.4/include/seat.h      2022-02-21 22:52:04.000000000 +0100
+++ new/seatd-0.7.0/include/seat.h      2022-05-23 22:03:38.000000000 +0200
@@ -13,6 +13,7 @@
        SEAT_DEVICE_TYPE_NORMAL,
        SEAT_DEVICE_TYPE_EVDEV,
        SEAT_DEVICE_TYPE_DRM,
+       SEAT_DEVICE_TYPE_WSCONS,
 };
 
 struct seat_device {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/include/wscons.h 
new/seatd-0.7.0/include/wscons.h
--- old/seatd-0.6.4/include/wscons.h    1970-01-01 01:00:00.000000000 +0100
+++ new/seatd-0.7.0/include/wscons.h    2022-05-23 22:03:38.000000000 +0200
@@ -0,0 +1,6 @@
+#ifndef _SEATD_WSCONS_H
+#define _SEATD_WSCONS_H
+
+int path_is_wscons(const char *path);
+
+#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/libseat/backend/logind.c 
new/seatd-0.7.0/libseat/backend/logind.c
--- old/seatd-0.6.4/libseat/backend/logind.c    2022-02-21 22:52:04.000000000 
+0100
+++ new/seatd-0.7.0/libseat/backend/logind.c    2022-05-23 22:03:38.000000000 
+0200
@@ -13,10 +13,10 @@
 #include <sys/un.h>
 #include <unistd.h>
 
-#if defined(HAVE_ELOGIND)
+#if defined(HAVE_LIBELOGIND)
 #include <elogind/sd-bus.h>
 #include <elogind/sd-login.h>
-#elif defined(HAVE_SYSTEMD)
+#elif defined(HAVE_LIBSYSTEMD)
 #include <systemd/sd-bus.h>
 #include <systemd/sd-login.h>
 #else
@@ -28,6 +28,14 @@
 #include "libseat.h"
 #include "log.h"
 
+static int dev_major_is_drm(unsigned int dev_major) {
+       return dev_major == 226;
+}
+
+static int dev_is_drm(dev_t device) {
+       return dev_major_is_drm(major(device));
+}
+
 struct backend_logind {
        struct libseat base;
        const struct libseat_seat_listener *seat_listener;
@@ -41,7 +49,6 @@
 
        bool active;
        bool initial_setup;
-       bool awaiting_pong;
        int has_drm;
 };
 
@@ -70,13 +77,12 @@
 
 static int ping_handler(sd_bus_message *m, void *userdata, sd_bus_error 
*ret_error) {
        (void)ret_error;
-       struct backend_logind *session = userdata;
+       (void)userdata;
        if (sd_bus_message_is_method_error(m, NULL)) {
                const sd_bus_error *error = sd_bus_message_get_error(m);
                log_errorf("Ping failed: %s: %s", error->name, error->message);
                return -1;
        }
-       session->awaiting_pong = false;
        return 0;
 }
 
@@ -91,14 +97,15 @@
 }
 
 static void check_pending_events(struct backend_logind *backend) {
-       if (sd_bus_get_events(backend->bus) <= 0) {
-               return;
-       }
-       if (backend->awaiting_pong) {
+       uint64_t queued_read, queued_write;
+       sd_bus_get_n_queued_read(backend->bus, &queued_read);
+       sd_bus_get_n_queued_write(backend->bus, &queued_write);
+
+       if (queued_read == 0 && queued_write == 0) {
                return;
        }
 
-       // We have events pending execution, so a dispatch is required.
+       // The sd_bus instance has queued data, so a dispatch is required.
        // However, we likely already drained our socket, so there will not be
        // anything to read. Instead, send a ping request to logind so that the
        // user will be woken up by its response.
@@ -107,7 +114,6 @@
                log_errorf("Could not send ping message: %s", strerror(-ret));
                return;
        }
-       backend->awaiting_pong = true;
 }
 
 static int open_device(struct libseat *base, const char *path, int *fd) {
@@ -286,6 +292,7 @@
                        total_dispatched += dispatched;
                }
        }
+       check_pending_events(backend);
        return total_dispatched;
 }
 
@@ -388,7 +395,7 @@
                return 0;
        }
 
-       if (dev_is_drm(makedev(major, minor)) && strcmp(type, "gone") != 0) {
+       if (dev_major_is_drm(major) && strcmp(type, "gone") != 0) {
                log_debugf("DRM device paused: %s", type);
                assert(session->has_drm > 0);
                set_active(session, false);
@@ -420,7 +427,7 @@
                return 0;
        }
 
-       if (dev_is_drm(makedev(major, minor))) {
+       if (dev_major_is_drm(major)) {
                log_debug("DRM device resumed");
                assert(session->has_drm > 0);
                set_active(session, true);
@@ -742,6 +749,7 @@
        backend->seat_listener_data = data;
        backend->base.impl = &logind_impl;
 
+       check_pending_events(backend);
        return &backend->base;
 
 error:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/libseat/backend/noop.c 
new/seatd-0.7.0/libseat/backend/noop.c
--- old/seatd-0.6.4/libseat/backend/noop.c      2022-02-21 22:52:04.000000000 
+0100
+++ new/seatd-0.7.0/libseat/backend/noop.c      2022-05-23 22:03:38.000000000 
+0200
@@ -109,7 +109,7 @@
                return NULL;
        }
 
-       if (socketpair(AF_UNIX, SOCK_STREAM, 0, backend->sockets) != 0) {
+       if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, 
backend->sockets) != 0) {
                log_errorf("socketpair() failed: %s", strerror(errno));
                free(backend);
                return NULL;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/libseat/backend/seatd.c 
new/seatd-0.7.0/libseat/backend/seatd.c
--- old/seatd-0.6.4/libseat/backend/seatd.c     2022-02-21 22:52:04.000000000 
+0100
+++ new/seatd-0.7.0/libseat/backend/seatd.c     2022-05-23 22:03:38.000000000 
+0200
@@ -42,32 +42,16 @@
        char seat_name[MAX_SEAT_LEN];
 };
 
-static int set_nonblock(int fd) {
-       int flags;
-       if ((flags = fcntl(fd, F_GETFD)) == -1 || fcntl(fd, F_SETFD, flags | 
FD_CLOEXEC) == -1) {
-               return -1;
-       }
-       if ((flags = fcntl(fd, F_GETFL)) == -1 || fcntl(fd, F_SETFL, flags | 
O_NONBLOCK) == -1) {
-               return -1;
-       }
-       return 0;
-}
-
 static int seatd_connect(void) {
        union {
                struct sockaddr_un unix;
                struct sockaddr generic;
        } addr = {{0}};
-       int fd = socket(AF_UNIX, SOCK_STREAM, 0);
+       int fd = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
        if (fd == -1) {
                log_errorf("Could not create socket: %s", strerror(errno));
                return -1;
        }
-       if (set_nonblock(fd) == -1) {
-               log_errorf("Could not make socket non-blocking: %s", 
strerror(errno));
-               close(fd);
-               return -1;
-       }
        const char *path = getenv("SEATD_SOCK");
        if (path == NULL) {
                path = SEATD_DEFAULTPATH;
@@ -616,29 +600,10 @@
 };
 
 #ifdef BUILTIN_ENABLED
-#include <signal.h>
-
-static int set_deathsig(int signal);
-
-#if defined(__linux__)
-#include <sys/prctl.h>
-
-static int set_deathsig(int signal) {
-       return prctl(PR_SET_PDEATHSIG, signal);
-}
-#elif defined(__FreeBSD__)
-#include <sys/procctl.h>
-
-static int set_deathsig(int signal) {
-       return procctl(P_PID, 0, PROC_PDEATHSIG_CTL, &signal);
-}
-#else
-#error Unsupported platform
-#endif
 
 static struct libseat *builtin_open_seat(const struct libseat_seat_listener 
*listener, void *data) {
        int fds[2];
-       if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == -1) {
+       if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0, 
fds) == -1) {
                log_errorf("Could not create socket pair: %s", strerror(errno));
                return NULL;
        }
@@ -650,6 +615,7 @@
                close(fds[1]);
                return NULL;
        } else if (pid == 0) {
+               close(fds[1]);
                int fd = fds[0];
                int res = 0;
                struct server server = {0};
@@ -664,7 +630,7 @@
                        res = 1;
                        goto server_error;
                }
-               set_deathsig(SIGTERM);
+               log_info("Started embedded seatd");
                while (server.running) {
                        if (poller_poll(&server.poller) == -1) {
                                log_errorf("Could not poll server socket: %s", 
strerror(errno));
@@ -676,8 +642,10 @@
                server_finish(&server);
        error:
                close(fd);
+               log_info("Stopped embedded seatd");
                exit(res);
        } else {
+               close(fds[0]);
                int fd = fds[1];
                return _open_seat(listener, data, fd);
        }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/man/seatd-launch.1.scd 
new/seatd-0.7.0/man/seatd-launch.1.scd
--- old/seatd-0.6.4/man/seatd-launch.1.scd      2022-02-21 22:52:04.000000000 
+0100
+++ new/seatd-0.7.0/man/seatd-launch.1.scd      2022-05-23 22:03:38.000000000 
+0200
@@ -10,12 +10,13 @@
 
 # OPTIONS
 
+*-l <loglevel>*
+       Log-level to pass to seatd. See *seatd*(1) for information about
+       available log-levels.
+
 *-h*
        Show help message and quit.
 
-*-s <path>*
-       Where to create the seatd socket. Defaults to a unique file path.
-
 *-v*
        Show the version number and quit.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/man/seatd.1.scd 
new/seatd-0.7.0/man/seatd.1.scd
--- old/seatd-0.6.4/man/seatd.1.scd     2022-02-21 22:52:04.000000000 +0100
+++ new/seatd-0.7.0/man/seatd.1.scd     2022-05-23 22:03:38.000000000 +0200
@@ -24,8 +24,9 @@
 *-g <group>*
        Group to own the seatd socket.
 
-*-s <path>*
-       Where to create the seatd socket. Defaults to `/run/seatd.sock`.
+*-l <loglevel>*
+       Log-level to use. Must be one of debug, info, error or silent. Defaults
+       to error.
 
 *-v*
        Show the version number and quit.
@@ -38,17 +39,7 @@
 seatd operates over a UNIX domain socket, with *libseat* providing the
 client-side of the protocol.
 
-# ENVIRONMENT
-
-[[ *VARIABLE*
-:[ *VALUES*
-:< *DESCRIPTION*
-|  SEATD_SOCK
-:  File path
-:  Informs libseat of the socket location, needed if it differs from 
`/run/seatd.sock`
-|  SEATD_LOGLEVEL
-:  silent, error, info, debug
-:  Sets the seatd log level. Defaults to "error"
+The location of the socket for seatd is set at compile-time.
 
 # SEE ALSO
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/meson.build new/seatd-0.7.0/meson.build
--- old/seatd-0.6.4/meson.build 2022-02-21 22:52:04.000000000 +0100
+++ new/seatd-0.7.0/meson.build 2022-05-23 22:03:38.000000000 +0200
@@ -1,9 +1,9 @@
 project(
        'seatd',
        'c',
-       version: '0.6.4',
+       version: '0.7.0',
        license: 'MIT',
-       meson_version: '>=0.56.0',
+       meson_version: '>=0.60.0',
        default_options: [
                'c_std=c11',
                'warning_level=3',
@@ -25,6 +25,19 @@
 seatdpath = '@0@/@1@/seatd'.format(get_option('prefix'), get_option('bindir'))
 
 cc = meson.get_compiler('c')
+
+add_project_arguments(
+       [
+               '-D_XOPEN_SOURCE=700',
+               '-D__BSD_VISIBLE',
+               '-D_NETBSD_SOURCE',
+               '-DSEATD_VERSION="@0@"'.format(meson.project_version()),
+               '-DSEATD_DEFAULTPATH="@0@"'.format(defaultpath),
+               '-DSEATD_INSTALLPATH="@0@"'.format(seatdpath),
+       ],
+       language: 'c',
+)
+
 add_project_arguments(cc.get_supported_arguments(
        [
                '-Wundef',
@@ -39,12 +52,13 @@
                '-Wno-unknown-warning-option',
                '-Wno-unused-command-line-argument',
                '-Wvla',
+       ]),
+       language: 'c',
+)
+
+add_project_arguments(cc.get_supported_link_arguments(
+       [
                '-Wl,--exclude-libs=ALL',
-               '-D_XOPEN_SOURCE=700',
-               '-D__BSD_VISIBLE',
-               '-DSEATD_VERSION="@0@"'.format(meson.project_version()),
-               '-DSEATD_DEFAULTPATH="@0@"'.format(defaultpath),
-               '-DSEATD_INSTALLPATH="@0@"'.format(seatdpath),
        ]),
        language: 'c',
 )
@@ -59,7 +73,7 @@
 
 # Hacks
 source_root = meson.current_source_dir().split('/')
-build_root = meson.build_root().split('/')
+build_root = meson.global_build_root().split('/')
 relative_dir_parts = []
 i = 0
 in_prefix = true
@@ -100,6 +114,7 @@
        'common/connection.c',
        'common/evdev.c',
        'common/drm.c',
+       'common/wscons.c',
        'seatd/poller.c',
        'seatd/seat.c',
        'seatd/client.c',
@@ -114,31 +129,26 @@
        private_files += 'libseat/backend/seatd.c'
 endif
 
+libseat_c_args = ['-DLIBSEAT=1']
+
 if with_seatd
-       add_project_arguments('-DSEATD_ENABLED=1', language: 'c')
+       libseat_c_args += '-DSEATD_ENABLED=1'
 endif
 
 logind = disabler()
-logind_provider = ''
 if get_option('libseat-logind') != 'disabled'
        if get_option('libseat-logind') == 'auto' and 
get_option('auto_features').disabled()
                # Disable logind
        elif get_option('libseat-logind') == 'auto'
                assert(get_option('auto_features').auto(), '-Dlibseat-logind 
must be set to systemd or elogind since auto_features != auto')
-               foreach logind_provider : ['elogind', 'systemd']
-                       logind = dependency('lib@0@'.format(logind_provider), 
required: false)
-                       if logind.found()
-                               break
-                       endif
-               endforeach
+               logind = dependency(['libelogind', 'libsystemd'], required: 
false)
        else
-               logind_provider = get_option('libseat-logind')
-               logind = dependency('lib@0@'.format(logind_provider))
+               logind = 
dependency('lib@0@'.format(get_option('libseat-logind')))
        endif
 
        if logind.found()
-               add_project_arguments('-DLOGIND_ENABLED=1', language: 'c')
-               
add_project_arguments('-DHAVE_@0@=1'.format(logind_provider.to_upper()), 
language: 'c')
+               libseat_c_args += '-DLOGIND_ENABLED=1'
+               libseat_c_args += 
'-DHAVE_@0@=1'.format(logind.name().to_upper())
                private_files += [
                        'libseat/backend/logind.c',
                        'common/drm.c',
@@ -152,7 +162,7 @@
 private_deps += realtime
 
 if with_builtin
-       add_project_arguments('-DBUILTIN_ENABLED=1', language: 'c')
+       libseat_c_args += '-DBUILTIN_ENABLED=1'
        private_files += server_files
 endif
 
@@ -161,6 +171,7 @@
        private_files,
        dependencies: private_deps,
        include_directories: [include_directories('.', 'include')],
+       c_args: libseat_c_args,
 )
 
 symbols_file = 'libseat/libseat.syms'
@@ -168,12 +179,13 @@
 lib = library(
        'seat', # This results in the library being called 'libseat'
        [ 'libseat/libseat.c', 'libseat/backend/noop.c' ],
-       soversion: libseat_soversion,
+       soversion: '@0@'.format(libseat_soversion),
        link_with: private_lib,
        include_directories: [include_directories('.', 'include')],
        install: true,
        link_args: symbols_flag,
        link_depends: symbols_file,
+       c_args: libseat_c_args,
 )
 
 install_headers('include/libseat.h')
@@ -200,6 +212,8 @@
        variables: libseat_vars,
 )
 
+meson.override_dependency('libseat', libseat)
+
 if with_server
        executable(
                'seatd',
@@ -247,7 +261,6 @@
 endif
 
 if scdoc.found()
-       scdoc_prog = find_program(scdoc.get_variable(pkgconfig: 'scdoc'), 
native: true)
        mandir = get_option('mandir')
 
        foreach src : ['seatd.1.scd', 'seatd-launch.1.scd']
@@ -259,9 +272,9 @@
                        output,
                        input: 'man/' + src,
                        output: output,
-                       command: [
-                               'sh', '-c', '@0@ < @INPUT@ > 
@1@'.format(scdoc_prog.full_path(), output)
-                       ],
+                       command: scdoc.get_variable(pkgconfig: 'scdoc'),
+                       feed: true,
+                       capture: true,
                        install: true,
                        install_dir: '@0@/man@1@'.format(mandir, section)
                )
@@ -271,7 +284,7 @@
 summary({
        'libseat-seatd': with_seatd,
        'libseat-builtin': with_builtin,
-       'libseat-systemd': logind.found() and logind_provider == 'systemd',
-       'libseat-elogind': logind.found() and logind_provider == 'elogind',
+       'libseat-systemd': logind.found() and logind.name() == 'libsystemd',
+       'libseat-elogind': logind.found() and logind.name() == 'libelogind',
        'server': with_server,
 }, bool_yn: true)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/seatd/client.c 
new/seatd-0.7.0/seatd/client.c
--- old/seatd-0.6.4/seatd/client.c      2022-02-21 22:52:04.000000000 +0100
+++ new/seatd-0.7.0/seatd/client.c      2022-05-23 22:03:38.000000000 +0200
@@ -14,6 +14,10 @@
 #include <sys/un.h>
 #endif
 
+#if defined(__NetBSD__)
+#include <sys/un.h>
+#endif
+
 #include "client.h"
 #include "linked_list.h"
 #include "log.h"
@@ -34,6 +38,23 @@
        *uid = cred.uid;
        *gid = cred.gid;
        return 0;
+#elif defined(__NetBSD__)
+       struct unpcbid cred;
+       socklen_t len = sizeof cred;
+       if (getsockopt(fd, 0, LOCAL_PEEREID, &cred, &len) == -1) {
+               // assume builtin backend
+               if (errno == EINVAL) {
+                       *pid = getpid();
+                       *uid = getuid();
+                       *gid = getgid();
+                       return 0;
+               }
+               return -1;
+       }
+       *pid = cred.unp_pid;
+       *uid = cred.unp_euid;
+       *gid = cred.unp_egid;
+       return 0;
 #elif defined(__FreeBSD__)
        struct xucred cred;
        socklen_t len = sizeof cred;
@@ -49,7 +70,7 @@
        *gid = cred.cr_ngroups > 0 ? cred.cr_groups[0] : (gid_t)-1;
        return 0;
 #else
-       return -1;
+#error Unsupported platform
 #endif
 }
 
@@ -81,6 +102,13 @@
 
 void client_destroy(struct client *client) {
        assert(client);
+
+#ifdef LIBSEAT
+       // The built-in backend version of seatd should terminate once its only
+       // client disconnects.
+       client->server->running = false;
+#endif
+
        client->server = NULL;
        if (client->connection.fd != -1) {
                close(client->connection.fd);
@@ -461,7 +489,13 @@
                        goto fail;
                }
                if (len == 0) {
+// https://man.netbsd.org/poll.2
+// Sockets produce POLLIN rather than POLLHUP when the remote end is closed.
+#if defined(__NetBSD__)
+                       log_info("Client disconnected");
+#else
                        log_error("Could not read client connection: 
zero-length read");
+#endif
                        goto fail;
                }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/seatd/seat.c new/seatd-0.7.0/seatd/seat.c
--- old/seatd-0.6.4/seatd/seat.c        2022-02-21 22:52:04.000000000 +0100
+++ new/seatd-0.7.0/seatd/seat.c        2022-05-23 22:03:38.000000000 +0200
@@ -17,6 +17,7 @@
 #include "protocol.h"
 #include "seat.h"
 #include "terminal.h"
+#include "wscons.h"
 
 static int seat_close_client(struct client *client);
 static int vt_close(int vt);
@@ -235,6 +236,8 @@
                type = SEAT_DEVICE_TYPE_EVDEV;
        } else if (path_is_drm(sanitized_path)) {
                type = SEAT_DEVICE_TYPE_DRM;
+       } else if (path_is_wscons(sanitized_path)) {
+               type = SEAT_DEVICE_TYPE_WSCONS;
        } else {
                log_errorf("%s is not a supported device type ", 
sanitized_path);
                errno = ENOENT;
@@ -281,6 +284,9 @@
        case SEAT_DEVICE_TYPE_EVDEV:
                // Nothing to do here
                break;
+       case SEAT_DEVICE_TYPE_WSCONS:
+               // Nothing to do here
+               break;
        default:
                log_error("Invalid seat device type");
                abort();
@@ -333,6 +339,9 @@
                        return -1;
                }
                break;
+       case SEAT_DEVICE_TYPE_WSCONS:
+               // Nothing to do here
+               break;
        default:
                log_error("Invalid seat device type");
                abort();
@@ -382,6 +391,9 @@
        case SEAT_DEVICE_TYPE_EVDEV:
                errno = EINVAL;
                return -1;
+       case SEAT_DEVICE_TYPE_WSCONS:
+               // Nothing to do here
+               break;
        default:
                log_error("Invalid seat device type");
                abort();
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/seatd/seatd.c 
new/seatd-0.7.0/seatd/seatd.c
--- old/seatd-0.6.4/seatd/seatd.c       2022-02-21 22:52:04.000000000 +0100
+++ new/seatd-0.7.0/seatd/seatd.c       2022-05-23 22:03:38.000000000 +0200
@@ -40,15 +40,15 @@
                goto error;
        }
        if (uid != -1 || gid != -1) {
+               if (chmod(path, 0770) == -1) {
+                       log_errorf("Could not chmod socket: %s", 
strerror(errno));
+                       goto error;
+               }
                if (chown(path, uid, gid) == -1) {
                        log_errorf("Could not chown socket to uid %d, gid %d: 
%s", uid, gid,
                                   strerror(errno));
                        goto error;
                }
-               if (chmod(path, 0770) == -1) {
-                       log_errorf("Could not chmod socket: %s", 
strerror(errno));
-                       goto error;
-               }
        }
        return fd;
 error:
@@ -57,35 +57,23 @@
 }
 
 int main(int argc, char *argv[]) {
-       char *loglevel = getenv("SEATD_LOGLEVEL");
-       enum libseat_log_level level = LIBSEAT_LOG_LEVEL_ERROR;
-       if (loglevel != NULL) {
-               if (strcmp(loglevel, "silent") == 0) {
-                       level = LIBSEAT_LOG_LEVEL_SILENT;
-               } else if (strcmp(loglevel, "info") == 0) {
-                       level = LIBSEAT_LOG_LEVEL_INFO;
-               } else if (strcmp(loglevel, "debug") == 0) {
-                       level = LIBSEAT_LOG_LEVEL_DEBUG;
-               }
-       }
-       log_init();
-       libseat_set_log_level(level);
-
        const char *usage = "Usage: seatd [options]\n"
                            "\n"
                            "  -h               Show this help message\n"
-                           "  -n <fd>          FD to notify readiness on\n"
+                           "  -n <fd>  FD to notify readiness on\n"
                            "  -u <user>        User to own the seatd socket\n"
                            "  -g <group>       Group to own the seatd socket\n"
-                           "  -s <path>        Where to create the seatd 
socket\n"
+                           "  -l <loglevel>    Log-level, one of debug, info, 
error or silent\n"
                            "  -v               Show the version number\n"
                            "\n";
 
        int c;
        int uid = -1, gid = -1;
        int readiness = -1;
-       const char *socket_path = getenv("SEATD_SOCK");
-       while ((c = getopt(argc, argv, "vhn:s:g:u:")) != -1) {
+       bool unlink_existing_socket = true;
+       bool chown_socket = true;
+       enum libseat_log_level level = LIBSEAT_LOG_LEVEL_INFO;
+       while ((c = getopt(argc, argv, "vhn:g:u:l:z")) != -1) {
                switch (c) {
                case 'n':
                        readiness = atoi(optarg);
@@ -94,10 +82,11 @@
                                return 1;
                        }
                        break;
-               case 's':
-                       socket_path = optarg;
-                       break;
                case 'u': {
+                       if (!chown_socket) {
+                               fprintf(stderr, "-u/-g and -z are mutually 
exclusive\n");
+                               return 1;
+                       }
                        struct passwd *pw = getpwnam(optarg);
                        if (pw == NULL) {
                                fprintf(stderr, "Could not find user by name 
'%s'.\n", optarg);
@@ -108,6 +97,10 @@
                        break;
                }
                case 'g': {
+                       if (!chown_socket) {
+                               fprintf(stderr, "-u/-g and -z are mutually 
exclusive\n");
+                               return 1;
+                       }
                        struct group *gr = getgrnam(optarg);
                        if (gr == NULL) {
                                fprintf(stderr, "Could not find group by name 
'%s'.\n", optarg);
@@ -117,6 +110,31 @@
                        }
                        break;
                }
+               case 'l':
+                       if (strcmp(optarg, "debug") == 0) {
+                               level = LIBSEAT_LOG_LEVEL_DEBUG;
+                       } else if (strcmp(optarg, "info") == 0) {
+                               level = LIBSEAT_LOG_LEVEL_INFO;
+                       } else if (strcmp(optarg, "error") == 0) {
+                               level = LIBSEAT_LOG_LEVEL_ERROR;
+                       } else if (strcmp(optarg, "silent") == 0) {
+                               level = LIBSEAT_LOG_LEVEL_SILENT;
+                       } else {
+                               fprintf(stderr, "Invalid loglevel: %s\n", 
optarg);
+                               return 1;
+                       }
+                       break;
+               case 'z':
+                       // Running under seatd-launch. We do not unlink files
+                       // to protect against multiple instances, and
+                       // seatd-launch takes care of ownership.
+                       if (uid != -1 || gid != -1) {
+                               fprintf(stderr, "-u/-g and -z are mutually 
exclusive\n");
+                               return 1;
+                       }
+                       unlink_existing_socket = false;
+                       chown_socket = false;
+                       break;
                case 'v':
                        printf("seatd version %s\n", SEATD_VERSION);
                        return 0;
@@ -131,33 +149,46 @@
                }
        }
 
-       if (socket_path == NULL) {
-               socket_path = SEATD_DEFAULTPATH;
-               struct stat st;
-               if (stat(socket_path, &st) == 0) {
-                       log_info("Removing leftover seatd socket");
-                       unlink(socket_path);
+       log_init();
+       libseat_set_log_level(level);
+
+       struct stat st;
+       if (lstat(SEATD_DEFAULTPATH, &st) == 0) {
+               if (!S_ISSOCK(st.st_mode)) {
+                       log_errorf("Non-socket file found at socket path %s, 
refusing to start",
+                                  SEATD_DEFAULTPATH);
+                       return 1;
+               } else if (!unlink_existing_socket) {
+                       log_errorf("Socket file found at socket path %s, 
refusing to start",
+                                  SEATD_DEFAULTPATH);
+                       return 1;
+               } else {
+                       // We only do this if the socket path is not user 
specified
+                       log_infof("Removing leftover socket at %s", 
SEATD_DEFAULTPATH);
+                       if (unlink(SEATD_DEFAULTPATH) == -1) {
+                               log_errorf("Could not remove leftover socket: 
%s", strerror(errno));
+                               return 1;
+                       }
                }
        }
 
        struct server server = {0};
        if (server_init(&server) == -1) {
-               log_errorf("server_create failed: %s", strerror(errno));
+               log_errorf("server_init failed: %s", strerror(errno));
                return 1;
        }
 
-       int socket_fd = open_socket(socket_path, uid, gid);
+       int ret = 1;
+       int socket_fd = open_socket(SEATD_DEFAULTPATH, uid, gid);
        if (socket_fd == -1) {
                log_error("Could not create server socket");
-               server_finish(&server);
-               return 1;
+               goto error_server;
        }
        if (poller_add_fd(&server.poller, socket_fd, EVENT_READABLE, 
server_handle_connection,
                          &server) == NULL) {
                log_errorf("Could not add socket to poller: %s", 
strerror(errno));
                close(socket_fd);
-               server_finish(&server);
-               return 1;
+               goto error_socket;
        }
 
        log_info("seatd started");
@@ -172,12 +203,18 @@
        while (server.running) {
                if (poller_poll(&server.poller) == -1) {
                        log_errorf("Poller failed: %s", strerror(errno));
-                       return 1;
+                       goto error_socket;
                }
        }
 
+       ret = 0;
+
+error_socket:
+       if (unlink(SEATD_DEFAULTPATH) == -1) {
+               log_errorf("Could not remove socket: %s", strerror(errno));
+       }
+error_server:
        server_finish(&server);
-       unlink(socket_path);
        log_info("seatd stopped");
-       return 0;
+       return ret;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/seatd/server.c 
new/seatd-0.7.0/seatd/server.c
--- old/seatd-0.6.4/seatd/server.c      2022-02-21 22:52:04.000000000 +0100
+++ new/seatd-0.7.0/seatd/server.c      2022-05-23 22:03:38.000000000 +0200
@@ -123,12 +123,18 @@
 
 int server_add_client(struct server *server, int fd) {
        if (set_nonblock(fd) != 0) {
-               close(fd);
                log_errorf("Could not prepare new client socket: %s", 
strerror(errno));
+               close(fd);
                return -1;
        }
 
        struct client *client = client_create(server, fd);
+       if (client == NULL) {
+               log_errorf("Could not create client: %s", strerror(errno));
+               close(fd);
+               return -1;
+       }
+
        client->event_source =
                poller_add_fd(&server->poller, fd, EVENT_READABLE, 
client_handle_connection, client);
        if (client->event_source == NULL) {
@@ -146,7 +152,7 @@
        if (mask & (EVENT_ERROR | EVENT_HANGUP)) {
                shutdown(fd, SHUT_RDWR);
                server->running = false;
-               log_errorf("Server socket received an error: %s", 
strerror(errno));
+               log_error("Server socket received an error");
                return -1;
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/seatd-0.6.4/seatd-launch/seatd-launch.c 
new/seatd-0.7.0/seatd-launch/seatd-launch.c
--- old/seatd-0.6.4/seatd-launch/seatd-launch.c 2022-02-21 22:52:04.000000000 
+0100
+++ new/seatd-0.7.0/seatd-launch/seatd-launch.c 2022-05-23 22:03:38.000000000 
+0200
@@ -11,17 +11,21 @@
 #include <unistd.h>
 
 int main(int argc, char *argv[]) {
-       (void)argc;
-
        const char *usage = "Usage: seatd-launch [options] [--] command\n"
                            "\n"
-                           "  -h       Show this help message\n"
-                           "  -v       Show the version number\n"
+                           "  -l <loglevel>    Log-level to pass to seatd\n"
+                           "  -h               Show this help message\n"
+                           "  -v               Show the version number\n"
                            "\n";
 
        int c;
-       while ((c = getopt(argc, argv, "vh")) != -1) {
+       char loglevel[16] = "info";
+       while ((c = getopt(argc, argv, "vhl:")) != -1) {
                switch (c) {
+               case 'l':
+                       strncpy(loglevel, optarg, sizeof loglevel);
+                       loglevel[sizeof loglevel - 1] = '\0';
+                       break;
                case 'v':
                        printf("seatd-launch version %s\n", SEATD_VERSION);
                        return 0;
@@ -29,7 +33,7 @@
                        printf("%s", usage);
                        return 0;
                case '?':
-                       fprintf(stderr, "Try '%s -h' for more information.\n", 
argv[0]);
+                       fprintf(stderr, "Try 'seatd-launch -h' for more 
information.\n");
                        return 1;
                default:
                        abort();
@@ -42,41 +46,30 @@
        }
        char **command = &argv[optind];
 
-       char sockpath[32];
-       snprintf(sockpath, sizeof sockpath, "/tmp/seatd.%d.sock", getpid());
-
-       unlink(sockpath);
-
-       int fds[2];
-       if (pipe(fds) == -1) {
+       int readiness_pipe[2];
+       if (pipe(readiness_pipe) == -1) {
                perror("Could not create pipe");
                goto error;
        }
 
+       // Start seatd
        pid_t seatd_child = fork();
        if (seatd_child == -1) {
                perror("Could not fork seatd process");
                goto error;
        } else if (seatd_child == 0) {
-               close(fds[0]);
+               close(readiness_pipe[0]);
 
                char pipebuf[16] = {0};
-               snprintf(pipebuf, sizeof pipebuf, "%d", fds[1]);
+               snprintf(pipebuf, sizeof pipebuf, "%d", readiness_pipe[1]);
 
-               char *env[2] = {NULL, NULL};
-               char loglevelbuf[32] = {0};
-               char *cur_loglevel = getenv("SEATD_LOGLEVEL");
-               if (cur_loglevel != NULL) {
-                       snprintf(loglevelbuf, sizeof loglevelbuf, 
"SEATD_LOGLEVEL=%s", cur_loglevel);
-                       env[0] = loglevelbuf;
-               }
-
-               char *command[] = {"seatd", "-n", pipebuf, "-s", sockpath, 
NULL};
+               char *env[1] = {NULL};
+               char *command[] = {"seatd", "-n", pipebuf, "-l", loglevel, 
"-z", NULL};
                execve(SEATD_INSTALLPATH, command, env);
                perror("Could not start seatd");
                _exit(1);
        }
-       close(fds[1]);
+       close(readiness_pipe[1]);
 
        // Wait for seatd to be ready
        char buf[1] = {0};
@@ -91,7 +84,7 @@
                }
 
                struct pollfd fd = {
-                       .fd = fds[0],
+                       .fd = readiness_pipe[0],
                        .events = POLLIN,
                };
 
@@ -106,7 +99,7 @@
                }
 
                if (fd.revents & POLLIN) {
-                       ssize_t n = read(fds[0], buf, 1);
+                       ssize_t n = read(readiness_pipe[0], buf, 1);
                        if (n == -1 && errno != EINTR) {
                                perror("Could not read from pipe");
                                goto error_seatd;
@@ -115,17 +108,17 @@
                        }
                }
        }
-       close(fds[0]);
+       close(readiness_pipe[0]);
 
        uid_t uid = getuid();
        gid_t gid = getgid();
 
        // Restrict access to the socket to just us
-       if (chown(sockpath, uid, gid) == -1) {
+       if (chown(SEATD_DEFAULTPATH, uid, gid) == -1) {
                perror("Could not chown seatd socket");
                goto error_seatd;
        }
-       if (chmod(sockpath, 0700) == -1) {
+       if (chmod(SEATD_DEFAULTPATH, 0700) == -1) {
                perror("Could not chmod socket");
                goto error_seatd;
        }
@@ -145,7 +138,7 @@
                perror("Could not fork target process");
                goto error_seatd;
        } else if (child == 0) {
-               setenv("SEATD_SOCK", sockpath, 1);
+               setenv("SEATD_SOCK", SEATD_DEFAULTPATH, 1);
                execvp(command[0], command);
                perror("Could not start target");
                _exit(1);
@@ -162,9 +155,6 @@
                }
        }
 
-       if (unlink(sockpath) != 0) {
-               perror("Could not unlink socket");
-       }
        if (kill(seatd_child, SIGTERM) != 0) {
                perror("Could not kill seatd");
        }
@@ -178,7 +168,6 @@
        }
 
 error_seatd:
-       unlink(sockpath);
        kill(seatd_child, SIGTERM);
 error:
        return 1;

++++++ seatd.obsinfo ++++++
--- /var/tmp/diff_new_pack.KJeLHp/_old  2023-06-30 20:00:00.446048586 +0200
+++ /var/tmp/diff_new_pack.KJeLHp/_new  2023-06-30 20:00:00.446048586 +0200
@@ -1,6 +1,5 @@
 name: seatd
-version: 0.6.4
-mtime: 1645480324
-commit: df13d03f9cfd0dc0c2b3298cd0e5eb4e4a10835e
-
+version: 0.7.0
+mtime: 1653336218
+commit: a803ba0502cccf147eec7fbcacd11c5b8643c0e0
 

Reply via email to