backup rspamd configs in config-templates; add 'antispam' to valid_keys for config-json file; test existence of file in config-backup-function

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2024-01-05 16:52:40 +01:00
parent ba11b0ab7d
commit 734d6888c8
9 changed files with 29 additions and 32 deletions

View File

@@ -94,7 +94,7 @@ if ($userinfo['change_serversettings'] == '1') {
}
if ($distribution != "" && isset($_POST['finish'])) {
$valid_keys = ['http', 'dns', 'smtp', 'mail', 'ftp', 'system', 'distro'];
$valid_keys = ['http', 'dns', 'smtp', 'mail', 'antispam', 'ftp', 'system', 'distro'];
unset($_POST['finish']);
unset($_POST['csrf_token']);
$params = $_POST;

View File

@@ -24,7 +24,6 @@
*/
use Froxlor\Database\Database;
use Froxlor\FileDir;
use Froxlor\Froxlor;
use Froxlor\Install\Update;
use Froxlor\Settings;
@@ -36,7 +35,7 @@ if (!defined('_CRON_UPDATE')) {
}
}
if (Froxlor::isFroxlorVersion('2.1.x')) {
if (Froxlor::isFroxlorVersion('2.1.4')) {
Update::showUpdateStep("Enhancing virtual email table");
Database::query("ALTER TABLE `" . TABLE_MAIL_VIRTUAL . "` ADD `spam_tag_level` float(4,1) NOT NULL DEFAULT 7.0;");
Database::query("ALTER TABLE `" . TABLE_MAIL_VIRTUAL . "` ADD `spam_kill_level` float(4,1) NOT NULL DEFAULT 14.0;");
@@ -45,8 +44,9 @@ if (Froxlor::isFroxlorVersion('2.1.x')) {
Update::lastStepStatus(0);
Update::showUpdateStep("Adjusting settings");
Database::query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `settinggroup` = 'antispam', `varname` = 'activated' WHERE `settinggroup` = 'dkim' AND `varname` = 'use_dkim';");
Database::query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `settinggroup` = 'antispam', `varname` = 'reload_command' WHERE `settinggroup` = 'dkim' AND `varname` = 'dkimrestart_command';");
$antispam_activated = $_POST['antispam_activated'] ?? 0;
Database::query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `settinggroup` = 'antispam', `varname` = 'activated', `value` = '" . (int)$antispam_activated . "' WHERE `settinggroup` = 'dkim' AND `varname` = 'use_dkim';");
Database::query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `settinggroup` = 'antispam', `varname` = 'reload_command', `value` = 'service rspamd restart' WHERE `settinggroup` = 'dkim' AND `varname` = 'dkimrestart_command';");
Database::query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `settinggroup` = 'antispam', `varname` = 'config_file', `value` = '/etc/rspamd/local.d/froxlor_settings.conf' WHERE `settinggroup` = 'dkim' AND `varname` = 'dkim_prefix';");
Database::query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `settinggroup` = 'antispam' WHERE `settinggroup` = 'dkim' AND `varname` = 'dkim_keylength';");
Settings::AddNew("dmarc.use_dmarc", "0");
@@ -55,6 +55,7 @@ if (Froxlor::isFroxlorVersion('2.1.x')) {
Database::query("DELETE FROM `" . TABLE_PANEL_SETTINGS . "` WHERE `settinggroup` = 'dkim' AND `varname` = 'dkim_domains';");
Database::query("DELETE FROM `" . TABLE_PANEL_SETTINGS . "` WHERE `settinggroup` = 'dkim' AND `varname` = 'dkim_algorithm';");
Database::query("DELETE FROM `" . TABLE_PANEL_SETTINGS . "` WHERE `settinggroup` = 'dkim' AND `varname` = 'dkim_notes';");
Update::lastStepStatus(0);
$to_clean = [

View File

@@ -409,7 +409,7 @@ class ConfigDaemon
}
$return[] = [
'type' => 'command',
'content' => $cmd . ' "' . $this->parseContent($attributes['name']) . '" "' . $this->parseContent($attributes['name']) . '.frx.bak"',
'content' => '[ -f ' . $this->parseContent($attributes['name']) . ' ] && ' . $cmd . ' "' . $this->parseContent($attributes['name']) . '" "' . $this->parseContent($attributes['name']) . '.frx.bak"',
'execute' => "pre"
];
}

View File

@@ -137,7 +137,7 @@ class Settings
$configfile = Froxlor::getInstallDir() . '/lib/config.inc.php';
if (@file_exists($configfile) && is_readable($configfile)) {
self::$conf = include $configfile;
self::$conf = array_merge(self::$conf, include $configfile);
}
return true;
}

View File

@@ -2582,7 +2582,7 @@ plugin {
</commands>
<files index="1">
<file name="/etc/rspamd/local.d/actions.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
# Set rewrite subject to this value (%s is replaced by the original subject)
subject = "***SPAM*** %s"
@@ -2590,7 +2590,7 @@ subject = "***SPAM*** %s"
</content>
</file>
<file name="/etc/rspamd/local.d/arc.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
try_fallback = true;
### Enable DKIM signing for alias sender addresses
@@ -2601,7 +2601,7 @@ selector_map = "/etc/rspamd/dkim_selectors.map";
</content>
</file>
<file name="/etc/rspamd/local.d/milter_headers.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
use = ["x-spamd-bar", "x-spam-level", "authentication-results"];
authenticated_headers = ["authentication-results"];
@@ -2612,7 +2612,7 @@ skip_authenticated = false
</content>
</file>
<file name="/etc/rspamd/local.d/replies.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
## If a user has replied to an email, dont mark other emails in the same thread as spam
action = "no action";
@@ -2643,7 +2643,6 @@ action = "no action";
<command><![CDATA[postconf -e "smtpd_milters = inet:127.0.0.1:11332"]]></command>
<command><![CDATA[postconf -e "non_smtpd_milters = inet:127.0.0.1:11332"]]></command>
<command><![CDATA[chown -R _rspamd:_rspamd /var/lib/rspamd/dkim]]></command>
<command><![CDATA[chmod 440 /var/lib/rspamd/dkim/*]]></command>
<command><![CDATA[service rspamd restart]]></command>
<command><![CDATA[service postfix restart]]></command>
</commands>

View File

@@ -4152,7 +4152,7 @@ plugin {
</commands>
<files index="1">
<file name="/etc/rspamd/local.d/actions.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
# Set rewrite subject to this value (%s is replaced by the original subject)
subject = "***SPAM*** %s"
@@ -4160,7 +4160,7 @@ subject = "***SPAM*** %s"
</content>
</file>
<file name="/etc/rspamd/local.d/arc.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
try_fallback = true;
### Enable DKIM signing for alias sender addresses
@@ -4171,7 +4171,7 @@ selector_map = "/etc/rspamd/dkim_selectors.map";
</content>
</file>
<file name="/etc/rspamd/local.d/milter_headers.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
use = ["x-spamd-bar", "x-spam-level", "authentication-results"];
authenticated_headers = ["authentication-results"];
@@ -4182,7 +4182,7 @@ skip_authenticated = false
</content>
</file>
<file name="/etc/rspamd/local.d/replies.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
## If a user has replied to an email, dont mark other emails in the same thread as spam
action = "no action";
@@ -4213,7 +4213,6 @@ action = "no action";
<command><![CDATA[postconf -e "smtpd_milters = inet:127.0.0.1:11332"]]></command>
<command><![CDATA[postconf -e "non_smtpd_milters = inet:127.0.0.1:11332"]]></command>
<command><![CDATA[chown -R _rspamd:_rspamd /var/lib/rspamd/dkim]]></command>
<command><![CDATA[chmod 440 /var/lib/rspamd/dkim/*]]></command>
<command><![CDATA[service rspamd restart]]></command>
</commands>
</general>

View File

@@ -3375,7 +3375,7 @@ plugin {
</commands>
<files index="1">
<file name="/etc/rspamd/local.d/actions.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
# Set rewrite subject to this value (%s is replaced by the original subject)
subject = "***SPAM*** %s"
@@ -3383,7 +3383,7 @@ subject = "***SPAM*** %s"
</content>
</file>
<file name="/etc/rspamd/local.d/arc.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
try_fallback = true;
### Enable DKIM signing for alias sender addresses
@@ -3394,7 +3394,7 @@ selector_map = "/etc/rspamd/dkim_selectors.map";
</content>
</file>
<file name="/etc/rspamd/local.d/milter_headers.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
use = ["x-spamd-bar", "x-spam-level", "authentication-results"];
authenticated_headers = ["authentication-results"];
@@ -3405,7 +3405,7 @@ skip_authenticated = false
</content>
</file>
<file name="/etc/rspamd/local.d/replies.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
## If a user has replied to an email, dont mark other emails in the same thread as spam
action = "no action";
@@ -3436,7 +3436,6 @@ action = "no action";
<command><![CDATA[postconf -e "smtpd_milters = inet:127.0.0.1:11332"]]></command>
<command><![CDATA[postconf -e "non_smtpd_milters = inet:127.0.0.1:11332"]]></command>
<command><![CDATA[chown -R _rspamd:_rspamd /var/lib/rspamd/dkim]]></command>
<command><![CDATA[chmod 440 /var/lib/rspamd/dkim/*]]></command>
<command><![CDATA[service rspamd restart]]></command>
</commands>
</general>

View File

@@ -26,6 +26,7 @@
<default for="nginx" settinggroup="phpfpm" varname="fastcgi_ipcdir" value="/var/run/nginx/"></default>
<default settinggroup="system" varname="bindreload_command" value="/etc/init.d/named restart"></default>
<default settinggroup="system" varname="crondreload" value="/etc/init.d/cronie restart"></default>
<default settinggroup="antispam" varname="reload_command" value="/etc/init.d/rspamd restart"></default>
</defaults>
<services>
<!-- HTTP -->
@@ -2229,7 +2230,7 @@ plugin {
</commands>
<files index="1">
<file name="/etc/rspamd/local.d/actions.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
# Set rewrite subject to this value (%s is replaced by the original subject)
subject = "***SPAM*** %s"
@@ -2237,7 +2238,7 @@ subject = "***SPAM*** %s"
</content>
</file>
<file name="/etc/rspamd/local.d/arc.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
try_fallback = true;
### Enable DKIM signing for alias sender addresses
@@ -2248,7 +2249,7 @@ selector_map = "/etc/rspamd/dkim_selectors.map";
</content>
</file>
<file name="/etc/rspamd/local.d/milter_headers.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
use = ["x-spamd-bar", "x-spam-level", "authentication-results"];
authenticated_headers = ["authentication-results"];
@@ -2259,7 +2260,7 @@ skip_authenticated = false
</content>
</file>
<file name="/etc/rspamd/local.d/replies.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
## If a user has replied to an email, dont mark other emails in the same thread as spam
action = "no action";
@@ -2290,7 +2291,6 @@ action = "no action";
<command><![CDATA[postconf -e "smtpd_milters = inet:127.0.0.1:11332"]]></command>
<command><![CDATA[postconf -e "non_smtpd_milters = inet:127.0.0.1:11332"]]></command>
<command><![CDATA[chown -R _rspamd:_rspamd /var/lib/rspamd/dkim]]></command>
<command><![CDATA[chmod 440 /var/lib/rspamd/dkim/*]]></command>
<command><![CDATA[rc-update add rspamd default]]></command>
<command><![CDATA[/etc/init.d/rspamd restart]]></command>
</commands>

View File

@@ -3365,7 +3365,7 @@ plugin {
</commands>
<files index="1">
<file name="/etc/rspamd/local.d/actions.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
# Set rewrite subject to this value (%s is replaced by the original subject)
subject = "***SPAM*** %s"
@@ -3373,7 +3373,7 @@ subject = "***SPAM*** %s"
</content>
</file>
<file name="/etc/rspamd/local.d/arc.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
try_fallback = true;
### Enable DKIM signing for alias sender addresses
@@ -3384,7 +3384,7 @@ selector_map = "/etc/rspamd/dkim_selectors.map";
</content>
</file>
<file name="/etc/rspamd/local.d/milter_headers.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
use = ["x-spamd-bar", "x-spam-level", "authentication-results"];
authenticated_headers = ["authentication-results"];
@@ -3395,7 +3395,7 @@ skip_authenticated = false
</content>
</file>
<file name="/etc/rspamd/local.d/replies.conf"
chown="root:root" chmod="0644">
chown="root:root" chmod="0644" backup="true">
<content><![CDATA[
## If a user has replied to an email, dont mark other emails in the same thread as spam
action = "no action";
@@ -3426,7 +3426,6 @@ action = "no action";
<command><![CDATA[postconf -e "smtpd_milters = inet:127.0.0.1:11332"]]></command>
<command><![CDATA[postconf -e "non_smtpd_milters = inet:127.0.0.1:11332"]]></command>
<command><![CDATA[chown -R _rspamd:_rspamd /var/lib/rspamd/dkim]]></command>
<command><![CDATA[chmod 440 /var/lib/rspamd/dkim/*]]></command>
<command><![CDATA[service rspamd restart]]></command>
</commands>
</general>