mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-28 08:26:14 +01:00
Merge branch 'wip/gdbus-even-when-setcap' into 'master'
Resolve GDBus regressions in setcap/setgid programs Closes #2305 See merge request GNOME/glib!1920
This commit is contained in:
commit
018ae0982c
@ -1286,7 +1286,7 @@ g_dbus_address_get_for_bus_sync (GBusType bus_type,
|
|||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean is_setuid = GLIB_PRIVATE_CALL (g_check_setuid) ();
|
gboolean has_elevated_privileges = GLIB_PRIVATE_CALL (g_check_setuid) ();
|
||||||
gchar *ret, *s = NULL;
|
gchar *ret, *s = NULL;
|
||||||
const gchar *starter_bus;
|
const gchar *starter_bus;
|
||||||
GError *local_error;
|
GError *local_error;
|
||||||
@ -1330,7 +1330,11 @@ g_dbus_address_get_for_bus_sync (GBusType bus_type,
|
|||||||
switch (bus_type)
|
switch (bus_type)
|
||||||
{
|
{
|
||||||
case G_BUS_TYPE_SYSTEM:
|
case G_BUS_TYPE_SYSTEM:
|
||||||
ret = !is_setuid ? g_strdup (g_getenv ("DBUS_SYSTEM_BUS_ADDRESS")) : NULL;
|
if (has_elevated_privileges)
|
||||||
|
ret = NULL;
|
||||||
|
else
|
||||||
|
ret = g_strdup (g_getenv ("DBUS_SYSTEM_BUS_ADDRESS"));
|
||||||
|
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
{
|
{
|
||||||
ret = g_strdup ("unix:path=/var/run/dbus/system_bus_socket");
|
ret = g_strdup ("unix:path=/var/run/dbus/system_bus_socket");
|
||||||
@ -1338,7 +1342,33 @@ g_dbus_address_get_for_bus_sync (GBusType bus_type,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case G_BUS_TYPE_SESSION:
|
case G_BUS_TYPE_SESSION:
|
||||||
ret = !is_setuid ? g_strdup (g_getenv ("DBUS_SESSION_BUS_ADDRESS")) : NULL;
|
if (has_elevated_privileges)
|
||||||
|
{
|
||||||
|
#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"));
|
||||||
|
}
|
||||||
|
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
{
|
{
|
||||||
ret = get_session_address_platform_specific (&local_error);
|
ret = get_session_address_platform_specific (&local_error);
|
||||||
|
Loading…
Reference in New Issue
Block a user