gdbus: Use DBUS_SESSION_BUS_ADDRESS if AT_SECURE but not setuid

This is against my better judgement, but it's the least bad regression
fix I can think of. If we don't do this, at least gnome-keyring-daemon
(setcap) and msmtp (setgid) are known to regress.

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/2305
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=981420
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=981555
Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2021-02-02 20:52:03 +00:00
parent 6436d52a0a
commit 7aa0580cc5

View File

@ -1343,9 +1343,31 @@ g_dbus_address_get_for_bus_sync (GBusType bus_type,
case G_BUS_TYPE_SESSION:
if (has_elevated_privileges)
ret = NULL;
{
#ifdef G_OS_UNIX
if (geteuid () == getuid ())
{
/* Ideally we shouldn't do this, because setgid and
* filesystem capabilities are also elevated privileges
* with which we should not be trusting environment variables
* from the caller. Unfortunately, there are programs with
* elevated privileges that rely on the session bus being
* available. We already prevent the really dangerous
* transports like autolaunch: and unixexec: when our
* privileges are elevated, so this can only make us connect
* to the wrong AF_UNIX or TCP socket. */
ret = g_strdup (g_getenv ("DBUS_SESSION_BUS_ADDRESS"));
}
else
#endif
{
ret = NULL;
}
}
else
ret = g_strdup (g_getenv ("DBUS_SESSION_BUS_ADDRESS"));
{
ret = g_strdup (g_getenv ("DBUS_SESSION_BUS_ADDRESS"));
}
if (ret == NULL)
{