From e6bb4e823a6fb353fb802b6a7bfb8d7ed1cc424a Mon Sep 17 00:00:00 2001
From: quentusrex <quentusrex@ispconfig3>
Date: Thu, 06 Nov 2008 12:35:24 -0500
Subject: [PATCH] Oops. Don't ever disable auth.  Bug FS#267 - mail filter not hidden for client 

---
 install/lib/installer_base.lib.php |   67 +++++++++++++++++++++++++--------
 1 files changed, 50 insertions(+), 17 deletions(-)

diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index c28947a..1a2fd6f 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -35,6 +35,7 @@
 	var $db;
 	public $conf;
 	public $install_ispconfig_interface = true;
+	
 
 
     public function __construct()
@@ -115,6 +116,7 @@
 	public function configure_database()
     {
 		global $conf;
+		
 		$cf = $conf['mysql']; // make $conf['mysql'] more accessible
 		//** Create the database
 		if(!$this->db->query('CREATE DATABASE IF NOT EXISTS '.$cf['database'])) {
@@ -147,6 +149,7 @@
 	public function add_database_server_record() {
 		
 		global $conf;
+		
 		$cf = $conf['mysql']; // make $conf['mysql'] more accessible
 		
 		if($cf['host'] == 'localhost') {
@@ -155,12 +158,17 @@
 			$from_host = $conf['hostname'];
 		}
 		
+		// Delete ISPConfig user, in case that it exists
+		$this->db->query("DELETE FROM mysql.user WHERE User = '".$cf['ispconfig_user']."' AND Host = '".$from_host."';");
+		$this->db->query("DELETE FROM mysql.db WHERE Db = '".$cf['database']."' AND Host = '".$from_host."';");
+		$this->db->query('FLUSH PRIVILEGES;');
+		
 		//* Create the ISPConfig database user
         $query = 'GRANT SELECT, INSERT, UPDATE, DELETE ON '.$cf['database'].".* "
                 ."TO '".$cf['ispconfig_user']."'@'".$from_host."' "
                 ."IDENTIFIED BY '".$cf['ispconfig_password']."';";
 		if(!$this->db->query($query)) {
-			$this->error('Unable to create database user: '.$cf['ispconfig_user']);
+			$this->error('Unable to create database user: '.$cf['ispconfig_user'].' Error: '.$this->db->errorMessage);
 		}
 		
 		//* Reload database privelages
@@ -170,7 +178,7 @@
 		$this->db->dbName = $cf['database'];
 		
 		$server_ini_content = rf("tpl/server.ini.master");
-		$server_ini_content = addslashes($server_ini_content);
+		$server_ini_content = mysql_real_escape_string($server_ini_content);
 		
 		$sql = "INSERT INTO `server` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`) VALUES (1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', 1, 1, 1, 1, 1, 1, '$server_ini_content', 0, 1);";
 		$this->db->query($sql);
@@ -180,8 +188,10 @@
 	
 
     //** writes postfix configuration files
-    private function process_postfix_config($configfile)
-    {
+    public function process_postfix_config($configfile)
+    {	
+		global $conf;
+		
         $config_dir = $conf['postfix']['config_dir'].'/';
         $full_file_name = $config_dir.$configfile; 
         //* Backup exiting file
@@ -199,7 +209,9 @@
 
 	public function configure_jailkit()
     {
-        $cf = $conf['jailkit'];
+        global $conf;
+		
+		$cf = $conf['jailkit'];
 		$config_dir = $cf['config_dir'];
 		$jk_init = $cf['jk_init'];
 		$jk_chrootsh = $cf['jk_chrootsh'];
@@ -318,12 +330,6 @@
 			caselog($command." &> /dev/null", __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
 		}
 		
-		// TODO: Change the master.cf file
-		/*
-		Add:
-        maildrop  unix  -       n       n       -       -       pipe
-        flags=R user=vmail argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}
-		*/
 		if(!stristr($options,'dont-create-certs')) {
 			//* Create the SSL certificate
 			$command = 'cd '.$config_dir.'; '
@@ -363,8 +369,10 @@
 		wf($cf['vmail_mailbox_base'].'/.'.$configfile, $content);
 		
 		//* Create the directory for the custom mailfilters
-		$command = 'mkdir '.$cf['vmail_mailbox_base'].'/mailfilters';
-		caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
+		if(!is_dir($cf['vmail_mailbox_base'].'/mailfilters')) {
+			$command = 'mkdir '.$cf['vmail_mailbox_base'].'/mailfilters';
+			caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
+		}
 		
 		//* Chmod and chown the .mailfilter file
 		$command = 'chown -R '.$cf['vmail_username'].':'.$cf['vmail_groupname'].' '.$cf['vmail_mailbox_base'].'/.mailfilter';
@@ -375,7 +383,7 @@
 		
 	}
 	
-	function configure_saslauthd() {
+	public function configure_saslauthd() {
 		global $conf;
 		
 	
@@ -402,7 +410,10 @@
 		if(is_file($configfile.'~')) exec('chmod 400 '.$configfile.'~');
 		$content = rf($configfile);
 		$content = str_replace('START=no','START=yes',$content);
+		// Debian
 		$content = str_replace('OPTIONS="-c"','OPTIONS="-m /var/spool/postfix/var/run/saslauthd -r"',$content);
+		// Ubuntu
+		$content = str_replace('OPTIONS="-c -m /var/run/saslauthd"','OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r"',$content);
 		wf($configfile,$content);
 		
 		// Edit the file /etc/init.d/saslauthd
@@ -410,6 +421,9 @@
 		$content = rf($configfile);
 		$content = str_replace('PIDFILE=$RUN_DIR/saslauthd.pid','PIDFILE="/var/spool/postfix/var/run/${NAME}/saslauthd.pid"',$content);
 		wf($configfile,$content);
+		
+		// add the postfix user to the sasl group (at least nescessary for ubuntu 8.04 and most likely debian lenny too.
+		exec('adduser postfix sasl');
 		
 		
 	}
@@ -467,7 +481,7 @@
 		wf($configfile, $content);
 	}
 	
-	function configure_amavis() {
+	public function configure_amavis() {
 		global $conf;
 		
 		// amavisd user config file
@@ -502,11 +516,14 @@
 		
 		// Append the configuration for amavisd to the master.cf file
 		if(is_file($conf["postfix"]["config_dir"].'/master.cf')) copy($conf["postfix"]["config_dir"].'/master.cf',$conf["postfix"]["config_dir"].'/master.cf~');
-		$content = rf("tpl/master_cf_amavis.master");
+		$content = rf($conf["postfix"]["config_dir"].'/master.cf');
 		// Only add the content if we had not addded it before
-		if(!stristr("127.0.0.1:10025 inet n - - - - smtpd",$content)) {
+		if(!stristr($content,"127.0.0.1:10025")) {
+			unset($content);
+			$content = rf("tpl/master_cf_amavis.master");
 			af($conf["postfix"]["config_dir"].'/master.cf',$content);
 		}
+		unset($content);
 		
 		// Add the clamav user to the amavis group
 		exec('adduser clamav amavis');
@@ -530,6 +547,8 @@
 	
 	public function configure_getmail()
     {
+		global $conf;
+		
 		$config_dir = $conf['getmail']['config_dir'];
 		
 		if(!is_dir($config_dir)) exec("mkdir -p ".escapeshellcmd($config_dir));
@@ -595,8 +614,15 @@
 	
 	public function configure_apache()
     {	
+		global $conf;
+		
 		//* Create the logging directory for the vhost logfiles
 		exec('mkdir -p /var/log/ispconfig/httpd');
+		
+		if(is_file('/etc/suphp/suphp.conf')) {
+			replaceLine('/etc/suphp/suphp.conf','php=php:/usr/bin','x-httpd-suphp=php:/usr/bin/php-cgi',0);
+			replaceLine('/etc/suphp/suphp.conf','docroot=','docroot=/var/clients',0);
+		}
 		
 	}
 	
@@ -606,6 +632,7 @@
 		
 		$dist_init_scripts = $conf['init_scripts'];
   		
+		if(is_dir("/etc/Bastille.backup")) caselog("rm -rf /etc/Bastille.backup", __FILE__, __LINE__);
 		if(is_dir("/etc/Bastille")) caselog("mv -f /etc/Bastille /etc/Bastille.backup", __FILE__, __LINE__);
   		@mkdir("/etc/Bastille", octdec($directory_mode));
   		if(is_dir("/etc/Bastille.backup/firewall.d")) caselog("cp -pfr /etc/Bastille.backup/firewall.d /etc/Bastille/", __FILE__, __LINE__);
@@ -723,6 +750,9 @@
 				while (($file = readdir($dh)) !== false) {
 					if($file != '.' && $file != '..') {
 						if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file);
+						if (strpos($file, '_core_module') !== false) {
+							if(!@is_link($install_dir.'/server/mods-core/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-core/'.$file);
+						}
 					}
 				}
 				closedir($dh);
@@ -735,6 +765,9 @@
 				while (($file = readdir($dh)) !== false) {
 					if($file != '.' && $file != '..') {
 						if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
+						if (strpos($file, '_core_plugin') !== false) {
+							if(!@is_link($install_dir.'/server/plugins-core/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-core/'.$file);
+						}
 					}
 				}
 				closedir($dh);

--
Gitblit v1.9.1