From 587fe4ed3539ea05126c8dc7bac27bcf2cab8302 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Mon, 11 Aug 2014 06:35:45 -0400
Subject: [PATCH] Merge branch 'master' of git.ispconfig.org:ispconfig/ispconfig3

---
 interface/lib/classes/tools_sites.inc.php         |    6 +-
 interface/web/sites/webdav_user_edit.php          |    6 ++
 server/plugins-available/mail_plugin_dkim.inc.php |   18 ++++++++-
 interface/web/sites/shell_user_edit.php           |    6 ++
 interface/web/sites/database_user_edit.php        |    7 ++-
 docs/Remote_API_docs.txt                          |    2 
 interface/web/sites/database_edit.php             |    6 ++
 interface/web/sites/ftp_user_edit.php             |    6 ++
 interface/web/mail/mail_domain_dkim_create.php    |    6 +-
 9 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/docs/Remote_API_docs.txt b/docs/Remote_API_docs.txt
index a11c78d..6f1c4fd 100644
--- a/docs/Remote_API_docs.txt
+++ b/docs/Remote_API_docs.txt
@@ -1,3 +1,3 @@
 
 
-The remote API documentation is in the remote_client/API-docs subfolder.
\ No newline at end of file
+The remote API documentation is in the remoting_client/API-docs subfolder.
diff --git a/interface/lib/classes/tools_sites.inc.php b/interface/lib/classes/tools_sites.inc.php
index 0fd5963..3400c5b 100644
--- a/interface/lib/classes/tools_sites.inc.php
+++ b/interface/lib/classes/tools_sites.inc.php
@@ -47,7 +47,7 @@
 					$name=str_replace('['.$keyword.']', $this->getClientID($dataRecord), $name);
 					break;
 				case 'DOMAINID':
-					$name=str_replace('['.$keyword.']', $dataRecord['parent_domain_id'], $name);
+					$name=str_replace('['.$keyword.']', $dataRecord['parent_domain_id'] ? $dataRecord['parent_domain_id'] : '[DOMAINID]', $name);
 					break;
 				}
 			}
@@ -92,7 +92,7 @@
 			} elseif(isset($dataRecord['sys_groupid'])) {
 				$client_group_id = $dataRecord['sys_groupid'];
 			} else {
-				$client_group_id = 0;
+				return '[CLIENTNAME]';
 			}
 		}
 
@@ -119,7 +119,7 @@
 			} elseif(isset($dataRecord['sys_groupid'])) {
 				$client_group_id = $dataRecord['sys_groupid'];
 			} else {
-				$client_group_id = 0;
+				return '[CLIENTID]';
 			}
 		}
 		$tmp = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE groupid = " . $app->functions->intval($client_group_id));
