]> arthur.barton.de Git - netdata.git/blobdiff - src/daemon.c
added more fping alarms; added the ability to have alarms that never send CLEAR notif...
[netdata.git] / src / daemon.c
index fb57be141d6da1801650d7112a242c4ad4f73034..4fd8ca5e5984b1e32c14730bb3f7ca3e35644daf 100644 (file)
@@ -114,16 +114,23 @@ int become_user(const char *username, int pid_fd)
             error("Cannot set supplementary groups for user '%s'", username);
 
         freez(supplementary_groups);
-        supplementary_groups = NULL;
         ngroups = 0;
     }
 
+#ifdef __APPLE__
+    if(setregid(gid, gid) != 0) {
+#else
     if(setresgid(gid, gid, gid) != 0) {
+#endif /* __APPLE__ */
         error("Cannot switch to user's %s group (gid: %u).", username, gid);
         return -1;
     }
 
+#ifdef __APPLE__
+    if(setreuid(uid, uid) != 0) {
+#else
     if(setresuid(uid, uid, uid) != 0) {
+#endif /* __APPLE__ */
         error("Cannot switch to user %s (uid: %u).", username, uid);
         return -1;
     }
@@ -229,7 +236,7 @@ int become_daemon(int dont_fork, const char *user)
     }
 
     // Set new file permissions
-    umask(0002);
+    umask(0007);
 
     // adjust my Out-Of-Memory score
     oom_score_adj(1000);
@@ -251,10 +258,8 @@ int become_daemon(int dont_fork, const char *user)
         create_needed_dir(VARLIB_DIR, getuid(), getgid());
     }
 
-    if(pidfd != -1) {
+    if(pidfd != -1)
         close(pidfd);
-        pidfd = -1;
-    }
 
     return(0);
 }