]> arthur.barton.de Git - netdata.git/blobdiff - src/main.c
added compile option NETDATA_VERIFY_LOCKS to enable the locks
[netdata.git] / src / main.c
index 8c157efa38f37f8be81fc52022fee8d3410ed967..20722a58f0cd60d8362de62499c9420f589ad2cd 100644 (file)
@@ -230,6 +230,7 @@ struct option_def options[] = {
     { 't', "The internal clock of netdata.",              "seconds",     "1"},
     { 'u', "Run as user.",                                "username",    "netdata"},
     { 'v', "Print netdata version and exit.",             NULL,          NULL},
+    { 'V', "Print netdata version and exit.",             NULL,          NULL},
     { 'W', "See Advanced options below.",                 "options",     NULL},
 };
 
@@ -378,7 +379,7 @@ static void backwards_compatible_config() {
     config_move(CONFIG_SECTION_GLOBAL, "default port",
                 CONFIG_SECTION_WEB,    "default port");
 
-    config_move(CONFIG_SECTION_GLOBAL, "disconnect idle clients after seconds",
+    config_move(CONFIG_SECTION_GLOBAL, "disconnect idle web clients after seconds",
                 CONFIG_SECTION_WEB,    "disconnect idle clients after seconds");
 
     config_move(CONFIG_SECTION_GLOBAL, "respect web browser do not track policy",
@@ -513,6 +514,9 @@ void set_global_environment() {
 
     // disable buffering for python plugins
     setenv("PYTHONUNBUFFERED", "1", 1);
+
+    // switch to standard locale for plugins
+    setenv("LC_ALL", "C", 1);
 }
 
 int main(int argc, char **argv) {
@@ -611,6 +615,7 @@ int main(int argc, char **argv) {
                     config_set(CONFIG_SECTION_GLOBAL, "run as user", optarg);
                     break;
                 case 'v':
+                case 'V':
                     printf("%s %s\n", program_name, program_version);
                     return 0;
                 case 'W':
@@ -851,7 +856,13 @@ int main(int argc, char **argv) {
         // get the user we should run
 
         // IMPORTANT: this is required before web_files_uid()
-        user = config_get(CONFIG_SECTION_GLOBAL, "run as user"    , (getuid() == 0)?NETDATA_USER:"");
+        if(getuid() == 0) {
+            user = config_get(CONFIG_SECTION_GLOBAL, "run as user", NETDATA_USER);
+        }
+        else {
+            struct passwd *passwd = getpwuid(getuid());
+            user = config_get(CONFIG_SECTION_GLOBAL, "run as user", (passwd && passwd->pw_name)?passwd->pw_name:"");
+        }
 
         // IMPORTANT: these have to run once, while single threaded
         web_files_uid(); // IMPORTANT: web_files_uid() before web_files_gid()