[icinga-checkins] icinga.org: icinga-web/master: * Switch to www-user/www-group ( as specified in the test.properties file) using seteuid/setegid ( fixes #1109)

git at icinga.org git at icinga.org
Tue Jan 18 10:04:55 CET 2011


Module: icinga-web
Branch: master
Commit: 21d00132b7a4cfb4d5ddc902b6b5abcc413f8cf1
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=21d00132b7a4cfb4d5ddc902b6b5abcc413f8cf1

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Thu Jan 13 13:05:52 2011 +0100

* Switch to www-user/www-group (as specified in the test.properties file) using seteuid/setegid (fixes #1109)

---

 etc/tests/icingaWebTesting.php |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/etc/tests/icingaWebTesting.php b/etc/tests/icingaWebTesting.php
index 9e01fd2..52ebd5c 100755
--- a/etc/tests/icingaWebTesting.php
+++ b/etc/tests/icingaWebTesting.php
@@ -56,7 +56,30 @@ require(dirname(__FILE__).'/../../app/modules/AppKit/lib/class/AppKitSingleton.c
 require(dirname(__FILE__).'/../../app/modules/AppKit/lib/util/AppKitModuleUtil.class.php');
 
 AgaviConfig::set('core.default_context', $env);
-// Initialize the appkit framework
+
+// Set uid/gid to www-user/www-group settings from the test.properties config
+$test_config = parse_ini_file(AgaviConfig::get("core.root_dir")."/etc/tests/test.properties");
+if (function_exists('posix_seteuid') && posix_getuid() == 0) {
+	$group = posix_getgrnam($test_config['www-group']);
+
+	if ($group !== false) {
+		if (!posix_setegid($group['gid'])) {
+		    echo "posix_setegid() failed.\n";
+		    return;
+		}
+	}
+
+	$user = posix_getpwnam($test_config['www-user']);
+
+	if ($user !== false) {
+		if (!posix_seteuid($user['uid'])) {
+		    echo "posix_seteuid() failed.\n";
+		    return;
+		}
+	}
+}
+
+		    // Initialize the appkit framework
 PHPUnit_Util_Filter::addDirectoryToFilter(AgaviConfig::get('core.cache_dir'));
 AgaviController::initializeModule('Web');
 AgaviController::initializeModule('AppKit');
@@ -65,4 +88,4 @@ $ctx = AgaviContext::getInstance();
 $ctx->getDatabaseManager()->getDatabase()->connect();
 AgaviTesting::dispatch($arguments);
 
-?>
\ No newline at end of file
+?>





More information about the icinga-checkins mailing list