[pulseaudio-commits] r2370 - in /branches/glitch-free/src/daemon: caps.c caps.h

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Tue May 6 14:10:55 PDT 2008


Author: lennart
Date: Tue May  6 23:10:53 2008
New Revision: 2370

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2370&root=pulseaudio&view=rev
Log:
add a few more asserts, don't allow pa_limit_caps() to fail

Modified:
    branches/glitch-free/src/daemon/caps.c
    branches/glitch-free/src/daemon/caps.h

Modified: branches/glitch-free/src/daemon/caps.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/daemon/caps.c?rev=2370&root=pulseaudio&r1=2369&r2=2370&view=diff
==============================================================================
--- branches/glitch-free/src/daemon/caps.c (original)
+++ branches/glitch-free/src/daemon/caps.c Tue May  6 23:10:53 2008
@@ -85,31 +85,21 @@
 #if defined(HAVE_SYS_CAPABILITY_H) && defined(HAVE_SYS_PRCTL_H)
 
 /* Limit permitted capabilities set to CAPSYS_NICE */
-int pa_limit_caps(void) {
-    int r = -1;
+void pa_limit_caps(void) {
     cap_t caps;
     cap_value_t nice_cap = CAP_SYS_NICE;
 
     pa_assert_se(caps = cap_init());
+    pa_assert_se(cap_clear(caps) == 0);
+    pa_assert_se(cap_set_flag(caps, CAP_EFFECTIVE, 1, &nice_cap, CAP_SET) == 0);
+    pa_assert_se(cap_set_flag(caps, CAP_PERMITTED, 1, &nice_cap, CAP_SET) == 0);
+    pa_assert_se(cap_set_proc(caps) == 0);
 
-    cap_clear(caps);
-    cap_set_flag(caps, CAP_EFFECTIVE, 1, &nice_cap, CAP_SET);
-    cap_set_flag(caps, CAP_PERMITTED, 1, &nice_cap, CAP_SET);
-
-    if (cap_set_proc(caps) < 0)
-        goto fail;
-
-    if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) < 0)
-        goto fail;
+    pa_assert_se(prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) == 0);
 
     pa_log_info("Dropped capabilities successfully.");
 
-    r = 1;
-
-fail:
-    cap_free(caps);
-
-    return r;
+    pa_assert_se(cap_free(caps) == 0);
 }
 
 /* Drop all capabilities, effectively becoming a normal user */
@@ -119,9 +109,9 @@
     pa_assert_se(prctl(PR_SET_KEEPCAPS, 0, 0, 0, 0) == 0);
 
     pa_assert_se(caps = cap_init());
-    cap_clear(caps);
+    pa_assert_se(cap_clear(caps) == 0);
     pa_assert_se(cap_set_proc(caps) == 0);
-    cap_free(caps);
+    pa_assert_se(cap_free(caps) == 0);
 }
 
 #else

Modified: branches/glitch-free/src/daemon/caps.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/daemon/caps.h?rev=2370&root=pulseaudio&r1=2369&r2=2370&view=diff
==============================================================================
--- branches/glitch-free/src/daemon/caps.h (original)
+++ branches/glitch-free/src/daemon/caps.h Tue May  6 23:10:53 2008
@@ -26,6 +26,6 @@
 
 void pa_drop_root(void);
 void pa_drop_caps(void);
-int pa_limit_caps(void);
+void pa_limit_caps(void);
 
 #endif




More information about the pulseaudio-commits mailing list