summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index d39cb48385..75ad56fecf 100644
--- a/src/util.c
+++ b/src/util.c
@@ -50,6 +50,7 @@
#include <linux/kd.h>
#include <dlfcn.h>
#include <sys/wait.h>
+#include <sys/capability.h>
#include "macro.h"
#include "util.h"
@@ -4236,6 +4237,23 @@ void parse_syslog_priority(char **p, int *priority) {
*p += k;
}
+int have_effective_cap(int value) {
+ cap_t cap;
+ cap_flag_value_t fv;
+ int r;
+
+ if (!(cap = cap_get_proc()))
+ return -errno;
+
+ if (cap_get_flag(cap, value, CAP_EFFECTIVE, &fv) < 0)
+ r = -errno;
+ else
+ r = fv == CAP_SET;
+
+ cap_free(cap);
+ return r;
+}
+
static const char *const ioprio_class_table[] = {
[IOPRIO_CLASS_NONE] = "none",
[IOPRIO_CLASS_RT] = "realtime",