for f2bjail in $(fail2ban-client status ...); do
if fail2ban-client get $f2bjail actions | grep -Eq "^hestia-$chain"; then
fail2ban-client set $f2bjail unbanip <ip> # ← recursion
fi
done
which makes unblock IP very slow and timeout when run from fail2ban (while CLI and webui is ok to do its job to clear the ban)
Cause:
PR #5139:
loop: v-delete-firewall-ban - fail2ban itself runs the script, that loop re-enters fail2ban → the deadlock
for f2bjail in $("$f2bcli" status | grep -i 'Jail list:' | cut -d':' -f2- | sed -E 's/\s*//g' | tr ',' ' '); do
if "$f2bcli" get "$f2bjail" actions | grep -Eq "^hestia-$chain" 2> /dev/null; then
"$f2bcli" set "$f2bjail" unbanip "$sip" &> /dev/null
fi
done
$ipv4_cidr should be used instead of $sip? because $sip is an escaped value only applicable to sed line but should not be used in fail2ban unban action
I am testing with my revised code code. It just add a IF wrapping the loop, and also fix the escaped CIDR fixing. Then apply the guard on hestia.local at fail2ban action.d folder to merge to exisitng one
Do a compare with the original and it’s a simple fix.
But I am not sure if there are anything i overlook, so seeking for devs to review. Also I dont know how to add those upgrade sh script as well
I’ll take a look to understand what this does and how it works. Once validated, you can open a PR, and if any changes are required during the Hestia upgrade, I’ll add a commit to take care of them.
Basically, the process is to create or modify the upgrade script for the next Hestia version, for example, install/upgrade/versions/1.10.5.sh, and add the required changes there. This could include checking whether Fail2Ban is installed, modifying the actions, restarting or reloading the service, etc.
I’ve been checking it, and it looks good so far (I need to do more tests), but as I said, it looks good.
Regarding the actions, I would keep the Hestia comment, use the full paths for the flock and env commands, and remove the init section. You should not add a 30 seconds timeout to Fail2Ban if flock already has a 30 seconds timeout. As I said, I would remove the init section, and Fail2Ban will use the default timeout of 60 seconds.
Thanks @sahsanu for reviewing. During the study, v-update-firewall is also risky when being triggered at the same time with ban/unban actions. I’ve put the fix together with the above (also changed the lock file name to cover the whole finding better)