From: Joshua Judson Rosen Date: Thu, 9 Aug 2012 03:17:51 +0000 (-0400) Subject: Make daemons call setgid() *before* setuid() because doing it the other way around... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f29d8e0d5a610359d35e9cf2cced41ab754cefe6;p=quix0rs-gnu-social.git Make daemons call setgid() *before* setuid() because doing it the other way around doesn't appear to work, at least on Linux. --- diff --git a/lib/daemon.php b/lib/daemon.php index 8873163a95..eaeecc1058 100644 --- a/lib/daemon.php +++ b/lib/daemon.php @@ -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()