From abc27e6b42aedbf9cbe5c179ff2be51ff46b6f17 Mon Sep 17 00:00:00 2001 From: Tim Wagner Date: Fri, 8 May 2015 14:37:33 +0200 Subject: [PATCH] Change order of switching user/group to group/user because of necessary permissions --- src/AppserverIo/Appserver/Core/Server.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/AppserverIo/Appserver/Core/Server.php b/src/AppserverIo/Appserver/Core/Server.php index 7608f183a..eccf20ce2 100644 --- a/src/AppserverIo/Appserver/Core/Server.php +++ b/src/AppserverIo/Appserver/Core/Server.php @@ -597,18 +597,21 @@ protected function switchProcessUser() } } - // As we should only change user and group AFTER we made all chown and chgrp changes we will do it here - // after collecting if we are able to - if ($userChangeable) { + // As we should only change user and group AFTER we made all chown and chgrp + // changes we will do it here after collecting if we are able to. - // change the user ID - posix_setuid($userId); - } + // ATTENTION: We first need to change the group, because we need to be root + // to do that. After that we can change the user also!!!!!!!!!!! if ($groupChangeable) { // change the group ID posix_setgid($groupId); } + if ($userChangeable) { + + // change the user ID + posix_setuid($userId); + } // log a message with the time needed for restart $this->getSystemLogger()->info(