{
int ret;
-#ifdef HAVE_SYS_CAPABILITY_H
+#if defined(HAVE_SYS_CAPABILITY_H) && defined(CAP_DAC_OVERRIDE)
if (check_capability (CAP_DAC_OVERRIDE) != 0)
{
if (getuid () == 0)
#ifdef HAVE_SYS_CAPABILITY_H
int check_capability (int capability) /* {{{ */
{
+#ifdef _LINUX_CAPABILITY_VERSION_3
struct __user_cap_header_struct cap_header_data;
cap_user_header_t cap_header = &cap_header_data;
struct __user_cap_data_struct cap_data_data;
return (-1);
else
return (0);
+#else
+ WARNING ("check_capability: unsupported capability implementation. "
+ "Some plugin(s) may require elevated privileges to work properly.");
+ return (0);
+#endif /* _LINUX_CAPABILITY_VERSION_3 */
} /* }}} int check_capability */
-#endif
+#endif /* HAVE_SYS_CAPABILITY_H */
listen_thread_init = 1;
-#ifdef HAVE_SYS_CAPABILITY_H
+#if defined(HAVE_SYS_CAPABILITY_H) && defined(CAP_NET_RAW)
if (check_capability (CAP_NET_RAW) != 0)
{
if (getuid () == 0)
sigaction (SIGCHLD, &sa, NULL);
-#ifdef HAVE_SYS_CAPABILITY_H
+#if defined(HAVE_SYS_CAPABILITY_H) && defined(CAP_SETUID) && defined(CAP_SETGID)
if ((check_capability (CAP_SETUID) != 0) ||
(check_capability (CAP_SETGID) != 0))
{
static int iptables_init (void)
{
-#ifdef HAVE_SYS_CAPABILITY_H
+#if defined(HAVE_SYS_CAPABILITY_H) && defined(CAP_NET_ADMIN)
if (check_capability (CAP_NET_ADMIN) != 0)
{
if (getuid () == 0)
"Will use a timeout of %gs.", ping_timeout);
}
-#ifdef HAVE_SYS_CAPABILITY_H
+#if defined(HAVE_SYS_CAPABILITY_H) && defined(CAP_NET_RAW)
if (check_capability (CAP_NET_RAW) != 0)
{
if (getuid () == 0)
if (getuid() == 0) {
/* We have everything we need */
return 0;
-#ifndef HAVE_SYS_CAPABILITY_H
+#if !defined(HAVE_SYS_CAPABILITY_H) && !defined(CAP_SYS_RAWIO)
} else {
ERROR("turbostat plugin: Initialization failed: this plugin "
"requires collectd to run as root");
return -1;
}
-#else /* HAVE_SYS_CAPABILITY_H */
+#else /* HAVE_SYS_CAPABILITY_H && CAP_SYS_RAWIO */
}
if (check_capability(CAP_SYS_RAWIO) != 0) {
"collectd a special capability (CAP_SYS_RAWIO) and read "
"access to /dev/cpu/*/msr (see previous warnings)");
return ret;
-#endif /* HAVE_SYS_CAPABILITY_H */
+#endif /* HAVE_SYS_CAPABILITY_H && CAP_SYS_RAWIO */
}
static int