[pulseaudio-commits] r1120 - /trunk/src/daemon/main.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Thu Jul 20 06:24:05 PDT 2006
Author: ossman
Date: Thu Jul 20 15:24:04 2006
New Revision: 1120
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1120&root=pulseaudio&view=rev
Log:
Centralise check if we're running as root.
Modified:
trunk/src/daemon/main.c
Modified: trunk/src/daemon/main.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/daemon/main.c?rev=1120&root=pulseaudio&r1=1119&r2=1120&view=diff
==============================================================================
--- trunk/src/daemon/main.c (original)
+++ trunk/src/daemon/main.c Thu Jul 20 15:24:04 2006
@@ -314,7 +314,7 @@
char *s;
int r, retval = 1, d = 0;
int daemon_pipe[2] = { -1, -1 };
- int suid_root;
+ int suid_root, real_root;
int valid_pid_file = 0;
#ifdef HAVE_GETUID
@@ -331,13 +331,15 @@
pa_limit_caps();
#ifdef HAVE_GETUID
- suid_root = getuid() != 0 && geteuid() == 0;
+ real_root = getuid() == 0;
+ suid_root = !real_root && geteuid() == 0;
if (suid_root && (pa_own_uid_in_group(PA_REALTIME_GROUP, &gid) <= 0 || gid >= 1000)) {
pa_log_warn(__FILE__": WARNING: called SUID root, but not in group '"PA_REALTIME_GROUP"'.");
pa_drop_root();
}
#else
+ real_root = 0;
suid_root = 0;
#endif
@@ -434,10 +436,10 @@
assert(conf->cmd == PA_CMD_DAEMON);
}
- if (getuid() == 0 && !conf->system_instance) {
+ if (real_root && !conf->system_instance) {
pa_log(__FILE__": This program is not intended to be run as root (unless --system is specified).");
goto finish;
- } else if (getuid() != 0 && conf->system_instance) {
+ } else if (!real_root && conf->system_instance) {
pa_log(__FILE__": Root priviliges required.");
goto finish;
}
More information about the pulseaudio-commits
mailing list