commit | author | age
|
94927b
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
Copyright (c) 2007, Till Brehm, projektfarm Gmbh |
|
5 |
All rights reserved. |
|
6 |
|
|
7 |
Redistribution and use in source and binary forms, with or without modification, |
|
8 |
are permitted provided that the following conditions are met: |
|
9 |
|
|
10 |
* Redistributions of source code must retain the above copyright notice, |
|
11 |
this list of conditions and the following disclaimer. |
|
12 |
* Redistributions in binary form must reproduce the above copyright notice, |
|
13 |
this list of conditions and the following disclaimer in the documentation |
|
14 |
and/or other materials provided with the distribution. |
|
15 |
* Neither the name of ISPConfig nor the names of its contributors |
|
16 |
may be used to endorse or promote products derived from this software without |
|
17 |
specific prior written permission. |
|
18 |
|
|
19 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
20 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
21 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
22 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
23 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
24 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
25 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
26 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
27 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
28 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
29 |
*/ |
|
30 |
|
|
31 |
class installer extends installer_base { |
b1a6a5
|
32 |
|
94927b
|
33 |
public function configure_dovecot() |
b1a6a5
|
34 |
{ |
94927b
|
35 |
global $conf; |
a8aad2
|
36 |
|
DM |
37 |
$virtual_transport = 'dovecot'; |
|
38 |
|
|
39 |
// check if virtual_transport must be changed |
|
40 |
if ($this->is_update) { |
2af58c
|
41 |
$tmp = $this->db->queryOneRecord("SELECT * FROM ?? WHERE server_id = ?", $conf["mysql"]["database"] . ".server", $conf['server_id']); |
a8aad2
|
42 |
$ini_array = ini_to_array(stripslashes($tmp['config'])); |
DM |
43 |
// ini_array needs not to be checked, because already done in update.php -> updateDbAndIni() |
|
44 |
|
|
45 |
if(isset($ini_array['mail']['mailbox_virtual_uidgid_maps']) && $ini_array['mail']['mailbox_virtual_uidgid_maps'] == 'y') { |
|
46 |
$virtual_transport = 'lmtp:unix:private/dovecot-lmtp'; |
|
47 |
} |
|
48 |
} |
b1a6a5
|
49 |
|
94927b
|
50 |
$config_dir = $conf['dovecot']['config_dir']; |
b1a6a5
|
51 |
|
94927b
|
52 |
//* Configure master.cf and add a line for deliver |
T |
53 |
if(is_file($config_dir.'/master.cf')){ |
8e725d
|
54 |
copy($config_dir.'/master.cf', $config_dir.'/master.cf~2'); |
J |
55 |
} |
94927b
|
56 |
if(is_file($config_dir.'/master.cf~')){ |
8e725d
|
57 |
chmod($config_dir.'/master.cf~2', 0400); |
J |
58 |
} |
94927b
|
59 |
$content = rf($conf["postfix"]["config_dir"].'/master.cf'); |
T |
60 |
// Only add the content if we had not addded it before |
b1a6a5
|
61 |
if(!stristr($content, "dovecot/deliver")) { |
94927b
|
62 |
$deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}'; |
b1a6a5
|
63 |
af($conf["postfix"]["config_dir"].'/master.cf', $deliver_content); |
94927b
|
64 |
} |
T |
65 |
unset($content); |
|
66 |
unset($deliver_content); |
b1a6a5
|
67 |
|
MC |
68 |
|
94927b
|
69 |
//* Reconfigure postfix to use dovecot authentication |
T |
70 |
// Adding the amavisd commands to the postfix configuration |
|
71 |
$postconf_commands = array ( |
|
72 |
'dovecot_destination_recipient_limit = 1', |
a8aad2
|
73 |
'virtual_transport = '.$virtual_transport, |
94927b
|
74 |
'smtpd_sasl_type = dovecot', |
T |
75 |
'smtpd_sasl_path = private/auth' |
|
76 |
); |
b1a6a5
|
77 |
|
94927b
|
78 |
// Make a backup copy of the main.cf file |
b1a6a5
|
79 |
copy($conf["postfix"]["config_dir"].'/main.cf', $conf["postfix"]["config_dir"].'/main.cf~3'); |
MC |
80 |
|
94927b
|
81 |
// Executing the postconf commands |
T |
82 |
foreach($postconf_commands as $cmd) { |
|
83 |
$command = "postconf -e '$cmd'"; |
|
84 |
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
85 |
} |
b1a6a5
|
86 |
|
94927b
|
87 |
//* copy dovecot.conf |
T |
88 |
$configfile = 'dovecot.conf'; |
8e725d
|
89 |
if(is_file($config_dir.'/'.$configfile)){ |
J |
90 |
copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~'); |
|
91 |
} |
b1a6a5
|
92 |
|
31e0d1
|
93 |
//* Get the dovecot version |
b1a6a5
|
94 |
exec('dovecot --version', $tmp); |
1fc360
|
95 |
$dovecot_version = $tmp[0]; |
31e0d1
|
96 |
unset($tmp); |
b1a6a5
|
97 |
|
31e0d1
|
98 |
//* Copy dovecot configuration file |
1fc360
|
99 |
if(version_compare($dovecot_version,2) >= 0) { |
b1a6a5
|
100 |
if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian6_dovecot2.conf.master')) { |
MC |
101 |
copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian6_dovecot2.conf.master', $config_dir.'/'.$configfile); |
|
102 |
} else { |
|
103 |
copy('tpl/debian6_dovecot2.conf.master', $config_dir.'/'.$configfile); |
|
104 |
} |
5e7306
|
105 |
replaceLine($config_dir.'/'.$configfile, 'postmaster_address = postmaster@example.com', 'postmaster_address = postmaster@'.$conf['hostname'], 1, 0); |
1fc360
|
106 |
if(version_compare($dovecot_version,2.1) < 0) { |
TB |
107 |
removeLine($config_dir.'/'.$configfile, 'ssl_protocols ='); |
|
108 |
} |
31e0d1
|
109 |
} else { |
b1a6a5
|
110 |
if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian6_dovecot.conf.master')) { |
MC |
111 |
copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian6_dovecot.conf.master', $config_dir.'/'.$configfile); |
|
112 |
} else { |
|
113 |
copy('tpl/debian6_dovecot.conf.master', $config_dir.'/'.$configfile); |
|
114 |
} |
31e0d1
|
115 |
} |
1fc360
|
116 |
|
TB |
117 |
|
b1a6a5
|
118 |
|
94927b
|
119 |
//* dovecot-sql.conf |
T |
120 |
$configfile = 'dovecot-sql.conf'; |
8e725d
|
121 |
if(is_file($config_dir.'/'.$configfile)){ |
J |
122 |
copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~'); |
4586d5
|
123 |
chmod($config_dir.'/'.$configfile.'~', 0400); |
8e725d
|
124 |
} |
615a0a
|
125 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian6_dovecot-sql.conf.master', 'tpl/debian6_dovecot-sql.conf.master'); |
b1a6a5
|
126 |
$content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content); |
MC |
127 |
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content); |
|
128 |
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content); |
|
129 |
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content); |
82e9b9
|
130 |
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content); |
032b86
|
131 |
$content = str_replace('{server_id}', $conf['server_id'], $content); |
8e725d
|
132 |
wf($config_dir.'/'.$configfile, $content); |
b1a6a5
|
133 |
|
8e725d
|
134 |
chmod($config_dir.'/'.$configfile, 0600); |
J |
135 |
chown($config_dir.'/'.$configfile, 'root'); |
|
136 |
chgrp($config_dir.'/'.$configfile, 'root'); |
5e7306
|
137 |
|
TB |
138 |
// Dovecot shall ignore mounts in website directory |
9b6866
|
139 |
if(is_installed('doveadm')) exec("doveadm mount add '/var/www/*' ignore > /dev/null 2> /dev/null"); |
94927b
|
140 |
|
T |
141 |
} |
b1a6a5
|
142 |
|
1ca823
|
143 |
public function configure_apache() { |
T |
144 |
global $conf; |
b1a6a5
|
145 |
|
MC |
146 |
if(file_exists('/etc/apache2/mods-available/fcgid.conf')) replaceLine('/etc/apache2/mods-available/fcgid.conf', 'MaxRequestLen', 'MaxRequestLen 15728640', 0, 1); |
|
147 |
|
1ca823
|
148 |
parent::configure_apache(); |
T |
149 |
} |
94927b
|
150 |
|
b1a6a5
|
151 |
public function configure_fail2ban() { |
MC |
152 |
/* |
c12af9
|
153 |
copy('tpl/dovecot-pop3imap.conf.master',"/etc/fail2ban/filter.d/dovecot-pop3imap.conf"); |
L |
154 |
copy('tpl/dovecot_fail2ban_jail.local.master','/etc/fail2ban/jail.local'); |
e44ec9
|
155 |
*/ |
b1a6a5
|
156 |
} |
MC |
157 |
|
94927b
|
158 |
} |
T |
159 |
|
4586d5
|
160 |
?> |