From b55fc618aa09fc1b0e20845d1f02871efee8a4a7 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Tue, 7 Aug 2007 12:43:18 +0000 Subject: [PATCH] Workaround for dbus --- src/hal.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/hal.c b/src/hal.c index e75ed2a..4c34a0a 100644 --- a/src/hal.c +++ b/src/hal.c @@ -17,6 +17,8 @@ #include #include +#include +#include #include #include #include "log.h" @@ -25,14 +27,26 @@ DBusConnection *pusb_hal_dbus_connect(void) { DBusConnection *dbus = NULL; DBusError error; + uid_t real_uid; dbus_error_init(&error); if (!(dbus = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) { - log_error("Cannot connect to system bus: %s\n", - error.message); - dbus_error_free(&error); - return (NULL); + /* Workaround for https://bugs.freedesktop.org/show_bug.cgi?id=11876 */ + if (!geteuid() && (real_uid = getuid())) + { + dbus_error_free(&error); + setuid(geteuid()); + dbus = dbus_bus_get(DBUS_BUS_SYSTEM, &error); + setuid(real_uid); + } + if (!dbus) + { + log_error("Cannot connect to system bus: %s\n", + error.message); + dbus_error_free(&error); + return (NULL); + } } return (dbus); }