Skip to content

Commit

Permalink
Merge branch 'collectd-5.7'
Browse files Browse the repository at this point in the history
Conflicts:
	configure.ac
  • Loading branch information
rubenk committed Feb 24, 2017
2 parents 64b8150 + 11c8a76 commit c3d354c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
6 changes: 3 additions & 3 deletions configure.ac
Expand Up @@ -585,14 +585,14 @@ if test "x$ac_system" = "xLinux"; then
)

if test "x$have_capability" = "xyes"; then
AC_CHECK_LIB([cap], [cap_get_bound],
AC_CHECK_LIB([cap], [cap_get_proc],
[have_capability="yes"],
[have_capability="no (cap_get_bound() not found)"]
[have_capability="no (cap_get_proc() not found)"]
)
fi

if test "x$have_capability" = "xyes"; then
AC_DEFINE([HAVE_CAPABILITY], [1], [Define to 1 if you have cap_get_bound() (-lcap).])
AC_DEFINE([HAVE_CAPABILITY], [1], [Define to 1 if you have cap_get_proc() (-lcap).])
fi

else
Expand Down
20 changes: 15 additions & 5 deletions src/daemon/common.c
Expand Up @@ -1564,16 +1564,26 @@ void strarray_free(char **array, size_t array_len) /* {{{ */
#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) /* {{{ */
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/common.h
Expand Up @@ -385,7 +385,7 @@ void strarray_free(char **array, size_t array_len);
* 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 */

0 comments on commit c3d354c

Please sign in to comment.