From 03200f17fb330b13f2ca9a13057fb97c672cdf1d Mon Sep 17 00:00:00 2001
From: Florian Schaal <florian@schaal-24.de>
Date: Sun, 24 Nov 2013 13:57:13 +0100
Subject: [PATCH] add amavis-configfile-location for centos 6.4; add
 amavis-initscrip-name for centos 6.4; fixed missing private_key in
 mail/mail_domain_dkim_create.php

---
 .../web/mail/mail_domain_dkim_create.php      |  2 +-
 .../mail_plugin_dkim.inc.php                  | 20 ++++++++++++++-----
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/interface/web/mail/mail_domain_dkim_create.php b/interface/web/mail/mail_domain_dkim_create.php
index 24198a3684..2a486a7db7 100644
--- a/interface/web/mail/mail_domain_dkim_create.php
+++ b/interface/web/mail/mail_domain_dkim_create.php
@@ -95,7 +95,7 @@ switch ($_POST['action']) {
 		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);
 		unlink("/usr/local/ispconfig/server/temp/random-data.bin");
-		$private_key='';
+		foreach($privkey as $values) $private_key=$private_key.$values."\n";
 	break;
 
 	case 'show': /* show the DNS-Record onLoad */
diff --git a/server/plugins-available/mail_plugin_dkim.inc.php b/server/plugins-available/mail_plugin_dkim.inc.php
index 1d5e521694..325dc0b1f1 100644
--- a/server/plugins-available/mail_plugin_dkim.inc.php
+++ b/server/plugins-available/mail_plugin_dkim.inc.php
@@ -77,7 +77,8 @@ class mail_plugin_dkim {
 		$pos_config=array(
 			'/etc/amavisd.conf',
 			'/etc/amavisd.conf/50-user',
-			'/etc/amavis/conf.d/50-user'
+			'/etc/amavis/conf.d/50-user',
+			'/etc/amavisd/amavisd.conf'
 		);
 		$amavis_configfile='';
 		foreach($pos_config as $conf) {
@@ -123,13 +124,22 @@ class mail_plugin_dkim {
 	 */
 	function restart_amavis() {
 		global $app, $conf;
-		$initfile=$conf['init_scripts'].'/amavis';
-		$app->log('Restarting amavis.', LOGLEVEL_DEBUG);
-		exec(escapeshellarg($conf['init_scripts']).escapeshellarg('/amavis').' restart', $output);
+		$pos_init=array(
+			$conf['init_scripts'].'/amavis',
+			$conf['init_scripts'].'/amavisd'
+		);
+		$initfile='';
+		foreach($pos_init as $init) {
+			if (is_executable($init)) {
+				$initfile=$init;
+				break;
+				}
+		}
+		$app->log('Restarting amavis: '.$initfile.'.', LOGLEVEL_DEBUG);
+		exec(escapeshellarg($initfile).' restart', $output);
 		foreach($output as $logline) $app->log($logline, LOGLEVEL_DEBUG);
 	}
 
-
 	/**
 	 * This function writes the keyfiles (public and private)
 	 * @param string $key_file full path to the key-file
-- 
GitLab