Skip to content

Commit 8788d2f

Browse files
author
Marius Burkard
committed
Merge branch '6027-rspamd-redis-server-and-password-fields' into 'develop'
Resolve "rspamd: redis server and password fields" Closes #6085 and #6027 See merge request ispconfig/ispconfig3!1410
2 parents ab11c0b + 6d9d4c5 commit 8788d2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

39 files changed

+391
-47
lines changed

install/lib/installer_base.lib.php

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,33 +1831,48 @@ public function configure_rspamd() {
18311831
fclose($fps);
18321832
unset($dkim_domains);
18331833

1834-
# local.d templates with template tags
1835-
$tpl = new tpl();
1836-
$tpl->newTemplate('rspamd_dkim_signing.conf.master');
1837-
$tpl->setVar('dkim_path', $mail_config['dkim_path']);
1838-
wf('/etc/rspamd/local.d/dkim_signing.conf', $tpl->grab());
1839-
1840-
$tpl = new tpl();
1841-
$tpl->newTemplate('rspamd_options.inc.master');
1842-
1834+
# look up values for use in template tags
18431835
$local_addrs = array();
18441836
$ips = $this->db->queryAllRecords('SELECT `ip_address`, `ip_type` FROM ?? WHERE `server_id` = ?', $conf['mysql']['database'].'.server_ip', $conf['server_id']);
18451837
if(is_array($ips) && !empty($ips)){
18461838
foreach($ips as $ip){
1847-
$local_addrs[] = array('quoted_ip' => "\"".$ip['ip_address']."\",\n");
1839+
$local_addrs[] = array(
1840+
'ip' => $ip['ip_address'],
1841+
'quoted_ip' => "\"".$ip['ip_address']."\",\n"
1842+
);
1843+
}
1844+
}
1845+
1846+
# local.d templates with template tags
1847+
# note: ensure these template files are in server/conf/ and symlinked in install/tpl/
1848+
$local_d = array(
1849+
'dkim_signing.conf',
1850+
'options.inc',
1851+
'redis.conf',
1852+
'classifier-bayes.conf',
1853+
);
1854+
foreach ($local_d as $f) {
1855+
$tpl = new tpl();
1856+
$tpl->newTemplate("rspamd_${f}.master");
1857+
1858+
$tpl->setVar('dkim_path', $mail_config['dkim_path']);
1859+
$tpl->setVar('rspamd_redis_servers', $mail_config['rspamd_redis_servers']);
1860+
$tpl->setVar('rspamd_redis_password', $mail_config['rspamd_redis_password']);
1861+
$tpl->setVar('rspamd_redis_bayes_servers', $mail_config['rspamd_redis_bayes_servers']);
1862+
$tpl->setVar('rspamd_redis_bayes_password', $mail_config['rspamd_redis_bayes_password']);
1863+
if(count($local_addrs) > 0) {
1864+
$tpl->setLoop('local_addrs', $local_addrs);
18481865
}
1866+
1867+
wf("/etc/rspamd/local.d/${f}", $tpl->grab());
18491868
}
1850-
$tpl->setLoop('local_addrs', $local_addrs);
1851-
wf('/etc/rspamd/local.d/options.inc', $tpl->grab());
1869+
18521870

18531871
# local.d templates without template tags
18541872
$local_d = array(
18551873
'groups.conf',
18561874
'antivirus.conf',
1857-
'classifier-bayes.conf',
1858-
'greylist.conf',
18591875
'mx_check.conf',
1860-
'redis.conf',
18611876
'milter_headers.conf',
18621877
'neural.conf',
18631878
'neural_group.conf',
@@ -1900,8 +1915,15 @@ public function configure_rspamd() {
19001915
}
19011916
}
19021917

1918+
# rename rspamd templates we no longer use
1919+
if(file_exists("/etc/rspamd/local.d/greylist.conf")) {
1920+
rename("/etc/rspamd/local.d/greylist.conf", "/etc/rspamd/local.d/greylist.old");
1921+
}
19031922

19041923
exec('chmod a+r /etc/rspamd/local.d/* /etc/rspamd/local.d/maps.d/* /etc/rspamd/override.d/*');
1924+
# protect passwords in these files
1925+
exec('chgrp _rspamd /etc/rspamd/local.d/redis.conf /etc/rspamd/local.d/classifier-bayes.conf /etc/rspamd/local.d/worker-controller.inc');
1926+
exec('chmod 640 /etc/rspamd/local.d/redis.conf /etc/rspamd/local.d/classifier-bayes.conf /etc/rspamd/local.d/worker-controller.inc');
19051927

19061928
# unneccesary, since this was done above?
19071929
$command = 'usermod -a -G amavis _rspamd';

install/tpl/rspamd_classifier-bayes.conf.master

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../server/conf/rspamd_classifier-bayes.conf.master

install/tpl/rspamd_dkim_signing.conf.master

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../server/conf/rspamd_dkim_signing.conf.master

install/tpl/rspamd_greylist.conf.master

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
enabled = true;
2-
servers = "localhost";
32
key_prefix = "rmx";
43
symbol_bad_mx = "MX_INVALID";
54
symbol_no_mx = "MX_MISSING";
65
symbol_good_mx = "MX_GOOD";
76
expire = 86400;
87
expire_novalid = 7200;
9-
greylist_invalid = false;
8+
greylist_invalid = false;

install/tpl/rspamd_neural.conf.master

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
servers = 127.0.0.1:6379;
21
enabled = true;
32

43
rules {
@@ -28,4 +27,4 @@ rules {
2827
symbol_ham = "NEURAL_HAM_SHORT";
2928
ann_expire = 1d;
3029
}
31-
}
30+
}

install/tpl/rspamd_redis.conf.master

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../server/conf/rspamd_redis.conf.master

0 commit comments

Comments
 (0)