@cryptotaxi247 / netdata-1 / commits / 2588e2198

netdata sets the PATH for its plugins

Costa Tsaousis (ktsaou) committed Jul 15, 2016 at 15:31 UTC 2588e21989b40c13fe14a67074f35c62efab49c8
1 file changed +7
src/main.c
+7
@@ -444,6 +444,13 @@ int main(int argc, char **argv)
444 // http://stackoverflow.com/questions/4554271/how-to-avoid-excessive-stat-etc-localtime-calls-in-strftime-on-linux
445 setenv("TZ", ":/etc/localtime", 0);
446
447 + {
448 + char path[1024 + 1], *p = getenv("PATH");
449 + if(!p) p = "/bin:/usr/bin";
450 + snprintfz(path, 1024, "%s:%s", p, "/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin");
451 + setenv("PATH", config_get("plugins", "PATH environment variable", path), 1);
452 + }
453 +
454 // cd to /tmp to avoid any plugins writing files at random places
455 if(chdir("/tmp")) error("netdata: ERROR: Cannot cd to /tmp");
456