diff --git a/interface/web/mail/mail_domain_dkim_create.php b/interface/web/mail/mail_domain_dkim_create.php
index 2a486a7..0f636b1 100644
--- a/interface/web/mail/mail_domain_dkim_create.php
+++ b/interface/web/mail/mail_domain_dkim_create.php
@@ -80,7 +80,7 @@
 	require_once('../../lib/classes/validate_dkim.inc.php');
 	$validate_dkim=new validate_dkim ();
 	if($validate_dkim->validate_post('private',$private_key)) { /* validate the $_POST-value */
-		exec('echo '.escapeshellarg($private_key).'|openssl rsa -pubout -outform PEM',$pubkey,$result);
+		exec('echo '.escapeshellarg($private_key).'|openssl rsa -pubout -outform PEM 2> /dev/null',$pubkey,$result);
 		$public_key=pub_key($pubkey);
 	} else {
 		$public_key='invalid key';
@@ -92,8 +92,8 @@
 
 switch ($_POST['action']) {
 	case 'create': /* create DKIM Private-key */
-		exec('openssl rand -out /usr/local/ispconfig/server/temp/random-data.bin 4096', $output, $result);
-		exec('openssl genrsa -rand /usr/local/ispconfig/server/temp/random-data.bin 1024', $privkey, $result);
+		exec('openssl rand -out /usr/local/ispconfig/server/temp/random-data.bin 4096 2> /dev/null', $output, $result);
+		exec('openssl genrsa -rand /usr/local/ispconfig/server/temp/random-data.bin 1024 2> /dev/null', $privkey, $result);
 		unlink("/usr/local/ispconfig/server/temp/random-data.bin");
 		foreach($privkey as $values) $private_key=$private_key.$values."\n";
 	break;
diff --git a/interface/web/sites/database_edit.php b/interface/web/sites/database_edit.php
index c392c79..22b631a 100644
--- a/interface/web/sites/database_edit.php
+++ b/interface/web/sites/database_edit.php
@@ -146,7 +146,11 @@
 			$app->tpl->setVar("database_name", $app->tools_sites->removePrefix($this->dataRecord['database_name'], $this->dataRecord['database_name_prefix'], $dbname_prefix));
 		}
 
-		$app->tpl->setVar("database_name_prefix", $app->tools_sites->getPrefix($this->dataRecord['database_name_prefix'], $dbname_prefix, $global_config['dbname_prefix']));
+		if($this->dataRecord['database_name'] == "") {
+			$app->tpl->setVar("database_name_prefix", $dbname_prefix);
+		} else {
+			$app->tpl->setVar("database_name_prefix", $app->tools_sites->getPrefix($this->dataRecord['database_name_prefix'], $dbname_prefix, $global_config['dbname_prefix']));
+		}
 
 		if($this->id > 0) {
 			//* we are editing a existing record
diff --git a/interface/web/sites/database_user_edit.php b/interface/web/sites/database_user_edit.php
index 75422ca..18b46b9 100644
--- a/interface/web/sites/database_user_edit.php
+++ b/interface/web/sites/database_user_edit.php
@@ -103,8 +103,11 @@
 			$app->tpl->setVar("database_user", $app->tools_sites->removePrefix($this->dataRecord['database_user'], $this->dataRecord['database_user_prefix'], $dbuser_prefix));
 		}
 
-
-		$app->tpl->setVar("database_user_prefix", $app->tools_sites->getPrefix($this->dataRecord['database_user_prefix'], $dbuser_prefix, $global_config['dbuser_prefix']));
+		if($this->dataRecord['database_user'] == "") {
+			$app->tpl->setVar("database_user_prefix", $dbuser_prefix);
+		} else {
+			$app->tpl->setVar("database_user_prefix", $app->tools_sites->getPrefix($this->dataRecord['database_user_prefix'], $dbuser_prefix, $global_config['dbuser_prefix']));
+		}
 
 		parent::onShowEnd();
 	}
diff --git a/interface/web/sites/ftp_user_edit.php b/interface/web/sites/ftp_user_edit.php
index 0346201..e4dec4a 100644
--- a/interface/web/sites/ftp_user_edit.php
+++ b/interface/web/sites/ftp_user_edit.php
@@ -82,7 +82,11 @@
 			$app->tpl->setVar("username", $app->tools_sites->removePrefix($this->dataRecord['username'], $this->dataRecord['username_prefix'], $ftpuser_prefix));
 		}
 
-		$app->tpl->setVar("username_prefix", $app->tools_sites->getPrefix($this->dataRecord['username_prefix'], $ftpuser_prefix, $global_config['ftpuser_prefix']));
+		if($this->dataRecord['username'] == "") {
+			$app->tpl->setVar("username_prefix", $ftpuser_prefix);
+		} else {
+			$app->tpl->setVar("username_prefix", $app->tools_sites->getPrefix($this->dataRecord['username_prefix'], $ftpuser_prefix, $global_config['ftpuser_prefix']));
+		}
 
 		parent::onShowEnd();
 	}
