From dae3b41faee2777046b0b612e2bd8b28caf0f189 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Thu, 19 Jul 2012 04:07:53 -0400
Subject: [PATCH] Fixed a warning in cron log on non web servers.

---
 install/lib/installer_base.lib.php |   64 ++++++++++++++++++++++----------
 1 files changed, 44 insertions(+), 20 deletions(-)

diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index bb88780..16b64c3 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -470,6 +470,15 @@
 			if(!$this->dbmaster->query($query)) {
 				$this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
 			}
+			
+			$query = "GRANT SELECT, UPDATE ON ".$value['db'].".`aps_instances` TO '".$value['user']."'@'".$host."' ";
+			if ($verbose){
+				echo $query ."\n";
+			}
+			if(!$this->dbmaster->query($query)) {
+				$this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
+			}
+			
 		}
 
 		/*
@@ -655,6 +664,7 @@
 				'virtual_mailbox_base = '.$cf['vmail_mailbox_base'],
 				'virtual_uid_maps = static:'.$cf['vmail_userid'],
 				'virtual_gid_maps = static:'.$cf['vmail_groupid'],
+				'inet_protocols=all',
 				'smtpd_sasl_auth_enable = yes',
 				'broken_sasl_auth_clients = yes',
 				'smtpd_sasl_authenticated_header = yes',
@@ -765,9 +775,22 @@
 
 	public function configure_saslauthd() {
 		global $conf;
+		
+		//* Get saslsauthd version
+		exec('saslauthd -v 2>&1',$out);
+		$parts = explode(' ',$out[0]);
+		$saslversion = $parts[1];
+		unset($parts);
+		unset($out);
 
-
-		$configfile = 'sasl_smtpd.conf';
+		if(version_compare($saslversion , '2.1.23') > 0) {
+			//* Configfile for saslauthd versions 2.1.24 and newer
+			$configfile = 'sasl_smtpd2.conf';
+		} else {
+			//* Configfile for saslauthd versions up to 2.1.23
+			$configfile = 'sasl_smtpd.conf';
+		}
+		
 		if(is_file($conf['postfix']['config_dir'].'/sasl/smtpd.conf')) copy($conf['postfix']['config_dir'].'/sasl/smtpd.conf',$conf['postfix']['config_dir'].'/sasl/smtpd.conf~');
 		if(is_file($conf['postfix']['config_dir'].'/sasl/smtpd.conf~')) chmod($conf['postfix']['config_dir'].'/sasl/smtpd.conf~', 0400);
 		$content = rf('tpl/'.$configfile.'.master');
@@ -1407,7 +1430,7 @@
 			$content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
 			$content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
 			$content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
-			$content = str_replace('{mysql_server_ip}',$conf['mysql']['host'],$content);
+			$content = str_replace('{mysql_server_ip}',$conf['mysql']['ip'],$content);
 		}
 		wf($conf['vlogger']['config_dir'].'/'.$configfile,$content);
 		chmod($conf['vlogger']['config_dir'].'/'.$configfile, 0600);
@@ -1469,12 +1492,11 @@
 
 			//copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
 			//* and create the symlink
-			if($this->install_ispconfig_interface == true) {
-				if(@is_link($vhost_conf_enabled_dir.'/apps.vhost')) unlink($vhost_conf_enabled_dir.'/apps.vhost');
-				if(!@is_link($vhost_conf_enabled_dir.'/000-apps.vhost')) {
-					symlink($vhost_conf_dir.'/apps.vhost',$vhost_conf_enabled_dir.'/000-apps.vhost');
-				}
+			if(@is_link($vhost_conf_enabled_dir.'/apps.vhost')) unlink($vhost_conf_enabled_dir.'/apps.vhost');
+			if(!@is_link($vhost_conf_enabled_dir.'/000-apps.vhost')) {
+				symlink($vhost_conf_dir.'/apps.vhost',$vhost_conf_enabled_dir.'/000-apps.vhost');
 			}
+			
 			if(!is_file($conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter')) {
 				mkdir($conf['web']['website_basedir'].'/php-fcgi-scripts/apps', 0755, true);
 				copy('tpl/apache_apps_fcgi_starter.master',$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
@@ -1548,12 +1570,11 @@
 
 			//copy('tpl/nginx_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
 			//* and create the symlink
-			if($this->install_ispconfig_interface == true) {
-				if(@is_link($vhost_conf_enabled_dir.'/apps.vhost')) unlink($vhost_conf_enabled_dir.'/apps.vhost');
-				if(!@is_link($vhost_conf_enabled_dir.'/000-apps.vhost')) {
-					symlink($vhost_conf_dir.'/apps.vhost',$vhost_conf_enabled_dir.'/000-apps.vhost');
-				}
+			if(@is_link($vhost_conf_enabled_dir.'/apps.vhost')) unlink($vhost_conf_enabled_dir.'/apps.vhost');
+			if(!@is_link($vhost_conf_enabled_dir.'/000-apps.vhost')) {
+				symlink($vhost_conf_dir.'/apps.vhost',$vhost_conf_enabled_dir.'/000-apps.vhost');
 			}
+			
 		}
 	}
 	
@@ -1769,6 +1790,10 @@
 				}
 			}
 		}
+		
+		//* Make the APS directories group writable
+		exec("chmod -R 770 $install_dir/interface/web/sites/aps_meta_packages");
+		exec("chmod -R 770 $install_dir/server/aps_packages");
 
 		//* make sure that the server config file (not the interface one) is only readable by the root user
 		chmod($install_dir.'/server/lib/'.$configfile, 0600);
@@ -1786,9 +1811,8 @@
 		}
 		
 		if(is_dir($install_dir.'/interface/invoices')) {
-			chmod($install_dir.'/interface/invoices', 0770);
-			chown($install_dir.'/interface/invoices', 'ispconfig');
-			chgrp($install_dir.'/interface/invoices', 'ispconfig');
+			exec('chmod -R 770 '.escapeshellarg($install_dir.'/interface/invoices'));
+			exec('chown -R ispconfig:ispconfig '.escapeshellarg($install_dir.'/interface/invoices'));
 		}
 
 		// TODO: FIXME: add the www-data user to the ispconfig group. This is just for testing
@@ -1815,7 +1839,7 @@
 		$command = "chmod +x $install_dir/server/scripts/*.sh";
 		caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 
-		if($conf['apache']['installed'] == true){
+		if($conf['apache']['installed'] == true && $this->install_ispconfig_interface == true){
 			//* Copy the ISPConfig vhost for the controlpanel
 			$vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
 			$vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
@@ -1841,7 +1865,7 @@
 
 			//copy('tpl/apache_ispconfig.vhost.master', $vhost_conf_dir.'/ispconfig.vhost');
 			//* and create the symlink
-			if($this->install_ispconfig_interface == true && $this->is_update == false) {
+			if($this->is_update == false) {
 				if(@is_link($vhost_conf_enabled_dir.'/ispconfig.vhost')) unlink($vhost_conf_enabled_dir.'/ispconfig.vhost');
 				if(!@is_link($vhost_conf_enabled_dir.'/000-ispconfig.vhost')) {
 					symlink($vhost_conf_dir.'/ispconfig.vhost',$vhost_conf_enabled_dir.'/000-ispconfig.vhost');
@@ -1857,7 +1881,7 @@
 			}
 		}
 		
-		if($conf['nginx']['installed'] == true){
+		if($conf['nginx']['installed'] == true && $this->install_ispconfig_interface == true){
 			//* Copy the ISPConfig vhost for the controlpanel
 			$vhost_conf_dir = $conf['nginx']['vhost_conf_dir'];
 			$vhost_conf_enabled_dir = $conf['nginx']['vhost_conf_enabled_dir'];
@@ -1900,7 +1924,7 @@
 
 			//copy('tpl/nginx_ispconfig.vhost.master', $vhost_conf_dir.'/ispconfig.vhost');
 			//* and create the symlink
-			if($this->install_ispconfig_interface == true && $this->is_update == false) {
+			if($this->is_update == false) {
 				if(@is_link($vhost_conf_enabled_dir.'/ispconfig.vhost')) unlink($vhost_conf_enabled_dir.'/ispconfig.vhost');
 				if(!@is_link($vhost_conf_enabled_dir.'/000-ispconfig.vhost')) {
 					symlink($vhost_conf_dir.'/ispconfig.vhost',$vhost_conf_enabled_dir.'/000-ispconfig.vhost');

--
Gitblit v1.9.1