From f78f1e5d4e837b658b535d90c28c3a55df8e8a91 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Thu, 09 Oct 2014 12:22:36 -0400
Subject: [PATCH] - certificate bundle is deprecated since apache 2.4.8

---
 install/dist/lib/opensuse.lib.php |  155 ++++++++++++++++-----------------------------------
 1 files changed, 48 insertions(+), 107 deletions(-)

diff --git a/install/dist/lib/opensuse.lib.php b/install/dist/lib/opensuse.lib.php
index c66d888..1144776 100644
--- a/install/dist/lib/opensuse.lib.php
+++ b/install/dist/lib/opensuse.lib.php
@@ -29,7 +29,23 @@
 */
 
 class installer_dist extends installer_base {
-
+	
+	public function __construct() {
+		//** check apache modules */
+		$mods = getapachemodules();
+		if(in_array('authz_compat', $mods, true)) {
+			swriteln($inst->lng('    WARNING! You are using mod_authz_compat.'));
+			swriteln($inst->lng('    Please make sure that your apache config uses the new auth syntax:'));
+			swriteln($inst->lng('    <Directory />'));
+			swriteln($inst->lng('    Options None'));
+			swriteln($inst->lng('    AllowOverride None'));
+			swriteln($inst->lng('    Require all denied'));
+			swriteln($inst->lng('    </Directory>'."\n"));
+			
+			swriteln($inst->lng('    If it uses the old syntax (deny from all) ISPConfig would fail to work.'));
+		}
+	}
+	
 	public function configure_mailman($status = 'insert') {
 		global $conf;
 
@@ -440,7 +456,6 @@
 			'virtual_transport = lmtp:unix:private/dovecot-lmtp',
 			'smtpd_sasl_type = dovecot',
 			'smtpd_sasl_path = private/auth',
-			'receive_override_options = no_address_mappings'
 		);
 
 		// Make a backup copy of the main.cf file
@@ -498,7 +513,7 @@
 		exec("chown root:root $config_dir/$configfile");
 		
 		// Dovecot shall ignore mounts in website directory
-		exec("doveadm mount add '/srv/www/*' ignore");
+		if(is_installed('doveadm')) exec("doveadm mount add '/srv/www/*' ignore > /dev/null 2> /dev/null");
 
 	}
 
@@ -685,10 +700,12 @@
 		$vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
 		$vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
 
-		//copy('tpl/apache_ispconfig.conf.master',$vhost_conf_dir.'/ispconfig.conf');
-		$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig.conf.master', 'tpl/apache_ispconfig.conf.master');
+		$tpl = new tpl('apache_ispconfig.conf.master');
+		$tpl->setVar('apache_version',getapacheversion());
+		
 		$records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'");
-
+		$ip_addresses = array();
+		
 		if(is_array($records) && count($records) > 0) {
 			foreach($records as $rec) {
 				if($rec['ip_type'] == 'IPv6') {
@@ -701,15 +718,17 @@
 					foreach($ports as $port) {
 						$port = intval($port);
 						if($port > 0 && $port < 65536 && $ip_address != '') {
-							$content .= 'NameVirtualHost '.$ip_address.":".$port."\n";
+							$ip_addresses[] = array('ip_address' => $ip_address, 'port' => $port);
 						}
 					}
 				}
 			}
 		}
-
-		$content .= "\n";
-		wf($vhost_conf_dir.'/ispconfig.conf', $content);
+		
+		if(count($ip_addresses) > 0) $tpl->setLoop('ip_adresses',$ip_addresses);
+		
+		wf($vhost_conf_dir.'/ispconfig.conf', $tpl->grab());
+		unset($tpl);
 
 		if(!@is_link($vhost_conf_enabled_dir."/000-ispconfig.conf")) {
 			exec("ln -s ".$vhost_conf_dir."/ispconfig.conf ".$vhost_conf_enabled_dir."/000-ispconfig.conf");
@@ -1099,6 +1118,9 @@
 				$command = 'usermod -a -G ispapps '.$conf['nginx']['user'];
 				caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 			}
+			// add nobody user to www group, as the default php-fpm pool from opensuse runs as nobody
+			$command = 'usermod -a -G www nobody';
+			caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 		}
 
 		//* Make the shell scripts executable
@@ -1114,31 +1136,32 @@
 
 
 			// Dont just copy over the virtualhost template but add some custom settings
-
-			$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig.vhost.master', "tpl/apache_ispconfig.vhost.master");
-			$content = str_replace('{vhost_port}', $conf['apache']['vhost_port'], $content);
+			$tpl = new tpl('apache_ispconfig.vhost.master');
+			$tpl->setVar('vhost_port',$conf['apache']['vhost_port']);
 
 			// comment out the listen directive if port is 80 or 443
 			if($conf['apache']['vhost_port'] == 80 or $conf['apache']['vhost_port'] == 443) {
-				$content = str_replace('{vhost_port_listen}', '#', $content);
+				$tpl->setVar('vhost_port_listen','#');
 			} else {
-				$content = str_replace('{vhost_port_listen}', '', $content);
+				$tpl->setVar('vhost_port_listen','');
 			}
 
