Add missing banaction_allports setting to update settings function

This commit is contained in:
2025-12-04 19:57:58 +01:00
parent 13704df994
commit 0f2a3a1e32
2 changed files with 35 additions and 13 deletions

View File

@@ -793,22 +793,23 @@ settings = {
'banaction_allports': banaction_allports_val
}
# Check if file already has our banner
has_banner = False
# Check if file already has our full banner (indicating it's already properly structured)
has_full_banner = False
has_action_mwlg = False
has_action_override = False
try:
with open(jail_file, 'r') as f:
content = f.read()
has_banner = 'Fail2Ban-UI' in content or 'fail2ban-ui' in content
# Check for the complete banner pattern with hash line separators
has_full_banner = '################################################################################' in content and 'Fail2Ban-UI Managed Configuration' in content and 'DO NOT EDIT THIS FILE MANUALLY' in content
has_action_mwlg = 'action_mwlg' in content and 'ui-custom-action' in content
has_action_override = 'action = %%(action_mwlg)s' in content
except FileNotFoundError:
pass
# If already properly structured, just update DEFAULT section
if has_banner and has_action_mwlg and has_action_override:
if has_full_banner and has_action_mwlg and has_action_override:
try:
with open(jail_file, 'r') as f:
lines = f.readlines()
@@ -862,6 +863,8 @@ if has_banner and has_action_mwlg and has_action_override:
('findtime', 'findtime = ' + settings['findtime']),
('maxretry', 'maxretry = ' + str(settings['maxretry'])),
('destemail', 'destemail = ' + settings['destemail']),
('banaction', 'banaction = ' + settings['banaction']),
('banaction_allports', 'banaction_allports = ' + settings['banaction_allports']),
]:
if key not in keys_updated:
for i, output_line in enumerate(output_lines):