]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
build: add elogind support
authorDudemanguy <random342@airmail.cc>
Fri, 20 Dec 2024 16:53:28 +0000 (10:53 -0600)
committerSimon McVittie <smcv@collabora.com>
Mon, 11 Aug 2025 14:35:17 +0000 (14:35 +0000)
Checking the uid of the user seat also works if elogind is used. Add
this as an option to the build and make it mutually exclusive with
enabling systemd.

dbus/dbus-userdb-util.c
dbus/meson.build
meson.build
meson_options.txt

index 736244955bdedf18351a76b94861473ff043f9b4..a7b61130980b2710987e00435e7445f0c7a42649 100644 (file)
 #include <systemd/sd-login.h>
 #endif
 
+#ifdef HAVE_ELOGIND
+#include <elogind/sd-login.h>
+#endif
+
 /**
  * @addtogroup DBusInternalsUtils
  * @{
@@ -67,7 +71,7 @@ dbus_bool_t
 _dbus_is_console_user (dbus_uid_t uid,
                       DBusError *error)
 {
-#ifdef HAVE_SYSTEMD
+#if defined(HAVE_SYSTEMD) || defined(HAVE_ELOGIND)
   /* check if we have logind */
   if (access ("/run/systemd/seats/", F_OK) >= 0)
     {
index 4c9f7be170c6db0d9de0db9af2b8c2d06a21aa93..a5946b6905d979f22f3248abe9ee6f6eb21fbf72 100644 (file)
@@ -24,6 +24,7 @@ dbus_dependencies = [
     adt_libs,
     network_libs,
     systemd,
+    elogind,
     valgrind.partial_dependency(compile_args: true),
 ]
 
index 451da911446e492db69353ddf0c64b48d60ea8d6..ae63f45d8d8f60533db7eef514f24c9e7c6fa9c7 100644 (file)
@@ -535,6 +535,17 @@ else
 endif
 data_config.set('SYSTEMCTL', systemctl)
 
+elogind_opt = get_option('elogind')
+if use_systemd
+    if elogind_opt.enabled()
+        error('-Dsystemd and -Delogind are mutually exclusive')
+    endif
+    elogind = dependency('', required: false)
+else
+    elogind = dependency('libelogind', version: '>=209', required: elogind_opt)
+endif
+use_elogind = elogind.found()
+config.set('HAVE_ELOGIND', use_elogind)
 
 
 use_traditional_activation = message_bus and get_option('traditional_activation')
@@ -1378,6 +1389,7 @@ summary_dict += {
     'Building inotify support': use_inotify,
     'Building kqueue support':  use_kqueue,
     'Building systemd support': use_systemd,
+    'Building elogind support': use_elogind,
     'Traditional activation':   use_traditional_activation,
     'Building X11 code':        config.get('DBUS_BUILD_X11'),
     'Building Doxygen docs':    doxygen.found(),
index 079b04da8e27d90f12db57f17bf24c3952405814..38ff03220d6dfaa016b111876cd3d37677b0d47d 100644 (file)
@@ -95,6 +95,13 @@ option(
   description: 'Enable tests that require insecure extra code in the library and binaries'
 )
 
+option(
+  'elogind',
+  type: 'feature',
+  value: 'disabled',
+  description: 'Use elogind for detecting user sessions'
+)
+
 option(
   'epoll',
   type: 'feature',