mirror of
https://github.com/webmin/webmin.git
synced 2026-01-16 15:06:07 +00:00
We should always use `[Definition]` to add changes, with defaults simply hardcode rather than populated from the `[DEFAULT] section. This is how at least it was originally implemented. Initial feature created in response to: https://forum.virtualmin.com/t/change-fail2ban-times/124311/3?u=ilia This fix triggered by: https://forum.virtualmin.com/t/fail2ban-intrusion-detector-firewalld-default-jail-options/133201/13?u=ilia
46 lines
1.2 KiB
Perl
Executable File
46 lines
1.2 KiB
Perl
Executable File
#!/usr/local/bin/perl
|
|
# Save global config options
|
|
|
|
use strict;
|
|
use warnings;
|
|
no warnings 'redefine';
|
|
no warnings 'uninitialized';
|
|
require './fail2ban-lib.pl';
|
|
our (%in, %text, %config);
|
|
&ReadParse();
|
|
&error_setup($text{'config_err'});
|
|
|
|
my $conf = &get_config();
|
|
my ($def) = grep { $_->{'name'} eq 'Definition' } @$conf;
|
|
$def || &error($text{'config_edef'});
|
|
|
|
# Validate inputs
|
|
if ($in{'logtarget_def'} eq 'file') {
|
|
$in{'logtarget'} =~ /^\/\S+$/ || &error($text{'config_elogtarget'});
|
|
}
|
|
if (!$in{'socket_def'}) {
|
|
$in{'socket'} =~ /^\/\S+$/ || &error($text{'config_esocket'});
|
|
}
|
|
|
|
# Update config file
|
|
&lock_all_config_files();
|
|
|
|
&save_directive("loglevel", $in{'loglevel'}, $def);
|
|
&save_directive("logtarget",
|
|
$in{'logtarget_def'} eq '' ? undef :
|
|
$in{'logtarget_def'} eq 'file' ? $in{'logtarget'} :
|
|
$in{'logtarget_def'}, $def);
|
|
&save_directive("socket", $in{'socket_def'} ? undef : $in{'socket'}, $def);
|
|
if ($def) {
|
|
my $time = $in{'dbpurgeage'} == 1 ? 86400 :
|
|
$in{'dbpurgeage'} == 2 ?
|
|
$in{'dbpurgeagecus'} : $in{'dbpurgeagesel'};
|
|
my $conf_time_error = &time_to_seconds_error($time);
|
|
&error($conf_time_error) if ($conf_time_error);
|
|
&save_directive("dbpurgeage", $time, $def);
|
|
}
|
|
|
|
&unlock_all_config_files();
|
|
&webmin_log("config");
|
|
&redirect("");
|