]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Make daemons call setgid() *before* setuid() because doing it the other way around...
authorJoshua Judson Rosen <rozzin@geekspace.com>
Thu, 9 Aug 2012 03:17:51 +0000 (23:17 -0400)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 5 May 2014 11:33:06 +0000 (13:33 +0200)
lib/daemon.php

index 8873163a95e9f97f988a447080a65878a77d57fb..eaeecc10589531325cd2506fbd421300ad11a2f4 100644 (file)
@@ -124,19 +124,6 @@ class Daemon
 
     function changeUser()
     {
-        $username = common_config('daemon', 'user');
-
-        if ($username) {
-            $user_info = posix_getpwnam($username);
-            if (!$user_info) {
-                common_log(LOG_WARNING,
-                           'Ignoring unknown user for daemon: ' . $username);
-            } else {
-                common_log(LOG_INFO, "Setting user to " . $username);
-                posix_setuid($user_info['uid']);
-            }
-        }
-
         $groupname = common_config('daemon', 'group');
 
         if ($groupname) {
@@ -149,6 +136,19 @@ class Daemon
                 posix_setgid($group_info['gid']);
             }
         }
+
+        $username = common_config('daemon', 'user');
+
+        if ($username) {
+            $user_info = posix_getpwnam($username);
+            if (!$user_info) {
+                common_log(LOG_WARNING,
+                           'Ignoring unknown user for daemon: ' . $username);
+            } else {
+                common_log(LOG_INFO, "Setting user to " . $username);
+                posix_setuid($user_info['uid']);
+            }
+        }
     }
 
     function runOnce()