From ee3c787cc68f6d043c8702c8f53a566277e2ee02 Mon Sep 17 00:00:00 2001 From: sebres Date: Fri, 13 Jan 2017 19:06:17 +0100 Subject: [PATCH 1/7] Recognize restored (from database) tickets after restart (tell action restored state of the ticket); Prevent executing of several actions (e.g. mail, send-mail etc) on restart (bans were already notified). Test cases extended (smtp and by restart in ServerReloadTest). Closes gh-1141 Closes gh-921 --- config/action.d/complain.conf | 3 +- config/action.d/dshield.conf | 10 ++++- config/action.d/helpers-common.conf | 3 ++ config/action.d/mail-buffered.conf | 8 +++- config/action.d/mail-whois-lines.conf | 4 +- config/action.d/mail-whois.conf | 4 +- config/action.d/mail.conf | 7 +++- config/action.d/sendmail-buffered.conf | 4 +- config/action.d/sendmail-geoip-lines.conf | 3 +- .../sendmail-whois-ipjailmatches.conf | 4 +- config/action.d/sendmail-whois-ipmatches.conf | 4 +- config/action.d/sendmail-whois-lines.conf | 3 +- config/action.d/sendmail-whois-matches.conf | 4 +- config/action.d/sendmail-whois.conf | 4 +- config/action.d/sendmail.conf | 4 +- config/action.d/smtp.py | 2 + config/action.d/xarf-login-attack.conf | 7 +++- fail2ban/server/action.py | 4 +- fail2ban/server/actions.py | 4 ++ fail2ban/tests/action_d/test_smtp.py | 15 ++++++- fail2ban/tests/fail2banclienttestcase.py | 42 +++++++++++++++---- 21 files changed, 114 insertions(+), 29 deletions(-) diff --git a/config/action.d/complain.conf b/config/action.d/complain.conf index e4ceb35f..d0156a44 100644 --- a/config/action.d/complain.conf +++ b/config/action.d/complain.conf @@ -58,7 +58,8 @@ actioncheck = # Tags: See jail.conf(5) man page # Values: CMD # -actionban = oifs=${IFS}; +actionban = %(_bypass_if_restored)s + oifs=${IFS}; IFS=.; SEP_IP=( ); set -- ${SEP_IP}; ADDRESSES=$(dig +short -t txt -q $4.$3.$2.$1.abuse-contacts.abusix.org); IFS=,; ADDRESSES=$(echo $ADDRESSES) IFS=${oifs} diff --git a/config/action.d/dshield.conf b/config/action.d/dshield.conf index a0041986..35eaa3be 100644 --- a/config/action.d/dshield.conf +++ b/config/action.d/dshield.conf @@ -26,6 +26,10 @@ # configure how often the buffer is flushed). # +[INCLUDES] + +before = helpers-common.conf + [Definition] # Option: actionstart @@ -64,7 +68,8 @@ actioncheck = # few seconds out, are incorrect. See # http://sourceforge.net/tracker/index.php?func=detail&aid=2017795&group_id=121032&atid=689047 # -actionban = TZONE=`date +%%z | sed 's/\([+-]..\)\(..\)/\1:\2/'` +actionban = %(_bypass_if_restored)s + TZONE=`date +%%z | sed 's/\([+-]..\)\(..\)/\1:\2/'` DATETIME="`perl -e '@t=localtime(