Browse Source

Fixed setuid code

Andrea Luzzardi 17 years ago
parent
commit
3b1efca5f7
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      src/hal.c

+ 6
- 4
src/hal.c View File

@ -27,18 +27,20 @@ DBusConnection *pusb_hal_dbus_connect(void)
{ {
DBusConnection *dbus = NULL; DBusConnection *dbus = NULL;
DBusError error; DBusError error;
uid_t real_uid;
dbus_error_init(&error); dbus_error_init(&error);
if (!(dbus = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) if (!(dbus = dbus_bus_get(DBUS_BUS_SYSTEM, &error)))
{ {
/* Workaround for https://bugs.freedesktop.org/show_bug.cgi?id=11876 */ /* 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); dbus_error_free(&error);
setuid(geteuid());
setreuid(euid, euid);
dbus = dbus_bus_get(DBUS_BUS_SYSTEM, &error); dbus = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
setuid(real_uid);
setreuid(ruid, euid);
} }
if (!dbus) if (!dbus)
{ {


Loading…
Cancel
Save