]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/daemon.php
Merge commit 'refs/merge-requests/41' of https://gitorious.org/social/mainline into...
[quix0rs-gnu-social.git] / lib / daemon.php
index c09531c9d572e2c714a21d862e0635311e2afdb6..eaeecc10589531325cd2506fbd421300ad11a2f4 100644 (file)
@@ -48,12 +48,11 @@ class Daemon
 
     function background()
     {
-        /* Starting PHP 5.4 (dotdeb), maybe earlier for some version/distrib
+        /*
+         * This prefers to Starting PHP 5.4 (dotdeb), maybe earlier for some version/distrib
          * seems MySQL connection using mysqli driver get lost when fork.
          * Need to unset it so that child process recreate it.
          *
-         * Not needed if using mysql driver (but it's deprecated starting PHP 5.5)
-         *
          * @todo FIXME cleaner way to do it ?
          */
         global $_DB_DATAOBJECT;
@@ -125,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) {
@@ -150,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()