Commit fdb51429 authored by tbrehm's avatar tbrehm

- Added dovecot Support for opensuse

- added installation instructions for opensuse 11.2 with bind and dovecot
- fixed a bug in bind plugin.
- improved opensuse installer.
parent 03c48f09
Installation
-----------
It is recommended to use a clean (fresh) OpenSUSE installatiom where you selected to install just the minimal packages. A Gnome or KDE desktop is not needed and will just slow down the server. Then follow the steps below to setup your server with ISPConfig 3:
The following guide is for the 32Bit version of openSUSE, for 64Bit installations the package names may differ especially the names of downloaded rpm files.
This guide will use Dovecote as pop3 / imap server and BIND as DNS Server. Dovecot and BIND are supported by ISPConfig version > 3.0.2
Install some basic packes and the compilers that we need later
// yast2 -i findutils readline libgcc glibc-devel findutils-locate gcc flex lynx compat-readline4 db-devel wget gcc-c++ make vim telnet cron iptables iputils man man-pages nano pico
yast2 -i findutils lynx wget vim telnet cron iptables iputils man man-pages nano pico sudo
1) Install Postfix, Divecot, MySQL with the following command line (on one line!):
yast2 -i postfix postfix-mysql mysql mysql-client python libmysqlclient-devel dovecot12 dovecot12-backend-mysql
chkconfig --add mysql
/etc/init.d/mysql start
chkconfig --add postfix
/etc/init.d/postfix start
chkconfig --add dovecot
/etc/init.d/dovecot start
rpm -i http://download.opensuse.org/repositories/server:/mail/openSUSE_11.2/noarch/getmail-4.16.0-1.1.noarch.rpm
// Set the mysql database password:
mysql_secure_installation
2) Install Amavisd-new, Spamassassin and Clamav (1 line!):
yast2 -i amavisd-new clamav clamav-db zoo unzip unrar bzip2 unarj perl-DBD-mysql
Open /etc/amavisd.conf...
vi /etc/amavisd.conf
... and add the $myhostname line with your correct hostname below the $mydomain line:
[...]
$mydomain = 'example.com'; # a convenient default for other settings
$myhostname = "server1.$mydomain";
[...]
then execute:
chkconfig --add amavis
chkconfig --add clamd
/etc/init.d/amavis start
/etc/init.d/clamd start
2.1) Install apache2
yast2 -i apache2 apache2-mod_fcgid
3) Install PHP5 modules (1 line!):
yast2 -i php5-bcmath php5-bz2 php5-calendar php5-ctype php5-curl php5-dom php5-ftp php5-gd php5-gettext php5-gmp php5-iconv php5-imap php5-ldap php5-mbstring php5-mcrypt php5-mysql php5-odbc php5-openssl php5-pcntl php5-pgsql php5-posix php5-shmop php5-snmp php5-soap php5-sockets php5-sqlite php5-sysvsem php5-tokenizer php5-wddx php5-xmlrpc php5-xsl php5-zlib php5-exif php5-fastcgi php5-pear php5-sysvmsg php5-sysvshm ImageMagick curl apache2-mod_php5
rpm -i http://download.opensuse.org/repositories/server:/php/openSUSE_11.2/i586/suphp-0.7.1-3.1.i586.rpm
Then run the following to enable the Apache modules:
a2enmod suexec
a2enmod rewrite
a2enmod ssl
a2enmod actions
a2enmod suphp
a2enmod fcgid
// Fix a suexec permission problem
chown root:www /usr/sbin/suexec2
chmod 4755 /usr/sbin/suexec2
// and start apache
chkconfig --add apache2
/etc/init.d/apache2 start
cd /tmp
yast2 -i pwgen
rpm -i http://download.opensuse.org/repositories/server:/php:/applications/openSUSE_11.2/noarch/phpMyAdmin-3.2.5-1.1.noarch.rpm
// Warnings like "warning: phpMyAdmin-3.1.2-1.1.src.rpm: Header V3 DSA signature: NOKEY, key ID 367fe7fc" can be ignored.
4) Install pure-ftpd and quota
yast2 -i pure-ftpd quota
chkconfig --add pure-ftpd
/etc/init.d/pure-ftpd start
5) Install Bind
yast2 -i bind
chkconfig --add named
6) Install webalizer
yast2 -i webalizer perl-DateManip
6.1 Install fail2ban
yast2 -i fail2ban
6.2 Install jailkit
rpm -i http://download.opensuse.org/repositories/security/openSUSE_11.2/i586/jailkit-2.11-1.1.i586.rpm
7) Install ISPConfig 3
cd /tmp
wget http://www.ispconfig.org/downloads/ISPConfig-3.0.2.tar.gz
tar xvfz ISPConfig-3.0.2.tar.gz
cd ispconfig3_install/install/
php -q install.php
The installer will configure all services like postfix, sasl, courier, etc. for you. A manual setup as required for ISPConfig 2 (perfect setup guides) is not nescessary. To login to the ISPConfig controlpanel, open the following URL in your browser (replace the IP to match your settings!):
http://192.168.0.100:8080/
the default login is:
user: admin
password: admin
In case you get a permission denied error from apache, please restart the apache webserver process.
Optional:
Install a webbased Email Client
rpm -i http://download.opensuse.org/repositories/server:/php:/applications/openSUSE_11.2/noarch/squirrelmail-1.4.19-4.1.noarch.rpm
......@@ -161,11 +161,11 @@ $conf['powerdns']['init_script'] = 'pdns';
//* BIND DNS Server
$conf['bind']['installed'] = false; // will be detected automatically during installation
$conf['bind']['bind_user'] = 'root';
$conf['bind']['bind_group'] = 'bind';
$conf['bind']['bind_zonefiles_dir'] = '/etc/bind';
$conf['bind']['named_conf_path'] = '/etc/bind/named.conf';
$conf['bind']['named_conf_local_path'] = '/etc/bind/named.conf.local';
$conf['bind']['bind_user'] = 'named';
$conf['bind']['bind_group'] = 'named';
$conf['bind']['bind_zonefiles_dir'] = '/var/lib/named';
$conf['bind']['named_conf_path'] = '/etc/named.conf';
$conf['bind']['named_conf_local_path'] = '/etc/named.conf.include';
$conf['bind']['init_script'] = 'named';
//* Jailkit
......
......@@ -77,11 +77,21 @@ class installer_dist extends installer_base {
__FILE__, __LINE__, 'chgrp on mysql-virtual_*.cf*', 'chgrp on mysql-virtual_*.cf* failed');
//* Creating virtual mail user and group
$command = 'groupadd -g '.$cf['vmail_groupid'].' '.$cf['vmail_groupname'];
if(!is_group($cf['vmail_groupname'])) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
$command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m';
if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
if(is_group($cf['vmail_groupname'])) {
$command = 'groupmod -g '.$cf['vmail_groupid'].' '.$cf['vmail_groupname'];
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
} else {
$command = 'groupadd -g '.$cf['vmail_groupid'].' '.$cf['vmail_groupname'];
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
}
if(is_user($cf['vmail_username'])) {
$command = 'usermod -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' -d '.$cf['vmail_mailbox_base'].' -s /bin/bash '.$cf['vmail_username'];
caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
} else {
$command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m';
caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
}
$postconf_commands = array (
'myhostname = '.$conf['hostname'],
......@@ -172,6 +182,9 @@ class installer_dist extends installer_base {
' flags=DRhu user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}',
$content);
// enable tlsmanager
$content = str_replace('#tlsmgr unix - - n 1000? 1 tlsmgr','tlsmgr unix - - n 1000? 1 tlsmgr',$content);
wf($configfile, $content);
//* Writing the Maildrop mailfilter file
......@@ -235,7 +248,7 @@ class installer_dist extends installer_base {
$content = str_replace('/sbin/startproc $AUTHD_BIN $SASLAUTHD_PARAMS -a $SASLAUTHD_AUTHMECH -n $SASLAUTHD_THREADS > /dev/null 2>&1','/sbin/startproc $AUTHD_BIN $SASLAUTHD_PARAMS -r -a $SASLAUTHD_AUTHMECH -n $SASLAUTHD_THREADS > /dev/null 2>&1',$content);
wf($configfile,$content);
if(is_file($configfile)) wf($configfile,$content);
......@@ -294,12 +307,79 @@ class installer_dist extends installer_base {
wf($configfile, $content);
}
public function configure_dovecot()
{
global $conf;
$config_dir = $conf['dovecot']['config_dir'];
//* Configure master.cf and add a line for deliver
if(is_file($config_dir.'/master.cf')){
copy($config_dir.'/master.cf', $config_dir.'/master.cf~2');
}
if(is_file($config_dir.'/master.cf~')){
exec('chmod 400 '.$config_dir.'/master.cf~2');
}
$content = rf($conf["postfix"]["config_dir"].'/master.cf');
// Only add the content if we had not addded it before
if(!stristr($content,"dovecot/deliver")) {
$deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}';
af($conf["postfix"]["config_dir"].'/master.cf',$deliver_content);
}
unset($content);
unset($deliver_content);
//* Reconfigure postfix to use dovecot authentication
// Adding the amavisd commands to the postfix configuration
$postconf_commands = array (
'dovecot_destination_recipient_limit = 1',
'virtual_transport = dovecot',
'smtpd_sasl_type = dovecot',
'smtpd_sasl_path = private/auth',
'receive_override_options = no_address_mappings'
);
// Make a backup copy of the main.cf file
copy($conf["postfix"]["config_dir"].'/main.cf',$conf["postfix"]["config_dir"].'/main.cf~3');
// Executing the postconf commands
foreach($postconf_commands as $cmd) {
$command = "postconf -e '$cmd'";
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
}
//* copy dovecot.conf
$configfile = 'dovecot.conf';
if(is_file("$config_dir/$configfile")){
copy("$config_dir/$configfile", "$config_dir/$configfile~");
}
copy('tpl/opensuse_dovecot.conf.master',"$config_dir/$configfile");
//* dovecot-sql.conf
$configfile = 'dovecot-sql.conf';
if(is_file("$config_dir/$configfile")){
copy("$config_dir/$configfile", "$config_dir/$configfile~");
}
exec("chmod 400 $config_dir/$configfile~");
$content = rf("tpl/opensuse_dovecot-sql.conf.master");
$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_host}',$conf['mysql']['host'],$content);
wf("$config_dir/$configfile", $content);
exec("chmod 600 $config_dir/$configfile");
exec("chown root:root $config_dir/$configfile");
}
public function configure_amavis() {
global $conf;
// amavisd user config file
$configfile = 'opensuse_amavisd_conf';
if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) copy($conf["amavis"]["config_dir"].'/amavisd.conf',$conf["courier"]["config_dir"].'/amavisd.conf~');
if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) @copy($conf["amavis"]["config_dir"].'/amavisd.conf',$conf["courier"]["config_dir"].'/amavisd.conf~');
if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf~')) exec('chmod 400 '.$conf["amavis"]["config_dir"].'/amavisd.conf~');
$content = rf("tpl/".$configfile.".master");
$content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
......
......@@ -218,6 +218,11 @@ class installer_base {
$tpl_ini_array['web']['group'] = $conf['apache']['group'];
$tpl_ini_array['mail']['pop3_imap_daemon'] = ($conf['dovecot']['installed'] == true)?'dovecot':'courier';
$tpl_ini_array['mail']['mail_filter_syntax'] = ($conf['dovecot']['installed'] == true)?'sieve':'maildrop';
$tpl_ini_array['dns']['bind_user'] = $conf['bind']['bind_user'];
$tpl_ini_array['dns']['bind_group'] = $conf['bind']['bind_group'];
$tpl_ini_array['dns']['bind_zonefiles_dir'] = $conf['bind']['bind_zonefiles_dir'];
$tpl_ini_array['dns']['named_conf_path'] = $conf['bind']['named_conf_path'];
$tpl_ini_array['dns']['named_conf_local_path'] = $conf['bind']['named_conf_local_path'];
$server_ini_content = array_to_ini($tpl_ini_array);
$server_ini_content = mysql_real_escape_string($server_ini_content);
......
# This file is opened as root, so it should be owned by root and mode 0600.
#
# http://wiki.dovecot.org/AuthDatabase/SQL
#
# For the sql passdb module, you'll need a database with a table that
# contains fields for at least the username and password. If you want to
# use the user@domain syntax, you might want to have a separate domain
# field as well.
#
# If your users all have the same uig/gid, and have predictable home
# directories, you can use the static userdb module to generate the home
# dir based on the username and domain. In this case, you won't need fields
# for home, uid, or gid in the database.
#
# If you prefer to use the sql userdb module, you'll want to add fields
# for home, uid, and gid. Here is an example table:
#
# CREATE TABLE users (
# username VARCHAR(128) NOT NULL,
# domain VARCHAR(128) NOT NULL,
# password VARCHAR(64) NOT NULL,
# home VARCHAR(255) NOT NULL,
# uid INTEGER NOT NULL,
# gid INTEGER NOT NULL,
# active CHAR(1) DEFAULT 'Y' NOT NULL
# );
# Database driver: mysql, pgsql, sqlite
#driver =
# Database connection string. This is driver-specific setting.
#
# pgsql:
# For available options, see the PostgreSQL documention for the
# PQconnectdb function of libpq.
#
# mysql:
# Basic options emulate PostgreSQL option names:
# host, port, user, password, dbname
#
# But also adds some new settings:
# client_flags - See MySQL manual
# ssl_ca, ssl_ca_path - Set either one or both to enable SSL
# ssl_cert, ssl_key - For sending client-side certificates to server
# ssl_cipher - Set minimum allowed cipher security (default: HIGH)
# option_file - Read options from the given file instead of
# the default my.cnf location
# option_group - Read options from the given group (default: client)
#
# You can connect to UNIX sockets by using host: host=/var/run/mysql.sock
# Note that currently you can't use spaces in parameters.
#
# MySQL supports multiple host parameters for load balancing / HA.
#
# sqlite:
# The path to the database file.
#
# Examples:
# connect = host=192.168.1.1 dbname=users
# connect = host=sql.example.com dbname=virtual user=virtual password=blarg
# connect = /etc/dovecot/authdb.sqlite
#
#connect =
# Default password scheme.
#
# List of supported schemes is in
# http://wiki.dovecot.org/Authentication/PasswordSchemes
#
#default_pass_scheme = MD5
# passdb query to retrieve the password. It can return fields:
# password - The user's password. This field must be returned.
# user - user@domain from the database. Needed with case-insensitive lookups.
# username and domain - An alternative way to represent the "user" field.
#
# The "user" field is often necessary with case-insensitive lookups to avoid
# e.g. "name" and "nAme" logins creating two different mail directories. If
# your user and domain names are in separate fields, you can return "username"
# and "domain" fields instead of "user".
#
# The query can also return other fields which have a special meaning, see
# http://wiki.dovecot.org/PasswordDatabase/ExtraFields
#
# Commonly used available substitutions (see http://wiki.dovecot.org/Variables
# for full list):
# %u = entire user@domain
# %n = user part of user@domain
# %d = domain part of user@domain
#
# Note that these can be used only as input to SQL query. If the query outputs
# any of these substitutions, they're not touched. Otherwise it would be
# difficult to have eg. usernames containing '%' characters.
#
# Example:
# password_query = SELECT userid AS user, pw AS password \
# FROM users WHERE userid = '%u' AND active = 'Y'
#
#password_query = \
# SELECT username, domain, password \
# FROM users WHERE username = '%n' AND domain = '%d'
# userdb query to retrieve the user information. It can return fields:
# uid - System UID (overrides mail_uid setting)
# gid - System GID (overrides mail_gid setting)
# home - Home directory
# mail - Mail location (overrides mail_location setting)
#
# None of these are strictly required. If you use a single UID and GID, and
# home or mail directory fits to a template string, you could use userdb static
# instead. For a list of all fields that can be returned, see
# http://wiki.dovecot.org/UserDatabase/ExtraFields
#
# Examples:
# user_query = SELECT home, uid, gid FROM users WHERE userid = '%u'
# user_query = SELECT dir AS home, user AS uid, group AS gid FROM users where userid = '%u'
# user_query = SELECT home, 501 AS uid, 501 AS gid FROM users WHERE userid = '%u'
#
#user_query = \
# SELECT home, uid, gid \
# FROM users WHERE username = '%n' AND domain = '%d'
# If you wish to avoid two SQL lookups (passdb + userdb), you can use
# userdb prefetch instead of userdb sql in dovecot.conf. In that case you'll
# also have to return userdb fields in password_query prefixed with "userdb_"
# string. For example:
#password_query = \
# SELECT userid AS user, password, \
# home AS userdb_home, uid AS userdb_uid, gid AS userdb_gid \
# FROM users WHERE userid = '%u'
driver = mysql
connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_server_ispconfig_user} password={mysql_server_ispconfig_password}
default_pass_scheme = CRYPT
password_query = SELECT password FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'
user_query = SELECT email as user, maildir as home, CONCAT(maildir, '/Maildir') as mail, uid, gid, CONCAT('maildir:storage=', quota) AS quota, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'
This diff is collapsed.
......@@ -18,7 +18,7 @@ NameVirtualHost *:{apps_vhost_port}
Options Indexes FollowSymLinks MultiViews +ExecCGI
AllowOverride AuthConfig Indexes Limit Options FileInfo
AddHandler fcgid-script .php
FCGIWrapper /var/www/php-fcgi-scripts/apps/.php-fcgi-starter .php
FCGIWrapper {apps_vhost_basedir}/php-fcgi-scripts/apps/.php-fcgi-starter .php
Order allow,deny
Allow from all
</Directory>
......
......@@ -1107,6 +1107,102 @@ class system{
return false;
}
}
function replaceLine($filename,$search_pattern,$new_line,$strict = 0,$append = 1) {
$lines = @file($filename);
$out = '';
$found = 0;
if(is_array($lines)) {
foreach($lines as $line) {
if($strict == 0) {
if(stristr($line,$search_pattern)) {
$out .= $new_line."\n";
$found = 1;
} else {
$out .= $line;
}
} else {
if(trim($line) == $search_pattern) {
$out .= $new_line."\n";
$found = 1;
} else {
$out .= $line;
}
}
}
}
if($found == 0) {
//* add \n if the last line does not end with \n or \r
if(substr($out,-1) != "\n" && substr($out,-1) != "\r") $out .= "\n";
//* add the new line at the end of the file
if($append == 1) $out .= $new_line."\n";
}
file_put_contents($filename,$out);
}
function removeLine($filename,$search_pattern,$strict = 0) {
if($lines = @file($filename)) {
$out = '';
foreach($lines as $line) {
if($strict == 0) {
if(!stristr($line,$search_pattern)) {
$out .= $line;
}
} else {
if(!trim($line) == $search_pattern) {
$out .= $line;
}
}
}
file_put_contents($filename,$out);
}
}
function maildirmake($maildir_path, $user = '', $subfolder = '') {
global $app;
if($subfolder != '') {
$dir = escapeshellarg($maildir_path.'/.'.$subfolder);
$dir_cur = escapeshellarg($maildir_path.'/.'.$subfolder.'/cur');
$dir_new = escapeshellarg($maildir_path.'/.'.$subfolder.'/new');
$dir_tmp = escapeshellarg($maildir_path.'/.'.$subfolder.'/tmp');
} else {
$dir = escapeshellarg($maildir_path);
$dir_cur = escapeshellarg($maildir_path.'/cur');
$dir_new = escapeshellarg($maildir_path.'/new');
$dir_tmp = escapeshellarg($maildir_path.'/tmp');
}
exec("mkdir -p $dir_cur $dir_new $dir_tmp");
exec("chmod 0700 $dir $dir_cur $dir_new $dir_tmp");
if($user != '' && $this->is_user($user) && $user != 'root') {
$user = escapeshellarg($user);
exec("chown $user $dir $dir_cur $dir_new $dir_tmp");
}
//* Add the subfolder to the subscriptions and courierimapsubscribed files
if($subfolder != '') {
// Courier
if(!is_file($maildir_path.'/courierimapsubscribed')) {
$tmp_file = escapeshellarg($maildir_path.'/courierimapsubscribed');
exec("touch $tmp_file && chown vmail:vmail $tmp_file");
}
$this->replaceLine($maildir_path.'/courierimapsubscribed','INBOX.'.$subfolder,'INBOX.'.$subfolder,1,1);
// Dovecot
if(!is_file($maildir_path.'/subscriptions')) {
$tmp_file = escapeshellarg($maildir_path.'/subscriptions');
exec("touch $tmp_file && chown vmail:vmail $tmp_file");
}
$this->replaceLine($maildir_path.'/subscriptions',$subfolder,$subfolder,1,1);
}
$app->log('Created Maildir '.$maildir_path.' with subfolder: '.$subfolder,LOGLEVEL_DEBUG);
}
}
?>
\ No newline at end of file
......@@ -86,6 +86,7 @@ class apps_vhost_plugin {
$content = str_replace('{apps_vhost_port}', $web_config['apps_vhost_port'], $content);
$content = str_replace('{apps_vhost_dir}', $web_config['website_basedir'].'/apps', $content);
$content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content);
$content = str_replace('{apps_vhost_basedir}', $web_config['website_basedir'], $content);
// comment out the listen directive if port is 80 or 443
......
......@@ -90,7 +90,7 @@ class bind_plugin {
$dns_config = $app->getconf->get_server_config($conf["server_id"], 'dns');
//* Write the domain file
if(!empty($zone['id'])) {
if(!empty($data['new']['id'])) {
$tpl = new tpl();
$tpl->newTemplate("bind_pri.domain.master");
......
......@@ -80,7 +80,7 @@ class mail_plugin {
global $app, $conf;
//* get the config
$app->uses("getconf");
$app->uses("getconf,system");
$mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail');
// convert to lower case - it could cause problems if some directory above has upper case name
......@@ -103,7 +103,7 @@ class mail_plugin {
// Dovecot uses a different mail layout with a separate 'Maildir' subdirectory.
if($mail_config['pop3_imap_daemon'] == 'dovecot') {
exec("su -c 'mkdir -p ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
$app->log('Created Directory: '.$base_path,LOGLEVEL_DEBUG);
$app->log('Created Directory: '.$maildomain_path,LOGLEVEL_DEBUG);
$maildomain_path .= '/Maildir';
}
......@@ -116,23 +116,28 @@ class mail_plugin {
//* Create the maildir, if it doesn not exist, set permissions, set quota.
if(!empty($maildomain_path) && !is_dir($maildomain_path)) {
exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
//exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name']);
if(!is_dir($data['new']['maildir'].'/.Sent')) {
exec("su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
$app->log('Created submaildir Sent: '."su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
//exec("su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
//$app->log('Created submaildir Sent: '."su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name'],'Sent');
}
if(!is_dir($data['new']['maildir'].'/.Drafts')) {
exec("su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
$app->log('Created submaildir Drafts: '."su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
//exec("su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
//$app->log('Created submaildir Drafts: '."su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name'],'Drafts');
}
if(!is_dir($data['new']['maildir'].'/.Trash')) {
exec("su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
$app->log('Created submaildir Trash: '."su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
//exec("su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
//$app->log('Created submaildir Trash: '."su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name'],'Trash');
}
if(!is_dir($data['new']['maildir'].'/.Junk')) {
exec("su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
$app->log('Created submaildir Junk: '."su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
//exec("su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
//$app->log('Created submaildir Junk: '."su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name'],'Junk');
}
exec('chown -R '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir']));
......@@ -156,7 +161,7 @@ class mail_plugin {
global $app, $conf;
// get the config
$app->uses("getconf");
$app->uses("getconf,system");
$mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail');
// convert to lower case - it could cause problems if some directory above has upper case name
......@@ -198,24 +203,29 @@ class mail_plugin {
//* Create the maildir, if it doesn not exist, set permissions, set quota.
if(!empty($maildomain_path) && !is_dir($maildomain_path.'/new')) {
exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
$app->log("Created Maildir "."su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
//exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
//$app->log("Created Maildir "."su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name']);
if(!is_dir($data['new']['maildir'].'/.Sent')) {
exec("su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
$app->log('Created submaildir Sent: '."su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
//exec("su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
//$app->log('Created submaildir Sent: '."su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name'],'Sent');
}
if(!is_dir($data['new']['maildir'].'/.Drafts')) {
exec("su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
$app->log('Created submaildir Drafts: '."su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
//exec("su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
//$app->log('Created submaildir Drafts: '."su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name'],'Drafts');
}
if(!is_dir($data['new']['maildir'].'/.Trash')) {
exec("su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
$app->log('Created submaildir Trash: '."su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
//exec("su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);