From 8e6df662ea484a160ec2d477be873cb4ba68199d Mon Sep 17 00:00:00 2001 From: Herman Semenoff Date: Wed, 4 Feb 2026 15:19:50 +0300 Subject: [PATCH] dbus: added _dbus_lookup_session_address_seatd --- dbus/dbus-sysdeps-unix.c | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 354c7481..fd140102 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -4606,6 +4606,53 @@ _dbus_lookup_session_address_launchd (dbus_bool_t *supported, } #endif +#ifdef HAVE_SEATD +static dbus_bool_t +_dbus_lookup_session_address_seatd (dbus_bool_t *supported, + DBusString *address, + DBusError *error) +{ + int seatd_fd = -1; + struct seatd_seat *seat = NULL; + + if (_dbus_check_setuid ()) + { + dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, + "Unable to get seatd socket when setuid"); + return FALSE; + } + + seatd_fd = seatd_open_seat(&seat); + if (seatd_fd < 0) + { + _dbus_verbose ("Could not open seatd seat: %s\n", strerror(-seatd_fd)); + *supported = FALSE; + return TRUE; + } + + seatd_close_seat(seat); + close(seatd_fd); + + const char *seatd_sock = getenv("SEATD_SOCK"); + if (seatd_sock == NULL) + { + _dbus_verbose ("SEATD_SOCK not in environment"); + *supported = FALSE; + return TRUE; + } + + if (!_dbus_string_append (address, "unix:path=") || + !_dbus_string_append (address, seatd_sock)) + { + _DBUS_SET_OOM (error); + return FALSE; + } + + *supported = TRUE; + return TRUE; +} +#endif + static dbus_bool_t _dbus_lookup_user_bus (dbus_bool_t *supported, DBusString *address, @@ -4707,6 +4754,13 @@ _dbus_lookup_session_address (dbus_bool_t *supported, #else *supported = FALSE; +#ifdef HAVE_SEATD + if (!_dbus_lookup_session_address_seatd (supported, address, error)) + return FALSE; + else if (*supported) + return TRUE; +#endif + if (!_dbus_lookup_user_bus (supported, address, error)) return FALSE; else if (*supported)