[icinga-checkins] icinga.org: icinga-web/mhein/default: * Don' t use su when running the tests as an ordinary user (fixes #1115).

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


Module: icinga-web
Branch: mhein/default
Commit: e02b8921a4f2f3610aa991c0952f90887a13200a
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=e02b8921a4f2f3610aa991c0952f90887a13200a

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

* Don't use su when running the tests as an ordinary user (fixes #1115).

---

 etc/tests/tests/installation/userRightsTest.php |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/etc/tests/tests/installation/userRightsTest.php b/etc/tests/tests/installation/userRightsTest.php
index ff5de6b..71d6436 100644
--- a/etc/tests/tests/installation/userRightsTest.php
+++ b/etc/tests/tests/installation/userRightsTest.php
@@ -49,9 +49,16 @@ class userRightsTest extends AgaviPhpUnitTestCase {
 
 		if(!$wwwUser)
 			$this->markTestSkipped("No www-user specified in test.properties!");
+
 		foreach($cacheFolders as $folder) {
+			$command = "touch ".$folder."/testfile.txt";
+
+			if (!function_exists('posix_getuid') || posix_getuid() == 0) {
+				$command = "su ".$wwwUser." -c '".$command."'";
+			}
 			 
-			exec("su ".$wwwUser." -c 'touch ".$folder."/testfile.txt'");
+			exec($command);
+
 			if(!file_exists($folder."/testfile.txt")) {
 				error("Web user ".$wwwUser." couldn't write to cache ".$folder.
 					  "Please check that the either the user ".$wwwUser." or the group ".$wwwGroup." has ".
@@ -83,8 +90,15 @@ class userRightsTest extends AgaviPhpUnitTestCase {
 		
 		$wwwUser = $this->sharedFixture['www-user'];
 		$wwwGroup = $this->sharedFixture['www-group'];
+
+		$command = "touch ".$logDir."/testfile.txt";
+
+		if (!function_exists('posix_getuid') || posix_getuid() == 0) {
+			$command = "su ".$wwwUser." -c '".$command."'";
+		}
 		
-		exec("su ".$wwwUser." -c 'touch ".$logDir."/testfile.txt'");
+		exec($command);
+
 		if(!file_exists($logDir."/testfile.txt")) {
 			error("Web user ".$wwwUser." couldn't create logfile in ".$logDir.
 				  "Please check that the either the user ".$wwwUser." or the group ".$wwwGroup." has ".





More information about the icinga-checkins mailing list