mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
add a few more asserts, don't allow pa_limit_caps() to fail
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/glitch-free@2370 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
71d14d40c8
commit
4fa6cb4589
2 changed files with 10 additions and 20 deletions
|
|
@ -85,31 +85,21 @@ void pa_drop_root(void) {
|
|||
#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 @@ void pa_drop_caps(void) {
|
|||
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue