From 3b1efca5f7573e8123d8bfd6ef21c1868547c279 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Tue, 7 Aug 2007 13:13:57 +0000 Subject: [PATCH] Fixed setuid code --- src/hal.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/hal.c b/src/hal.c index 4c34a0a..6f1201c 100644 --- a/src/hal.c +++ b/src/hal.c @@ -27,18 +27,20 @@ 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))) { /* Workaround for https://bugs.freedesktop.org/show_bug.cgi?id=11876 */ - if (!geteuid() && (real_uid = getuid())) + uid_t ruid; + uid_t euid; + + if (!(euid = geteuid()) && (ruid = getuid())) { dbus_error_free(&error); - setuid(geteuid()); + setreuid(euid, euid); dbus = dbus_bus_get(DBUS_BUS_SYSTEM, &error); - setuid(real_uid); + setreuid(ruid, euid); } if (!dbus) {