diff --git a/interface/web/sites/shell_user_edit.php b/interface/web/sites/shell_user_edit.php
index 3c72a5f..f0c8c36 100644
--- a/interface/web/sites/shell_user_edit.php
+++ b/interface/web/sites/shell_user_edit.php
@@ -82,7 +82,11 @@
 			$app->tpl->setVar("username", $app->tools_sites->removePrefix($this->dataRecord['username'], $this->dataRecord['username_prefix'], $shelluser_prefix));
 		}
 
-		$app->tpl->setVar("username_prefix", $app->tools_sites->getPrefix($this->dataRecord['username_prefix'], $shelluser_prefix, $global_config['shelluser_prefix']));
+		if($this->dataRecord['username'] == "") {
+			$app->tpl->setVar("username_prefix", $shelluser_prefix);
+		} else {
+			$app->tpl->setVar("username_prefix", $app->tools_sites->getPrefix($this->dataRecord['username_prefix'], $shelluser_prefix, $global_config['shelluser_prefix']));
+		}
 
 		if($this->id > 0) {
 			//* we are editing a existing record
diff --git a/interface/web/sites/webdav_user_edit.php b/interface/web/sites/webdav_user_edit.php
index 56b019c..fcea99e 100644
--- a/interface/web/sites/webdav_user_edit.php
+++ b/interface/web/sites/webdav_user_edit.php
@@ -81,7 +81,11 @@
 			$app->tpl->setVar("username", $app->tools_sites->removePrefix($this->dataRecord['username'], $this->dataRecord['username_prefix'], $webdavuser_prefix));
 		}
 
-		$app->tpl->setVar("username_prefix", $app->tools_sites->getPrefix($this->dataRecord['username_prefix'], $webdavuser_prefix, $global_config['webdavuser_prefix']));
+		if($this->dataRecord['username'] == "") {
+			$app->tpl->setVar("username_prefix", $webdavuser_prefix);
+		} else {
+			$app->tpl->setVar("username_prefix", $app->tools_sites->getPrefix($this->dataRecord['username_prefix'], $webdavuser_prefix, $global_config['webdavuser_prefix']));
+		}
 
 		if($this->id > 0) {
 			//* we are editing a existing record
diff --git a/server/plugins-available/mail_plugin_dkim.inc.php b/server/plugins-available/mail_plugin_dkim.inc.php
index 268c9c5..a74c4b8 100644
--- a/server/plugins-available/mail_plugin_dkim.inc.php
+++ b/server/plugins-available/mail_plugin_dkim.inc.php
@@ -123,7 +123,21 @@
 
             if (!is_dir($mail_config['dkim_path'])) {
                 $app->log('DKIM Path '.$mail_config['dkim_path'].' not found - (re)created.', LOGLEVEL_DEBUG);
-                mkdir($mail_config['dkim_path'], 0750, true);
+				if($app->system->is_user('amavis')) { 
+					$amavis_user='amavis'; 
+				} elseif ($app->system->is_user('vscan')) { 
+					$amavis_user='vscan'; 
+				}
+				else { 
+					$amavis_user=''; 
+				}
+				if(!empty($amavis_user)) {
+					mkdir($mail_config['dkim_path'], 0750, true);
+					exec('chown '.$amavis_user.' /var/lib/amavis/dkim');
+					unset($amavis_user);
+				} else {
+					mkdir($mail_config['dkim_path'], 0755, true);
+				}
             }
 
 			if (!is_writeable($mail_config['dkim_path'])) {
@@ -173,7 +187,7 @@
 			$app->log('Saved DKIM Private-key to '.$key_file.'.private', LOGLEVEL_DEBUG);
 			$success=true;
 			/* now we get the DKIM Public-key */
-			exec('cat '.escapeshellarg($key_file.'.private').'|openssl rsa -pubout', $pubkey, $result);
+			exec('cat '.escapeshellarg($key_file.'.private').'|openssl rsa -pubout 2> /dev/null', $pubkey, $result);
 			$public_key='';
 			foreach($pubkey as $values) $public_key=$public_key.$values."\n";
 			/* save the DKIM Public-key in dkim-dir */

--
Gitblit v1.9.1