diff --git a/install/dist/conf/centos70.conf.php b/install/dist/conf/centos70.conf.php index 90c19bfdbe3c9ca07c6144d116e37f27fe896efc..08afc5441ef22ca2bd24868b94c6cc7e32afa55d 100644 --- a/install/dist/conf/centos70.conf.php +++ b/install/dist/conf/centos70.conf.php @@ -129,6 +129,11 @@ $conf['amavis']['installed'] = false; // will be detected automatically during i $conf['amavis']['config_dir'] = '/etc/amavisd'; $conf['amavis']['init_script'] = 'amavisd'; +//* Rspamd +$conf['rspamd']['installed'] = false; // will be detected automatically during installation +$conf['rspamd']['config_dir'] = '/etc/rspamd'; +$conf['rspamd']['init_script'] = 'rspamd'; + //* ClamAV $conf['clamav']['installed'] = false; // will be detected automatically during installation $conf['clamav']['init_script'] = 'clamd@amavisd'; diff --git a/install/dist/conf/centos72.conf.php b/install/dist/conf/centos72.conf.php index 76257cff85a3fb636e02197aea48c0db2fddfbaf..a0b118308108f4897d29569fcf639977e0a97a4b 100644 --- a/install/dist/conf/centos72.conf.php +++ b/install/dist/conf/centos72.conf.php @@ -129,6 +129,11 @@ $conf['amavis']['installed'] = false; // will be detected automatically during i $conf['amavis']['config_dir'] = '/etc/amavisd'; $conf['amavis']['init_script'] = 'amavisd'; +//* Rspamd +$conf['rspamd']['installed'] = false; // will be detected automatically during installation +$conf['rspamd']['config_dir'] = '/etc/rspamd'; +$conf['rspamd']['init_script'] = 'rspamd'; + //* ClamAV $conf['clamav']['installed'] = false; // will be detected automatically during installation $conf['clamav']['init_script'] = 'clamd@amavisd'; diff --git a/install/dist/conf/debian40.conf.php b/install/dist/conf/debian40.conf.php index 797f9fa4a4cc902a6b88b51eb6a4e6473fa21ae9..c2eb4953380b47b814ac7b4beb6d1da3b258e991 100644 --- a/install/dist/conf/debian40.conf.php +++ b/install/dist/conf/debian40.conf.php @@ -129,6 +129,11 @@ $conf['amavis']['installed'] = false; // will be detected automatically during i $conf['amavis']['config_dir'] = '/etc/amavis'; $conf['amavis']['init_script'] = 'amavis'; +//* Rspamd +$conf['rspamd']['installed'] = false; // will be detected automatically during installation +$conf['rspamd']['config_dir'] = '/etc/rspamd'; +$conf['rspamd']['init_script'] = 'rspamd'; + //* ClamAV $conf['clamav']['installed'] = false; // will be detected automatically during installation $conf['clamav']['init_script'] = 'clamav-daemon'; diff --git a/install/dist/conf/debian60.conf.php b/install/dist/conf/debian60.conf.php index 71d849bc594e27aada2a23e98f4fe1f2afd92063..09356dbe1824d28e1fd74eaaeff46d64ab95cc4d 100644 --- a/install/dist/conf/debian60.conf.php +++ b/install/dist/conf/debian60.conf.php @@ -129,6 +129,11 @@ $conf['amavis']['installed'] = false; // will be detected automatically during i $conf['amavis']['config_dir'] = '/etc/amavis'; $conf['amavis']['init_script'] = 'amavis'; +//* Rspamd +$conf['rspamd']['installed'] = false; // will be detected automatically during installation +$conf['rspamd']['config_dir'] = '/etc/rspamd'; +$conf['rspamd']['init_script'] = 'rspamd'; + //* ClamAV $conf['clamav']['installed'] = false; // will be detected automatically during installation $conf['clamav']['init_script'] = 'clamav-daemon'; diff --git a/install/dist/conf/debian90.conf.php b/install/dist/conf/debian90.conf.php index 29f723e858ea72c17991cdfab5f966c2621da58f..a92ed1049b275ec09dead63ccad659215366154a 100644 --- a/install/dist/conf/debian90.conf.php +++ b/install/dist/conf/debian90.conf.php @@ -129,6 +129,11 @@ $conf['amavis']['installed'] = false; // will be detected automatically during i $conf['amavis']['config_dir'] = '/etc/amavis'; $conf['amavis']['init_script'] = 'amavis'; +//* Rspamd +$conf['rspamd']['installed'] = false; // will be detected automatically during installation +$conf['rspamd']['config_dir'] = '/etc/rspamd'; +$conf['rspamd']['init_script'] = 'rspamd'; + //* ClamAV $conf['clamav']['installed'] = false; // will be detected automatically during installation $conf['clamav']['init_script'] = 'clamav-daemon'; diff --git a/install/dist/conf/debiantesting.conf.php b/install/dist/conf/debiantesting.conf.php index 927bad8001672ed8107ecf9f5bc875738e8034e6..350be08cb5e52e773a2a7cce4db4fc846a02ff03 100644 --- a/install/dist/conf/debiantesting.conf.php +++ b/install/dist/conf/debiantesting.conf.php @@ -129,6 +129,11 @@ $conf['amavis']['installed'] = false; // will be detected automatically during i $conf['amavis']['config_dir'] = '/etc/amavis'; $conf['amavis']['init_script'] = 'amavis'; +//* Rspamd +$conf['rspamd']['installed'] = false; // will be detected automatically during installation +$conf['rspamd']['config_dir'] = '/etc/rspamd'; +$conf['rspamd']['init_script'] = 'rspamd'; + //* ClamAV $conf['clamav']['installed'] = false; // will be detected automatically during installation $conf['clamav']['init_script'] = 'clamav-daemon'; diff --git a/install/dist/conf/fedora9.conf.php b/install/dist/conf/fedora9.conf.php index 8eba03845887e4e7746995e22dbe00aa811d764d..46f3da03ce06a894dc8dfe94cb06475d70c945f2 100644 --- a/install/dist/conf/fedora9.conf.php +++ b/install/dist/conf/fedora9.conf.php @@ -129,6 +129,11 @@ $conf['amavis']['installed'] = false; // will be detected automatically during i $conf['amavis']['config_dir'] = '/etc/amavisd'; $conf['amavis']['init_script'] = 'amavisd'; +//* Rspamd +$conf['rspamd']['installed'] = false; // will be detected automatically during installation +$conf['rspamd']['config_dir'] = '/etc/rspamd'; +$conf['rspamd']['init_script'] = 'rspamd'; + //* ClamAV $conf['clamav']['installed'] = false; // will be detected automatically during installation $conf['clamav']['init_script'] = 'clamd.amavisd'; diff --git a/install/dist/conf/gentoo.conf.php b/install/dist/conf/gentoo.conf.php index 2d07ae9bcce0e54d6905f095415f53d22d41829f..15ecefb6c34ff6897777a73279d31382f145b72c 100644 --- a/install/dist/conf/gentoo.conf.php +++ b/install/dist/conf/gentoo.conf.php @@ -140,6 +140,11 @@ $conf['amavis']['installed'] = false; // will be detected automatically during i $conf['amavis']['config_file'] = '/etc/amavisd.conf'; $conf['amavis']['init_script'] = 'amavisd'; +//* Rspamd +$conf['rspamd']['installed'] = false; // will be detected automatically during installation +$conf['rspamd']['config_dir'] = '/etc/rspamd'; +$conf['rspamd']['init_script'] = 'rspamd'; + //* ClamAV $conf['clamav']['installed'] = false; // will be detected automatically during installation $conf['clamav']['init_script'] = 'clamd'; diff --git a/install/dist/conf/opensuse112.conf.php b/install/dist/conf/opensuse112.conf.php index 13d06a64a8878fe7fa755afc80b13b661ec695cc..12b5748fbe9714cb8c05e9adec322d554233e07e 100644 --- a/install/dist/conf/opensuse112.conf.php +++ b/install/dist/conf/opensuse112.conf.php @@ -129,6 +129,11 @@ $conf['amavis']['installed'] = false; // will be detected automatically during i $conf['amavis']['config_dir'] = '/etc'; $conf['amavis']['init_script'] = 'amavis'; +//* Rspamd +$conf['rspamd']['installed'] = false; // will be detected automatically during installation +$conf['rspamd']['config_dir'] = '/etc/rspamd'; +$conf['rspamd']['init_script'] = 'rspamd'; + //* ClamAV $conf['clamav']['installed'] = false; // will be detected automatically during installation $conf['clamav']['init_script'] = 'clamd'; diff --git a/install/dist/conf/ubuntu1604.conf.php b/install/dist/conf/ubuntu1604.conf.php index 2b0e1f7842ef7b0975af71077af8236bfe32a1d6..afa0ea7c94bc6843e52e3906761c7e3600bfee67 100644 --- a/install/dist/conf/ubuntu1604.conf.php +++ b/install/dist/conf/ubuntu1604.conf.php @@ -129,6 +129,11 @@ $conf['amavis']['installed'] = false; // will be detected automatically during i $conf['amavis']['config_dir'] = '/etc/amavis'; $conf['amavis']['init_script'] = 'amavis'; +//* Rspamd +$conf['rspamd']['installed'] = false; // will be detected automatically during installation +$conf['rspamd']['config_dir'] = '/etc/rspamd'; +$conf['rspamd']['init_script'] = 'rspamd'; + //* ClamAV $conf['clamav']['installed'] = false; // will be detected automatically during installation $conf['clamav']['init_script'] = 'clamav-daemon'; diff --git a/install/dist/conf/ubuntu1710.conf.php b/install/dist/conf/ubuntu1710.conf.php index d33267bb73be0cdb74bee0d965da7e32b59f22e2..2a4c364f740174c27907493ba8eb95f7edf8e5b6 100644 --- a/install/dist/conf/ubuntu1710.conf.php +++ b/install/dist/conf/ubuntu1710.conf.php @@ -129,6 +129,11 @@ $conf['amavis']['installed'] = false; // will be detected automatically during i $conf['amavis']['config_dir'] = '/etc/amavis'; $conf['amavis']['init_script'] = 'amavis'; +//* Rspamd +$conf['rspamd']['installed'] = false; // will be detected automatically during installation +$conf['rspamd']['config_dir'] = '/etc/rspamd'; +$conf['rspamd']['init_script'] = 'rspamd'; + //* ClamAV $conf['clamav']['installed'] = false; // will be detected automatically during installation $conf['clamav']['init_script'] = 'clamav-daemon'; diff --git a/install/dist/conf/ubuntu1804.conf.php b/install/dist/conf/ubuntu1804.conf.php index 1f13a1e3ed2040e737a67831b623f53405e71c22..d7eb1972db97529943fcac854471fbf0b1de2f19 100644 --- a/install/dist/conf/ubuntu1804.conf.php +++ b/install/dist/conf/ubuntu1804.conf.php @@ -129,6 +129,11 @@ $conf['amavis']['installed'] = false; // will be detected automatically during i $conf['amavis']['config_dir'] = '/etc/amavis'; $conf['amavis']['init_script'] = 'amavis'; +//* Rspamd +$conf['rspamd']['installed'] = false; // will be detected automatically during installation +$conf['rspamd']['config_dir'] = '/etc/rspamd'; +$conf['rspamd']['init_script'] = 'rspamd'; + //* ClamAV $conf['clamav']['installed'] = false; // will be detected automatically during installation $conf['clamav']['init_script'] = 'clamav-daemon'; diff --git a/install/dist/lib/debian60.lib.php b/install/dist/lib/debian60.lib.php index 730058f6e77d499dec6a23dcf7455ff1eba26bb7..69d9758b3d1731c89a071588071be6057c9c3878 100644 --- a/install/dist/lib/debian60.lib.php +++ b/install/dist/lib/debian60.lib.php @@ -68,7 +68,6 @@ class installer extends installer_base { } //* Reconfigure postfix to use dovecot authentication - // Adding the amavisd commands to the postfix configuration $postconf_commands = array ( 'dovecot_destination_recipient_limit = 1', 'virtual_transport = '.$virtual_transport, diff --git a/install/dist/lib/fedora.lib.php b/install/dist/lib/fedora.lib.php index a6b23e38422c51580c12af7163bf0298f8e3c244..88da3fb0ddae1cc59f0c0d46b795ca0d8c8291a5 100644 --- a/install/dist/lib/fedora.lib.php +++ b/install/dist/lib/fedora.lib.php @@ -319,7 +319,6 @@ class installer_dist extends installer_base { } //* Reconfigure postfix to use dovecot authentication - // Adding the amavisd commands to the postfix configuration $postconf_commands = array ( 'dovecot_destination_recipient_limit = 1', 'virtual_transport = '.$virtual_transport, diff --git a/install/install.php b/install/install.php index 934d595a5dc785b2f61454e541b40b4e229dcd6c..2d1e294c8035a4689d75111512ff704632aeaff0 100644 --- a/install/install.php +++ b/install/install.php @@ -99,7 +99,7 @@ require_once 'lib/classes/tpl.inc.php'; die('We will stop here. There is already a ISPConfig installation, use the update script to update this installation.'); }*/ -// Patch is required to reapir latest amavis versions +// Patch is required to repair latest amavis versions if(is_installed('amavisd-new') && !is_installed('patch')) die('The patch command is missing. Install patch command and start installation again.'); //** Get distribution identifier @@ -362,6 +362,12 @@ if($install_mode == 'standard' || strtolower($inst->simple_query('Configure Mail $inst->configure_amavis(); } + //* Configure Rspamd + $force = @($conf['rspamd']['installed']) ? true : $inst->force_configure_app('Rspamd', ($install_mode == 'expert')); + if($force) { + swriteln('Configuring Rspamd'); + $inst->configure_rspamd(); + } //* Configure Getmail $force = @($conf['getmail']['installed']) ? true : $inst->force_configure_app('Getmail', ($install_mode == 'expert')); if($force) { @@ -561,6 +567,7 @@ swriteln('Restarting services ...'); if($conf['mysql']['installed'] == true && $conf['mysql']['init_script'] != '') system($inst->getinitcommand($conf['mysql']['init_script'], 'restart').' >/dev/null 2>&1'); if($conf['postfix']['installed'] == true && $conf['postfix']['init_script'] != '') system($inst->getinitcommand($conf['postfix']['init_script'], 'restart')); if($conf['amavis']['installed'] == true && $conf['amavis']['init_script'] != '') system($inst->getinitcommand($conf['amavis']['init_script'], 'restart')); +if($conf['rspamd']['installed'] == true && $conf['rspamd']['init_script'] != '') system($inst->getinitcommand($conf['rspamd']['init_script'], 'restart')); if($conf['clamav']['installed'] == true && $conf['clamav']['init_script'] != '') system($inst->getinitcommand($conf['clamav']['init_script'], 'restart')); if($conf['dovecot']['installed'] == true && $conf['dovecot']['init_script'] != '') system($inst->getinitcommand($conf['dovecot']['init_script'], 'restart')); if($conf['apache']['installed'] == true && $conf['apache']['init_script'] != '') system($inst->getinitcommand($conf['apache']['init_script'], 'restart')); diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index f25c4eb1f2460b7db45f093eec25012a9d692e12..81656057809d2939d5f1a15647f28863b469216e 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -158,6 +158,7 @@ class installer_base { if(is_installed('getmail')) $conf['getmail']['installed'] = true; if(is_installed('dovecot')) $conf['dovecot']['installed'] = true; if(is_installed('amavisd-new') || is_installed('amavisd')) $conf['amavis']['installed'] = true; + if(is_installed('rspamd')) $conf['rspamd']['installed'] = true; if(is_installed('clamdscan')) $conf['clamav']['installed'] = true; if(is_installed('pure-ftpd') || is_installed('pure-ftpd-wrapper')) $conf['pureftpd']['installed'] = true; if(is_installed('mydns') || is_installed('mydns-ng')) $conf['mydns']['installed'] = true; @@ -1033,7 +1034,6 @@ class installer_base { } //* Reconfigure postfix to use dovecot authentication - // Adding the amavisd commands to the postfix configuration $postconf_commands = array ( 'dovecot_destination_recipient_limit = 1', 'virtual_transport = '.$virtual_transport, @@ -1211,6 +1211,159 @@ class installer_base { if(!empty($amavis_group)) exec('chgrp -R '.$amavis_group.' /var/lib/amavis/dkim'); } + + public function configure_rspamd() { + global $conf; + + //* These postconf commands will be executed on installation and update + $server_ini_rec = $this->db->queryOneRecord("SELECT config FROM ?? WHERE server_id = ?", $conf["mysql"]["database"] . '.server', $conf['server_id']); + $server_ini_array = ini_to_array(stripslashes($server_ini_rec['config'])); + unset($server_ini_rec); + + $mail_config = $server_ini_array['mail']; + if($mail_config['content_filter'] === 'rspamd') { + exec("postconf -X 'receive_override_options'"); + exec("postconf -X 'content_filter'"); + + exec("postconf -e 'smtpd_milters = inet:localhost:11332'"); + exec("postconf -e 'non_smtpd_milters = inet:localhost:11332'"); + exec("postconf -e 'milter_protocol = 6'"); + exec("postconf -e 'milter_mail_macros = i {mail_addr} {client_addr} {client_name} {auth_authen}'"); + exec("postconf -e 'milter_default_action = accept'"); + + exec("postconf -e 'smtpd_sender_restrictions = check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf, permit_mynetworks, permit_sasl_authenticated'"); + + $new_options = array(); + $options = preg_split("/,\s*/", exec("postconf -h smtpd_recipient_restrictions")); + foreach ($options as $value) { + if (!preg_match('/check_policy_service\s+inet:127.0.0.1:10023/', $value)) { + $new_options[] = $value; + } + } + exec("postconf -e 'smtpd_recipient_restrictions = ".implode(", ", $new_options)."'"); + } + + if(!is_dir('/etc/rspamd/local.d/')){ + mkdir('/etc/rspamd/local.d/', 0755, true); + } + + if(!is_dir('/etc/rspamd/override.d/')){ + mkdir('/etc/rspamd/override.d/', 0755, true); + } + + $tpl = new tpl(); + $tpl->newTemplate('rspamd_users.conf.master'); + + $whitelist_ips = array(); + $ips = $this->db->queryAllRecords("SELECT * FROM server_ip WHERE server_id = ?", $conf['server_id']); + if(is_array($ips) && !empty($ips)){ + foreach($ips as $ip){ + $whitelist_ips[] = array('ip' => $ip['ip_address']); + } + } + $tpl->setLoop('whitelist_ips', $whitelist_ips); + wf('/etc/rspamd/local.d/users.conf', $tpl->grab()); + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd_groups.conf.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_groups.conf.master /etc/rspamd/local.d/groups.conf'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd_groups.conf.master /etc/rspamd/local.d/groups.conf'); + } + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd_antivirus.conf.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_antivirus.conf.master /etc/rspamd/local.d/antivirus.conf'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd_antivirus.conf.master /etc/rspamd/local.d/antivirus.conf'); + } + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd_classifier-bayes.conf.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_classifier-bayes.conf.master /etc/rspamd/local.d/classifier-bayes.conf'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd_classifier-bayes.conf.master /etc/rspamd/local.d/classifier-bayes.conf'); + } + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd_greylist.conf.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_greylist.conf.master /etc/rspamd/local.d/greylist.conf'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd_greylist.conf.master /etc/rspamd/local.d/greylist.conf'); + } + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd_symbols_antivirus.conf.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_symbols_antivirus.conf.master /etc/rspamd/local.d/antivirus_group.conf'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd_symbols_antivirus.conf.master /etc/rspamd/local.d/antivirus_group.conf'); + } + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd_override_rbl.conf.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_override_rbl.conf.master /etc/rspamd/override.d/rbl_group.conf'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd_override_rbl.conf.master /etc/rspamd/override.d/rbl_group.conf'); + } + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd_override_surbl.conf.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_override_surbl.conf.master /etc/rspamd/override.d/surbl_group.conf'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd_override_surbl.conf.master /etc/rspamd/override.d/surbl_group.conf'); + } + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd_mx_check.conf.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_mx_check.conf.master /etc/rspamd/local.d/mx_check.conf'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd_mx_check.conf.master /etc/rspamd/local.d/mx_check.conf'); + } + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd_redis.conf.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_redis.conf.master /etc/rspamd/local.d/redis.conf'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd_redis.conf.master /etc/rspamd/local.d/redis.conf'); + } + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd_milter_headers.conf.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_milter_headers.conf.master /etc/rspamd/local.d/milter_headers.conf'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd_milter_headers.conf.master /etc/rspamd/local.d/milter_headers.conf'); + } + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd_options.inc.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_options.inc.master /etc/rspamd/local.d/options.inc'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd_options.inc.master /etc/rspamd/local.d/options.inc'); + } + + exec('chmod a+r /etc/rspamd/local.d/* /etc/rspamd/override.d/*'); + + $tpl = new tpl(); + $tpl->newTemplate('rspamd_dkim_signing.conf.master'); + $tpl->setVar('dkim_path', $mail_config['dkim_path']); + wf('/etc/rspamd/local.d/dkim_signing.conf', $tpl->grab()); + + $command = 'usermod -a -G amavis _rspamd'; + caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); + + if(strpos(rf('/etc/rspamd/rspamd.conf'), '.include "$LOCAL_CONFDIR/local.d/users.conf"') === false){ + af('/etc/rspamd/rspamd.conf', '.include "$LOCAL_CONFDIR/local.d/users.conf"'); + } + + if(!isset($mail_config['rspamd_password']) || !$mail_config['rspamd_password']) { + $mail_config['rspamd_password'] = str_shuffle(bin2hex(openssl_random_pseudo_bytes(12))); + + $server_ini_array['mail']['rspamd_password'] = $mail_config['rspamd_password']; + } + + $server_ini_array['mail']['rspamd_available'] = 'y'; + $server_ini_string = array_to_ini($server_ini_array); + if($this->dbmaster != $this->db) { + $this->dbmaster->query('UPDATE `server` SET `config` = ? WHERE `server_id` = ?', $server_ini_string, $conf['server_id']); + } + $this->db->query('UPDATE `server` SET `config` = ? WHERE `server_id` = ?', $server_ini_string, $conf['server_id']); + unset($server_ini_array); + unset($server_ini_string); + + $tpl = new tpl(); + $tpl->newTemplate('rspamd_worker-controller.inc.master'); + $tpl->setVar('rspamd_password', $mail_config['rspamd_password']); + wf('/etc/rspamd/local.d/worker-controller.inc', $tpl->grab()); + } public function configure_spamassassin() { global $conf; diff --git a/install/update.php b/install/update.php index a282289312d31037f6401abe26762a6f59d32ced..6b271516e3aebfb3da2f9cbea114d126a6cd7f86 100644 --- a/install/update.php +++ b/install/update.php @@ -98,7 +98,7 @@ if(is_dir('/root/ispconfig') || is_dir('/home/admispconfig')) { die('This software cannot be installed on a server wich runs ISPConfig 2.x.'); } -// Patch is required to reapir latest amavis versions +// Patch is required to repair latest amavis versions if(is_installed('amavisd-new') && !is_installed('patch')) die('The patch command is missing. Install patch command and start update again.'); //** Get distribution identifier @@ -380,6 +380,12 @@ if($reconfigure_services_answer == 'yes' || $reconfigure_services_answer == 'sel $inst->configure_amavis(); } + //** Configure Rspamd + if($conf['rspamd']['installed'] == true && $inst->reconfigure_app('Rspamd', $reconfigure_services_answer)) { + swriteln('Configuring Rspamd'); + $inst->configure_rspamd(); + } + //** Configure Getmail if ($inst->reconfigure_app('Getmail', $reconfigure_services_answer)) { swriteln('Configuring Getmail'); @@ -507,6 +513,7 @@ if($reconfigure_services_answer == 'yes') { if($conf['services']['mail']) { if($conf['postfix']['installed'] == true && $conf['postfix']['init_script'] != '') system($inst->getinitcommand($conf['postfix']['init_script'], 'restart')); if($conf['amavis']['installed'] == true && $conf['amavis']['init_script'] != '') system($inst->getinitcommand($conf['amavis']['init_script'], 'restart')); + if($conf['rspamd']['installed'] == true && $conf['rspamd']['init_script'] != '') system($inst->getinitcommand($conf['rspamd']['init_script'], 'restart')); if($conf['clamav']['installed'] == true && $conf['clamav']['init_script'] != '') system($inst->getinitcommand($conf['clamav']['init_script'], 'restart')); if($conf['dovecot']['installed'] == true && $conf['dovecot']['init_script'] != '') system($inst->getinitcommand($conf['dovecot']['init_script'], 'restart')); } diff --git a/interface/web/admin/form/server_config.tform.php b/interface/web/admin/form/server_config.tform.php index 9c48d72d0ddfbed82ce2acd45d68414b85a27a12..a5eb6dc06444d6a179aba1875a01870b0bc05f72 100644 --- a/interface/web/admin/form/server_config.tform.php +++ b/interface/web/admin/form/server_config.tform.php @@ -1911,4 +1911,10 @@ $form["tabs"]['rescue'] = array( //################################# ) ); -?> + +$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); +if(!isset($mail_config['rspamd_available']) || $mail_config['rspamd_available'] != 'y') { + $form['tabs']['mail']['fields']['content_filter']['default'] = 'amavisd'; + unset($form['tabs']['mail']['fields']['content_filter']['value']['rspamd']); + unset($form['tabs']['mail']['fields']['rspamd_password']); +} \ No newline at end of file diff --git a/server/plugins-available/postfix_server_plugin.inc.php b/server/plugins-available/postfix_server_plugin.inc.php index bcb7d1592041089667284e2b04d2ecc2dc08b989..1d500c8bcf6a127a90628d8c976383ef27e08dd0 100644 --- a/server/plugins-available/postfix_server_plugin.inc.php +++ b/server/plugins-available/postfix_server_plugin.inc.php @@ -62,10 +62,6 @@ class postfix_server_plugin { $app->plugins->registerEvent('server_insert', $this->plugin_name, 'insert'); $app->plugins->registerEvent('server_update', $this->plugin_name, 'update'); - - $app->plugins->registerEvent('server_ip_insert', $this->plugin_name, 'server_ip'); - $app->plugins->registerEvent('server_ip_update', $this->plugin_name, 'server_ip'); - $app->plugins->registerEvent('server_ip_delete', $this->plugin_name, 'server_ip'); } function insert($event_name, $data) { @@ -204,104 +200,6 @@ class postfix_server_plugin { } } exec("postconf -e 'smtpd_recipient_restrictions = ".implode(", ", $new_options)."'"); - - if(!is_dir('/etc/rspamd/local.d/')){ - $app->system->mkdirpath('/etc/rspamd/local.d/'); - } - - if(!is_dir('/etc/rspamd/override.d/')){ - $app->system->mkdirpath('/etc/rspamd/override.d/'); - } - - $this->server_ip($event_name, $data); - - if(file_exists($conf['rootpath'].'/conf-custom/rspamd_groups.conf.master')) { - exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_groups.conf.master /etc/rspamd/local.d/groups.conf'); - } else { - exec('cp '.$conf['rootpath'].'/conf/rspamd_groups.conf.master /etc/rspamd/local.d/groups.conf'); - } - - if(file_exists($conf['rootpath'].'/conf-custom/rspamd_antivirus.conf.master')) { - exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_antivirus.conf.master /etc/rspamd/local.d/antivirus.conf'); - } else { - exec('cp '.$conf['rootpath'].'/conf/rspamd_antivirus.conf.master /etc/rspamd/local.d/antivirus.conf'); - } - - if(file_exists($conf['rootpath'].'/conf-custom/rspamd_classifier-bayes.conf.master')) { - exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_classifier-bayes.conf.master /etc/rspamd/local.d/classifier-bayes.conf'); - } else { - exec('cp '.$conf['rootpath'].'/conf/rspamd_classifier-bayes.conf.master /etc/rspamd/local.d/classifier-bayes.conf'); - } - - if(file_exists($conf['rootpath'].'/conf-custom/rspamd_greylist.conf.master')) { - exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_greylist.conf.master /etc/rspamd/local.d/greylist.conf'); - } else { - exec('cp '.$conf['rootpath'].'/conf/rspamd_greylist.conf.master /etc/rspamd/local.d/greylist.conf'); - } - - if(file_exists($conf['rootpath'].'/conf-custom/rspamd_symbols_antivirus.conf.master')) { - exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_symbols_antivirus.conf.master /etc/rspamd/local.d/antivirus_group.conf'); - } else { - exec('cp '.$conf['rootpath'].'/conf/rspamd_symbols_antivirus.conf.master /etc/rspamd/local.d/antivirus_group.conf'); - } - - if(file_exists($conf['rootpath'].'/conf-custom/rspamd_override_rbl.conf.master')) { - exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_override_rbl.conf.master /etc/rspamd/override.d/rbl_group.conf'); - } else { - exec('cp '.$conf['rootpath'].'/conf/rspamd_override_rbl.conf.master /etc/rspamd/override.d/rbl_group.conf'); - } - - if(file_exists($conf['rootpath'].'/conf-custom/rspamd_override_surbl.conf.master')) { - exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_override_surbl.conf.master /etc/rspamd/override.d/surbl_group.conf'); - } else { - exec('cp '.$conf['rootpath'].'/conf/rspamd_override_surbl.conf.master /etc/rspamd/override.d/surbl_group.conf'); - } - - if(file_exists($conf['rootpath'].'/conf-custom/rspamd_mx_check.conf.master')) { - exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_mx_check.conf.master /etc/rspamd/local.d/mx_check.conf'); - } else { - exec('cp '.$conf['rootpath'].'/conf/rspamd_mx_check.conf.master /etc/rspamd/local.d/mx_check.conf'); - } - - if(file_exists($conf['rootpath'].'/conf-custom/rspamd_redis.conf.master')) { - exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_redis.conf.master /etc/rspamd/local.d/redis.conf'); - } else { - exec('cp '.$conf['rootpath'].'/conf/rspamd_redis.conf.master /etc/rspamd/local.d/redis.conf'); - } - - if(file_exists($conf['rootpath'].'/conf-custom/rspamd_milter_headers.conf.master')) { - exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_milter_headers.conf.master /etc/rspamd/local.d/milter_headers.conf'); - } else { - exec('cp '.$conf['rootpath'].'/conf/rspamd_milter_headers.conf.master /etc/rspamd/local.d/milter_headers.conf'); - } - - if(file_exists($conf['rootpath'].'/conf-custom/rspamd_options.inc.master')) { - exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_options.inc.master /etc/rspamd/local.d/options.inc'); - } else { - exec('cp '.$conf['rootpath'].'/conf/rspamd_options.inc.master /etc/rspamd/local.d/options.inc'); - } - - /*if(file_exists($conf['rootpath'].'/conf-custom/rspamd.local.lua.master')) { - exec('cp '.$conf['rootpath'].'/conf-custom/rspamd.local.lua.master /etc/rspamd/rspamd.local.lua'); - } else { - exec('cp '.$conf['rootpath'].'/conf/rspamd.local.lua.master /etc/rspamd/rspamd.local.lua'); - }*/ - - exec('chmod a+r /etc/rspamd/local.d/* /etc/rspamd/override.d/*'); - - $tpl = new tpl(); - $tpl->newTemplate('rspamd_dkim_signing.conf.master'); - $tpl->setVar('dkim_path', $mail_config['dkim_path']); - $app->system->file_put_contents('/etc/rspamd/local.d/dkim_signing.conf', $tpl->grab()); - - $app->system->add_user_to_group('amavis', '_rspamd'); - - if(strpos($app->system->file_get_contents('/etc/rspamd/rspamd.conf'), '.include "$LOCAL_CONFDIR/local.d/users.conf"') === false){ - $app->uses('file'); - $app->file->af('/etc/rspamd/rspamd.conf', '.include "$LOCAL_CONFDIR/local.d/users.conf"'); - } - - if(is_file('/etc/init.d/rspamd')) $app->services->restartServiceDelayed('rspamd', 'reload'); } elseif($mail_config['content_filter'] == 'amavisd'){ exec("postconf -X 'smtpd_milters'"); exec("postconf -X 'milter_protocol'"); @@ -328,30 +226,4 @@ class postfix_server_plugin { $app->services->restartServiceDelayed('postfix', 'reload'); } - function server_ip($event_name, $data) { - global $app, $conf; - - // get the config - $app->uses("getconf,system"); - $app->load('tpl'); - - $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); - - if($mail_config['content_filter'] == 'rspamd'){ - $tpl = new tpl(); - $tpl->newTemplate('rspamd_users.conf.master'); - - $whitelist_ips = array(); - $ips = $app->db->queryAllRecords("SELECT * FROM server_ip WHERE server_id = ?", $conf['server_id']); - if(is_array($ips) && !empty($ips)){ - foreach($ips as $ip){ - $whitelist_ips[] = array('ip' => $ip['ip_address']); - } - } - $tpl->setLoop('whitelist_ips', $whitelist_ips); - $app->system->file_put_contents('/etc/rspamd/local.d/users.conf', $tpl->grab()); - - if(is_file('/etc/init.d/rspamd')) $app->services->restartServiceDelayed('rspamd', 'reload'); - } - } } // end class diff --git a/server/plugins-available/rspamd_plugin.inc.php b/server/plugins-available/rspamd_plugin.inc.php index e3fb16b800fc292949f9f899b5999462ea94288e..4b60b11ea0758167352822c3727b1dbecf07d50c 100644 --- a/server/plugins-available/rspamd_plugin.inc.php +++ b/server/plugins-available/rspamd_plugin.inc.php @@ -66,6 +66,11 @@ class rspamd_plugin { $app->plugins->registerEvent('spamfilter_wblist_insert', $this->plugin_name, 'spamfilter_wblist_insert'); $app->plugins->registerEvent('spamfilter_wblist_update', $this->plugin_name, 'spamfilter_wblist_update'); $app->plugins->registerEvent('spamfilter_wblist_delete', $this->plugin_name, 'spamfilter_wblist_delete'); + + //* server ip + $app->plugins->registerEvent('server_ip_insert', $this->plugin_name, 'server_ip'); + $app->plugins->registerEvent('server_ip_update', $this->plugin_name, 'server_ip'); + $app->plugins->registerEvent('server_ip_delete', $this->plugin_name, 'server_ip'); } function spamfilter_users_insert($event_name, $data) { @@ -206,5 +211,32 @@ class rspamd_plugin { } } + function server_ip($event_name, $data) { + global $app, $conf; + + // get the config + $app->uses("getconf,system"); + $app->load('tpl'); + + $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); + + if($mail_config['content_filter'] == 'rspamd'){ + $tpl = new tpl(); + $tpl->newTemplate('rspamd_users.conf.master'); + + $whitelist_ips = array(); + $ips = $app->db->queryAllRecords("SELECT * FROM server_ip WHERE server_id = ?", $conf['server_id']); + if(is_array($ips) && !empty($ips)){ + foreach($ips as $ip){ + $whitelist_ips[] = array('ip' => $ip['ip_address']); + } + } + $tpl->setLoop('whitelist_ips', $whitelist_ips); + $app->system->file_put_contents('/etc/rspamd/local.d/users.conf', $tpl->grab()); + + $app->services->restartServiceDelayed('rspamd', 'reload'); + } + } + } // end class ?> \ No newline at end of file