summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6969c62)
raw | patch | inline | side by side (parent: 6969c62)
author | Marc Fournier <marc.fournier@camptocamp.com> | |
Wed, 25 Jan 2017 06:37:41 +0000 (07:37 +0100) | ||
committer | Marc Fournier <marc.fournier@camptocamp.com> | |
Wed, 25 Jan 2017 06:37:41 +0000 (07:37 +0100) |
src/daemon/common.c | patch | blob | history | |
src/daemon/common.h | patch | blob | history |
diff --git a/src/daemon/common.c b/src/daemon/common.c
index 7ead55d12a411b62ad1831c9618a1f87ecaa3d6e..2be2e8e57c31d175189f0287ca0b9e4acbe8c37d 100644 (file)
--- a/src/daemon/common.c
+++ b/src/daemon/common.c
#if HAVE_CAPABILITY
int check_capability(int arg) /* {{{ */
{
- cap_value_t cap = (cap_value_t)arg;
+ cap_value_t cap_value = (cap_value_t)arg;
+ cap_t cap;
+ cap_flag_value_t cap_flag_value;
- if (!CAP_IS_SUPPORTED(cap))
+ if (!CAP_IS_SUPPORTED(cap_value))
return (-1);
- int have_cap = cap_get_bound(cap);
- if (have_cap != 1)
+ if (!(cap = cap_get_proc())) {
+ ERROR("check_capability: cap_get_proc failed.");
return (-1);
+ }
- return (0);
+ if (cap_get_flag(cap, cap_value, CAP_EFFECTIVE, &cap_flag_value) < 0) {
+ ERROR("check_capability: cap_get_flag failed.");
+ cap_free(cap);
+ return (-1);
+ }
+ cap_free(cap);
+
+ return (cap_flag_value != CAP_SET);
} /* }}} int check_capability */
#else
int check_capability(__attribute__((unused)) int arg) /* {{{ */
diff --git a/src/daemon/common.h b/src/daemon/common.h
index a88e73e00de860a61b6e41b7bf3992b01eb38f9b..2a0b9ee7f79a1da33ff1b4aba741280495ca91a8 100644 (file)
--- a/src/daemon/common.h
+++ b/src/daemon/common.h
* argument. Returns zero if it does, less than zero if it doesn't or on error.
* See capabilities(7) for the list of possible capabilities.
* */
-int check_capability(int capability);
+int check_capability(int arg);
#endif /* HAVE_SYS_CAPABILITY_H */
#endif /* COMMON_H */