]> code.delx.au - pulseaudio/commitdiff
never stay root after startup, even if we don't have capabilites
authorLennart Poettering <lennart@poettering.net>
Thu, 16 Aug 2007 19:48:49 +0000 (19:48 +0000)
committerLennart Poettering <lennart@poettering.net>
Thu, 16 Aug 2007 19:48:49 +0000 (19:48 +0000)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1678 fefdeb5f-60dc-0310-8127-8f9354f1896f

src/daemon/main.c

index eac470bff0a020b404ca1850812c69c1112a80b9..cf2e628bc440050a2eb5c8aab54f4f754a8d41f1 100644 (file)
@@ -336,10 +336,19 @@ int main(int argc, char *argv[]) {
 #endif
 
     if (suid_root) {
-        if (pa_limit_caps() > 0)
-            /* We managed to drop capabilities except the needed
-             * ones. Hence we can drop the uid. */
-            pa_drop_root();
+        /* Drop all capabilities except CAP_SYS_NICE  */
+        pa_limit_caps();
+
+        /* Drop priviliges, but keep CAP_SYS_NICE */
+        pa_drop_root();
+
+        /* After dropping root, the effective set is reset, hence,
+         * let's raise it again */
+        pa_limit_caps();
+
+        /* When capabilities are not supported we will not be able to
+         * aquire RT sched anymore. But yes, that's the way it is. It
+         * is just too risky tun let PA run as root all the time. */
     }
 
     setlocale(LC_ALL, "");
@@ -386,7 +395,7 @@ int main(int argc, char *argv[]) {
     if (conf->high_priority && conf->cmd == PA_CMD_DAEMON)
         pa_raise_priority();
 
-    if (suid_root) {
+    if (suid_root && conf->cmd != PA_CMD_DAEMON) {
         pa_drop_caps();
         pa_drop_root();
     }