Protect getuid() with an ifdef.

git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/ossman@411 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Pierre Ossman 2006-01-05 22:12:25 +00:00
parent 5ac2cb90f7
commit 010476f226
2 changed files with 17 additions and 1 deletions

View file

@ -35,6 +35,8 @@
#include "log.h"
#include "caps.h"
#ifdef HAVE_GETUID
/* Drop root rights when called SUID root */
void pa_drop_root(void) {
uid_t uid = getuid();
@ -54,6 +56,13 @@ void pa_drop_root(void) {
#endif
}
#else
void pa_drop_root(void) {
}
#endif
#ifdef HAVE_SYS_CAPABILITY_H
/* Limit capabilities set to CAPSYS_NICE */

View file

@ -117,18 +117,25 @@ int main(int argc, char *argv[]) {
char *s;
int r, retval = 1, d = 0;
int daemon_pipe[2] = { -1, -1 };
gid_t gid = (gid_t) -1;
int suid_root;
int valid_pid_file = 0;
#ifdef HAVE_GETUID
gid_t gid = (gid_t) -1;
#endif
pa_limit_caps();
#ifdef HAVE_GETUID
suid_root = getuid() != 0 && geteuid() == 0;
if (suid_root && (pa_uid_in_group("realtime", &gid) <= 0 || gid >= 1000)) {
pa_log_warn(__FILE__": WARNING: called SUID root, but not in group 'realtime'.\n");
pa_drop_root();
}
#else
suid_root = 0;
#endif
LTDL_SET_PRELOADED_SYMBOLS();