# include <arpa/inet.h>
#endif
+#if HAVE_CAPABILITY
+# include <sys/capability.h>
+#endif
+
#ifdef HAVE_LIBKSTAT
extern kstat_ctl_t *kc;
#endif
+/* AIX doesn't have MSG_DONTWAIT */
+#ifndef MSG_DONTWAIT
+# define MSG_DONTWAIT MSG_NONBLOCK
+#endif
+
#if !HAVE_GETPWNAM_R
static pthread_mutex_t getpwnam_r_lock = PTHREAD_MUTEX_INITIALIZER;
#endif
}
if (value == endptr) {
- ERROR ("parse_value: Failed to parse string as %s: %s.",
+ ERROR ("parse_value: Failed to parse string as %s: \"%s\".",
DS_TYPE_TO_STRING (ds_type), value);
sfree (value);
return -1;
socklen_t socklen = sizeof (socklen_t);
int so_keepalive = 1;
- int tcp_keepidle = ((CDTIME_T_TO_MS(plugin_get_interval()) - 1) / 100 + 1);
- int tcp_keepintvl = ((CDTIME_T_TO_MS(plugin_get_interval()) - 1) / 1000 + 1);
status = getsockopt (sockfd, SOL_SOCKET, SO_TYPE, &socktype, &socklen);
if (status != 0)
WARNING ("set_sock_opts: failed to set socket keepalive flag");
#ifdef TCP_KEEPIDLE
+ int tcp_keepidle = ((CDTIME_T_TO_MS(plugin_get_interval()) - 1) / 100 + 1);
status = setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPIDLE,
&tcp_keepidle, sizeof (tcp_keepidle));
if (status != 0)
#endif
#ifdef TCP_KEEPINTVL
+ int tcp_keepintvl = ((CDTIME_T_TO_MS(plugin_get_interval()) - 1) / 1000 + 1);
status = setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPINTVL,
&tcp_keepintvl, sizeof (tcp_keepintvl));
if (status != 0)
sfree (array[i]);
sfree (array);
} /* }}} void strarray_free */
+
+#if HAVE_CAPABILITY
+int check_capability (int arg) /* {{{ */
+{
+ cap_value_t cap = (cap_value_t) arg;
+
+ if (!CAP_IS_SUPPORTED (cap))
+ return (-1);
+
+ int have_cap = cap_get_bound (cap);
+ if (have_cap != 1)
+ return (-1);
+
+ return (0);
+} /* }}} int check_capability */
+#else
+int check_capability (__attribute__((unused)) int arg) /* {{{ */
+{
+ WARNING ("check_capability: unsupported capability implementation. "
+ "Some plugin(s) may require elevated privileges to work properly.");
+ return (0);
+} /* }}} int check_capability */
+#endif /* HAVE_CAPABILITY */