summaryrefslogtreecommitdiff
path: root/bus/selinux.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-02-03 08:36:38 +0100
committerRalf Habacker <ralf@winkde.(none)>2010-02-03 08:36:38 +0100
commit15109202a98b0a117f54308d58de4f2034334f92 (patch)
treef9ea524830c724215fb380f6bb189922597a623f /bus/selinux.c
parent19d48c3344fa0b43d960c2f0b8b5fbb2f9f8cb86 (diff)
downloaddbus-15109202a98b0a117f54308d58de4f2034334f92.tar.gz
Fix compilation in --disable-selinux case
_dbus_change_to_daemon_user moved into selinux.c for the --with-selinux (and audit) case because that's where all of the relevant libcap headers were being used. However in the --disable-selinux case this didn't compile and wasn't very clean. If we don't have libaudit, use the legacy direct setgid/setuid bits we had before in dbus-sysdeps-util-unix.c.
Diffstat (limited to 'bus/selinux.c')
-rw-r--r--bus/selinux.c37
1 files changed, 2 insertions, 35 deletions
diff --git a/bus/selinux.c b/bus/selinux.c
index 614fa31b..996cf1d8 100644
--- a/bus/selinux.c
+++ b/bus/selinux.c
@@ -1019,7 +1019,8 @@ bus_selinux_shutdown (void)
#endif /* HAVE_SELINUX */
}
-#ifndef DBUS_WIN
+/* The !HAVE_LIBAUDIT case lives in dbus-sysdeps-util-unix.c */
+#ifdef HAVE_LIBAUDIT
/**
* Changes the user and group the bus is running as.
*
@@ -1045,7 +1046,6 @@ _dbus_change_to_daemon_user (const char *user,
return FALSE;
}
-#ifdef HAVE_LIBAUDIT
/* If we were root */
if (_dbus_geteuid () == 0)
{
@@ -1086,40 +1086,7 @@ _dbus_change_to_daemon_user (const char *user,
return FALSE;
}
}
-#else
- /* setgroups() only works if we are a privileged process,
- * so we don't return error on failure; the only possible
- * failure is that we don't have perms to do it.
- *
- * not sure this is right, maybe if setuid()
- * is going to work then setgroups() should also work.
- */
- if (setgroups (0, NULL) < 0)
- _dbus_warn ("Failed to drop supplementary groups: %s\n",
- _dbus_strerror (errno));
-
- /* Set GID first, or the setuid may remove our permission
- * to change the GID
- */
- if (setgid (gid) < 0)
- {
- dbus_set_error (error, _dbus_error_from_errno (errno),
- "Failed to set GID to %lu: %s", gid,
- _dbus_strerror (errno));
- return FALSE;
- }
-
- if (setuid (uid) < 0)
- {
- dbus_set_error (error, _dbus_error_from_errno (errno),
- "Failed to set UID to %lu: %s", uid,
- _dbus_strerror (errno));
- return FALSE;
- }
-#endif /* !HAVE_LIBAUDIT */
return TRUE;
}
-
#endif
-