mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-13 13:29:58 -05:00
allow high priority scheduling only for users in group "realtime"
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@238 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
8176b3a1ba
commit
ed36241085
4 changed files with 96 additions and 21 deletions
26
polyp/caps.c
26
polyp/caps.c
|
|
@ -36,14 +36,19 @@
|
|||
#include "caps.h"
|
||||
|
||||
void pa_drop_root(void) {
|
||||
if (getuid() != 0 && geteuid() == 0) {
|
||||
pa_log(__FILE__": Started SUID root, dropping root rights.\n");
|
||||
setuid(getuid());
|
||||
seteuid(getuid());
|
||||
}
|
||||
uid_t uid = getuid();
|
||||
|
||||
if (uid == 0 || geteuid() != 0)
|
||||
return;
|
||||
|
||||
pa_log(__FILE__": dropping root rights.\n");
|
||||
|
||||
setuid(uid);
|
||||
seteuid(uid);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SYS_CAPABILITY_H
|
||||
|
||||
int pa_limit_caps(void) {
|
||||
int r = -1;
|
||||
cap_t caps;
|
||||
|
|
@ -53,14 +58,15 @@ int pa_limit_caps(void) {
|
|||
assert(caps);
|
||||
|
||||
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;
|
||||
|
||||
pa_log(__FILE__": Started SUID root, capabilities limited.\n");
|
||||
|
||||
pa_log(__FILE__": dropped capabilities successfully.\n");
|
||||
|
||||
r = 0;
|
||||
|
||||
fail:
|
||||
|
|
@ -78,10 +84,10 @@ int pa_drop_caps(void) {
|
|||
|
||||
cap_clear(caps);
|
||||
|
||||
if (cap_set_proc(caps) < 0)
|
||||
if (cap_set_proc(caps) < 0) {
|
||||
pa_log(__FILE__": failed to drop capabilities: %s\n", strerror(errno));
|
||||
goto fail;
|
||||
|
||||
pa_drop_root();
|
||||
}
|
||||
|
||||
r = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue