#include <sys/capability.h>
#endif
-#ifdef HAVE_SYS_PRCTL_H
-#include <sys/prctl.h>
-#endif
-
#include "caps.h"
/* Glibc <= 2.2 has broken unistd.h */
pa_assert_se(geteuid() == uid);
pa_assert_se(getgid() == gid);
pa_assert_se(getegid() == gid);
-#endif
-#ifdef HAVE_SYS_PRCTL_H
- pa_assert_se(prctl(PR_SET_KEEPCAPS, 0, 0, 0, 0) == 0);
+ if (uid != 0)
+ pa_drop_caps();
#endif
+}
+void pa_drop_caps(void) {
#ifdef HAVE_SYS_CAPABILITY_H
- if (uid != 0) {
- cap_t caps;
- pa_assert_se(caps = cap_init());
- pa_assert_se(cap_clear(caps) == 0);
- pa_assert_se(cap_set_proc(caps) == 0);
- pa_assert_se(cap_free(caps) == 0);
- }
+#ifdef __linux
+ cap_t caps;
+ pa_assert_se(caps = cap_init());
+ pa_assert_se(cap_clear(caps) == 0);
+ pa_assert_se(cap_set_proc(caps) == 0);
+ pa_assert_se(cap_free(caps) == 0);
+#elif __FreeBSD__
+ pa_assert_se (cap_enter () == 0);
+#else
+#error Don't know how to do capabilities on your system. Please send a patch.
+#endif /* __linux */
+#else /* HAVE_SYS_CAPABILITY_H */
+ pa_log_warn("Normally all extra capabilities would be dropped now, but "
+ "that's impossible because this Pulseaudio was built without "
+ "libcap support.");
#endif
}