[Fusionforge-commits] FusionForge branch Branch_5_3 updated. 5a3f1dfd8776fb5ae61c984e6917c105e1ee39ca

Franck VILLAUME nerville at fusionforge.org
Fri Feb 21 17:11:11 CET 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, Branch_5_3 has been updated
       via  5a3f1dfd8776fb5ae61c984e6917c105e1ee39ca (commit)
      from  b64f36d9da9c7055150f9f6e67c9d5acf9a730fc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5a3f1dfd8776fb5ae61c984e6917c105e1ee39ca
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Fri Feb 21 17:10:19 2014 +0100

    util_sudo_effective_user: posix_seteuid does not work as expected on every distribution. debian bash has been patched to work. reimplement the function using pcntl functions

diff --git a/src/common/include/utils.php b/src/common/include/utils.php
index f5c4259..233222b 100644
--- a/src/common/include/utils.php
+++ b/src/common/include/utils.php
@@ -1771,23 +1771,27 @@ function util_mkdtemp($suffix = '', $prefix = 'tmp') {
  * @return	boolean	true on success, false on error
  */
 function util_sudo_effective_user($username, $function, $params=array()) {
-	$saved_egid = posix_getegid();
-	$saved_euid = posix_geteuid();
-
 	$userinfo = posix_getpwnam($username);
 	if ($userinfo === false) {
 		return false;
 	}
-	if (posix_setegid($userinfo['gid']) &&
-	    ($saved_euid != 0 || posix_initgroups($username, $userinfo['gid'])) &&
-	    posix_seteuid($userinfo['uid'])) {
-		$function($params);
-	}
 
-	posix_setegid($saved_egid);
-	posix_seteuid($saved_euid);
-	if ($saved_euid == 0)
-		posix_initgroups("root", 0);
+	$pid = pcntl_fork();
+	if ( $pid == -1 ) {
+		// Fork failed
+		exit(1);
+	} else if ($pid) {
+		pcntl_waitpid($pid, $status);
+	} else {
+		if (posix_setgid($userinfo['gid']) &&
+			posix_initgroups($username, $userinfo['gid']) &&
+			posix_setuid($userinfo['uid'])) {
+			putenv('HOME='.$userinfo['dir']);
+			$function($params);
+		}
+		//exit(1); // too nice, PHP gracefully quits and closes DB connection
+		posix_kill(posix_getpid(), 9);
+	}
 	return true;
 }
 

-----------------------------------------------------------------------

Summary of changes:
 src/common/include/utils.php |   28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list