summaryrefslogtreecommitdiff
path: root/src/daemon
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2013-12-10 16:47:53 -0500
committerTanu Kaskinen <tanu.kaskinen@linux.intel.com>2013-12-20 21:48:50 +0200
commit1da34e99b203de14a45c94ec768faf04d41eca5b (patch)
tree8768e936f1d51ede3664a578a767b95bd723c7f5 /src/daemon
parent5d2d9e57006c6509ef6d173b89502685ff429449 (diff)
Add support for FreeBSD <sys/capability.h>
cap_init() and friends are Linux-specific, so only use them if we're on Linux. Add support for FreeBSD capabilities if we find <sys/capability.h> to be available there. Add an #else (not Linux or FreeBSD) case with an #error requesting contributions for other platforms. This patch keeps the cap_init check in configure.ac but removes the error if it fails. This will ensure we link to -lcap if needed, but won't fail for the case that capabilities are part of the core system (as on FreeBSD). We do however, modify the header check to ensure we fail if there is no <sys/capability.h> at all and we are on a system where it could be installed. The logic here is that it is better to give the user the chance to install it than it is to proceed silently with a disabled security feature on a system where it could easily be supported. --without-caps remains an option if the user wants to force it. https://bugs.freedesktop.org/show_bug.cgi?id=72580
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/caps.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/daemon/caps.c b/src/daemon/caps.c
index 2251cb373..68b79cebd 100644
--- a/src/daemon/caps.c
+++ b/src/daemon/caps.c
@@ -80,12 +80,18 @@ void pa_drop_root(void) {
void pa_drop_caps(void) {
#ifdef HAVE_SYS_CAPABILITY_H
+#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.");