-			if(is_file('/usr/local/ispconfig/interface/ssl/ispserver.crt') && is_file('/usr/local/ispconfig/interface/ssl/ispserver.key')) {
-				$content = str_replace('{ssl_comment}', '', $content);
+			if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) {
+				$tpl->setVar('ssl_comment','');
 			} else {
-				$content = str_replace('{ssl_comment}', '#', $content);
+				$tpl->setVar('ssl_comment','#');
 			}
 			if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key') && is_file($install_dir.'/interface/ssl/ispserver.bundle')) {
-				$content = str_replace('{ssl_bundle_comment}', '', $content);
+				$tpl->setVar('ssl_bundle_comment','');
 			} else {
-				$content = str_replace('{ssl_bundle_comment}', '#', $content);
+				$tpl->setVar('ssl_bundle_comment','#');
 			}
+			
+			$tpl->setVar('apache_version',getapacheversion());
 
+			$content = $tpl->grab();
 			$content = str_replace('/var/www/', '/srv/www/', $content);
-
-			wf("$vhost_conf_dir/ispconfig.vhost", $content);
+			wf($vhost_conf_dir.'/ispconfig.vhost', $content);
 
 			//if(!is_file('/srv/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) {
 			$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig_fcgi_starter.master', 'tpl/apache_ispconfig_fcgi_starter.master');
@@ -1275,93 +1298,11 @@
 
 		//* Remove Domain module as its functions are available in the client module now
 		if(@is_dir('/usr/local/ispconfig/interface/web/domain')) exec('rm -rf /usr/local/ispconfig/interface/web/domain');
+		
+		// Add symlink for patch tool
+		if(!is_link('/usr/local/bin/ispconfig_patch')) exec('ln -s /usr/local/ispconfig/server/scripts/ispconfig_patch /usr/local/bin/ispconfig_patch');
 
 
-	}
-
-	public function configure_dbserver()
-	{
-		global $conf;
-
-		//* If this server shall act as database server for client DB's, we configure this here
-		$install_dir = $conf['ispconfig_install_dir'];
-
-		// Create a file with the database login details which
-		// are used to create the client databases.
-
-		if(!is_dir("$install_dir/server/lib")) {
-			$command = "mkdir $install_dir/server/lib";
-			caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
-		}
-
-		$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/mysql_clientdb.conf.master', "tpl/mysql_clientdb.conf.master");
-		$content = str_replace('{hostname}', $conf['mysql']['host'], $content);
-		$content = str_replace('{username}', $conf['mysql']['admin_user'], $content);
-		$content = str_replace('{password}', $conf['mysql']['admin_password'], $content);
-		wf("$install_dir/server/lib/mysql_clientdb.conf", $content);
-		exec('chmod 600 '."$install_dir/server/lib/mysql_clientdb.conf");
-		exec('chown root:root '."$install_dir/server/lib/mysql_clientdb.conf");
-
-	}
-
-	public function install_crontab()
-	{
-		global $conf;
-
-		//* Root Crontab
-		exec('crontab -u root -l > crontab.txt');
-		$existing_root_cron_jobs = file('crontab.txt');
-
-		// remove existing ispconfig cronjobs, in case the syntax has changed
-		foreach($existing_root_cron_jobs as $key => $val) {
-			if(stristr($val, '/usr/local/ispconfig')) unset($existing_root_cron_jobs[$key]);
-		}
-
-		$root_cron_jobs = array(
-			'* * * * * /usr/local/ispconfig/server/server.sh &> /dev/null',
-			'30 00 * * * /usr/local/ispconfig/server/cron_daily.sh &> /dev/null'
-		);
-
-		if ($conf['nginx']['installed'] == true) {
-			$root_cron_jobs[] = "0 0 * * * /usr/local/ispconfig/server/scripts/create_daily_nginx_access_logs.sh &> /dev/null";
-		}
-
-		foreach($root_cron_jobs as $cron_job) {
-			if(!in_array($cron_job."\n", $existing_root_cron_jobs)) {
-				$existing_root_cron_jobs[] = $cron_job."\n";
-			}
-		}
-		file_put_contents('crontab.txt', $existing_root_cron_jobs);
-		exec('crontab -u root crontab.txt &> /dev/null');
-		unlink('crontab.txt');
-
-		//* Getmail crontab
-		if(is_user('getmail')) {
-			$cf = $conf['getmail'];
-			exec('crontab -u getmail -l > crontab.txt');
-			$existing_cron_jobs = file('crontab.txt');
-
-			$cron_jobs = array(
-				'*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> /dev/null'
-			);
-
-			// remove existing ispconfig cronjobs, in case the syntax has changed
-			foreach($existing_cron_jobs as $key => $val) {
-				if(stristr($val, 'getmail')) unset($existing_cron_jobs[$key]);
-			}
-
-			foreach($cron_jobs as $cron_job) {
-				if(!in_array($cron_job."\n", $existing_cron_jobs)) {
-					$existing_cron_jobs[] = $cron_job."\n";
-				}
-			}
-			file_put_contents('crontab.txt', $existing_cron_jobs);
-			exec('crontab -u getmail crontab.txt &> /dev/null');
-			unlink('crontab.txt');
-		}
-
-		exec('touch /var/log/ispconfig/cron.log');
-		exec('chmod 660 /var/log/ispconfig/cron.log');
 	}
 
 }

--
Gitblit v1.9.1