From d40319096f607083b4c3fb458e4e0a7e285f0141 Mon Sep 17 00:00:00 2001
From: vogelor <vogelor@ispconfig3>
Date: Wed, 09 Jun 2010 15:26:11 -0400
Subject: [PATCH] Fixed some errors in editing the webdav-user

---
 install/lib/installer_base.lib.php |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index c925f3c..eba6f5c 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -282,9 +282,11 @@
 			
 			$hosts[$from_host]['user'] = $conf['mysql']['master_ispconfig_user'];
 			$hosts[$from_host]['db'] = $conf['mysql']['master_database'];
+			$hosts[$from_host]['pwd'] = $conf['mysql']['master_ispconfig_password'];
 
 			$hosts[$from_ip]['user'] = $conf['mysql']['master_ispconfig_user'];
 			$hosts[$from_ip]['db'] = $conf['mysql']['master_database'];
+			$hosts[$from_ip]['pwd'] = $conf['mysql']['master_ispconfig_password'];
 		} else{
 			/*
 			 * it is NOT a master-slave - Setup so we have to find out all clients and their
@@ -298,18 +300,27 @@
 			foreach ($data as $item){
 				$hosts[$item['Host']]['user'] = $item['User'];
 				$hosts[$item['Host']]['db'] = $conf['mysql']['master_database'];
+				$hosts[$item['Host']]['pwd'] = ''; // the user already exists, so we need no pwd!
 			}
 		}
 		
 		if(is_array($hosts)) {
 		foreach($hosts as $host => $value) {
 			/*
-			 *  Delete ISPConfig user in the master database, in case that it exists
+			 * If a pwd exists, this means, we have to add the new user (and his pwd).
+			 * if not, the user already exists and we do not need the pwd
+			 */
+			if ($value['pwd'] != ''){
+				$query = "CREATE USER '".$value['user']."'@'".$host."' IDENTIFIED BY '" . $value['pwd'] . "'";
+				$this->dbmaster->query($query); // ignore the error
+			}
+
+			/*
+			 *  Try to delete all rights of the user in case that it exists.
+			 *  In Case that it will not exist, do nothing (ignore the error!)
 			 */
 			$query = "REVOKE ALL PRIVILEGES, GRANT OPTION FROM '".$value['user']."'@'".$host."' ";
-			if(!$this->dbmaster->query($query)) {
-				$this->error('Unable to remove rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
-			}
+			$this->dbmaster->query($query); // ignore the error
 
 			//* Create the ISPConfig database user in the remote database
 			$query = "GRANT SELECT ON ".$value['db'].".`server` TO '".$value['user']."'@'".$host."' ";
@@ -1402,7 +1413,7 @@
 
 		//* Add Log-Rotation
 		if (is_dir('/etc/logrotate.d')) {
-			unlink('/etc/logrotate.d/logispc3');
+			@unlink('/etc/logrotate.d/logispc3'); // ignore, if the file is not there
 			$fh = fopen('/etc/logrotate.d/logispc3', 'w');
 			fwrite($fh,
 					"/var/log/ispconfig/ispconfig.log { \n" .

--
Gitblit v1.9.1