]>
code.delx.au - pulseaudio/blob - polyp/caps.c
d03ab14be10f118815ea761df3ad6e3b020149c3
4 This file is part of polypaudio.
6 polypaudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 2 of the License,
9 or (at your option) any later version.
11 polypaudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with polypaudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
31 #ifdef HAVE_SYS_CAPABILITY_H
32 #include <sys/capability.h>
38 void pa_drop_root(void) {
41 if (uid
== 0 || geteuid() != 0)
44 pa_log(__FILE__
": dropping root rights.\n");
51 #ifdef HAVE_SYS_CAPABILITY_H
53 int pa_limit_caps(void) {
56 cap_value_t nice_cap
= CAP_SYS_NICE
;
63 cap_set_flag(caps
, CAP_EFFECTIVE
, 1, &nice_cap
, CAP_SET
);
64 cap_set_flag(caps
, CAP_PERMITTED
, 1, &nice_cap
, CAP_SET
);
66 if (cap_set_proc(caps
) < 0)
69 pa_log(__FILE__
": dropped capabilities successfully.\n");
79 int pa_drop_caps(void) {
88 if (cap_set_proc(caps
) < 0) {
89 pa_log(__FILE__
": failed to drop capabilities: %s\n", strerror(errno
));
103 int pa_limit_caps(void) {
107 int pa_drop_caps(void) {