X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fexec.c;h=fc40d4a9eff65e1d1300e2160466e9e6d01402b9;hb=c76419c0cf983f1ecd3d36aa236cc4e3f9cff733;hp=e90f83c94ad4aa46169f6c827ee741ca9c5d9575;hpb=2761915bed8c6caea41018be3e675aa712cc0b0a;p=collectd.git diff --git a/src/exec.c b/src/exec.c index e90f83c9..fc40d4a9 100644 --- a/src/exec.c +++ b/src/exec.c @@ -39,6 +39,10 @@ #include #include +#ifdef HAVE_SYS_CAPABILITY_H +# include +#endif + #define PL_NORMAL 0x01 #define PL_NOTIF_ACTION 0x02 @@ -270,7 +274,7 @@ static void set_environment (void) /* {{{ */ CDTIME_T_TO_DOUBLE (plugin_get_interval ())); setenv ("COLLECTD_INTERVAL", buffer, /* overwrite = */ 1); - ssnprintf (buffer, sizeof (buffer), "%s", hostname_g); + sstrncpy (buffer, hostname_g, sizeof (buffer)); setenv ("COLLECTD_HOSTNAME", buffer, /* overwrite = */ 1); #else ssnprintf (buffer, sizeof (buffer), "COLLECTD_INTERVAL=%.3f", @@ -543,7 +547,7 @@ failed: static int parse_line (char *buffer) /* {{{ */ { if (strncasecmp ("PUTVAL", buffer, strlen ("PUTVAL")) == 0) - return (handle_putval (stdout, buffer)); + return (cmd_handle_putval (stdout, buffer)); else if (strncasecmp ("PUTNOTIF", buffer, strlen ("PUTNOTIF")) == 0) return (handle_putnotif (stdout, buffer)); else @@ -806,6 +810,22 @@ static int exec_init (void) /* {{{ */ sigaction (SIGCHLD, &sa, NULL); +#if defined(HAVE_SYS_CAPABILITY_H) && defined(CAP_SETUID) && defined(CAP_SETGID) + if ((check_capability (CAP_SETUID) != 0) || + (check_capability (CAP_SETGID) != 0)) + { + if (getuid () == 0) + WARNING ("exec plugin: Running collectd as root, but the CAP_SETUID " + "or CAP_SETGID capabilities are missing. The plugin's read function " + "will probably fail. Is your init system dropping capabilities?"); + else + WARNING ("exec plugin: collectd doesn't have the CAP_SETUID or " + "CAP_SETGID capabilities. If you don't want to run collectd as root, " + "try running \"setcap 'cap_setuid=ep cap_setgid=ep'\" on the " + "collectd binary."); + } +#endif + return (0); } /* int exec_init }}} */