From bcd725da57d20004a30e6934d5bc9669241461e4 Mon Sep 17 00:00:00 2001
From: Falko Timme <ft@falkotimme.com>
Date: Tue, 27 May 2014 13:08:59 -0400
Subject: [PATCH] - Implemented non-interactive install/update mode.

---
 install/lib/installer_base.lib.php |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index 7d6348b..2fc9e0b 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -750,8 +750,13 @@
 
 		if(!stristr($options, 'dont-create-certs')) {
 			//* Create the SSL certificate
-			$command = 'cd '.$config_dir.'; '
-				.'openssl req -new -outform PEM -out smtpd.cert -newkey rsa:4096 -nodes -keyout smtpd.key -keyform PEM -days 3650 -x509';
+			if(is_file('autoinstall.conf.php')){
+				$command = 'cd '.$config_dir.'; '
+					.'openssl req -new -subj \'/C=AU/ST=Some-State/O=Internet Widgits Pty Ltd\' -outform PEM -out smtpd.cert -newkey rsa:4096 -nodes -keyout smtpd.key -keyform PEM -days 3650 -x509';
+			} else {
+				$command = 'cd '.$config_dir.'; '
+					.'openssl req -new -outform PEM -out smtpd.cert -newkey rsa:4096 -nodes -keyout smtpd.key -keyform PEM -days 3650 -x509';
+			}
 			exec($command);
 
 			$command = 'chmod o= '.$config_dir.'/smtpd.key';
@@ -1683,7 +1688,11 @@
 
 		$ssl_pw = substr(md5(mt_rand()), 0, 6);
 		exec("openssl genrsa -des3 -passout pass:$ssl_pw -out $ssl_key_file 4096");
-		exec("openssl req -new -passin pass:$ssl_pw -passout pass:$ssl_pw -key $ssl_key_file -out $ssl_csr_file");
+		if(is_file('autoinstall.conf.php')){
+			exec("openssl req -new -passin pass:$ssl_pw -passout pass:$ssl_pw -subj '/C=AU/ST=Some-State/O=Internet Widgits Pty Ltd' -key $ssl_key_file -out $ssl_csr_file");
+		} else {
+			exec("openssl req -new -passin pass:$ssl_pw -passout pass:$ssl_pw -key $ssl_key_file -out $ssl_csr_file");
+		}
 		exec("openssl req -x509 -passin pass:$ssl_pw -passout pass:$ssl_pw -key $ssl_key_file -in $ssl_csr_file -out $ssl_crt_file -days 3650");
 		exec("openssl rsa -passin pass:$ssl_pw -in $ssl_key_file -out $ssl_key_file.insecure");
 		rename($ssl_key_file, $ssl_key_file.'.secure');

--
Gitblit v1.9.1