From da594075f3f59476ef055a6387634468fa839036 Mon Sep 17 00:00:00 2001 From: Alexander Dietrich Date: Tue, 2 Jul 2013 20:30:41 +0200 Subject: [PATCH 1/2] Move sendmail settings to common file, make sender name configurable --- config/action.d/sendmail-buffered.conf | 18 +++++++----------- config/action.d/sendmail-common.conf | 23 +++++++++++++++++++++++ config/action.d/sendmail-whois-lines.conf | 18 +++++++----------- config/action.d/sendmail-whois.conf | 18 +++++++----------- config/action.d/sendmail.conf | 18 +++++++----------- 5 files changed, 51 insertions(+), 44 deletions(-) create mode 100644 config/action.d/sendmail-common.conf diff --git a/config/action.d/sendmail-buffered.conf b/config/action.d/sendmail-buffered.conf index bec1e91c..f5ca6c10 100644 --- a/config/action.d/sendmail-buffered.conf +++ b/config/action.d/sendmail-buffered.conf @@ -4,6 +4,10 @@ # # +[INCLUDES] + +before = sendmail-common.conf + [Definition] # Option: actionstart @@ -11,7 +15,7 @@ # Values: CMD # actionstart = printf %%b "Subject: [Fail2Ban] : started - From: Fail2Ban <> + From: <> To: \n Hi,\n The jail has been started successfully.\n @@ -25,7 +29,7 @@ actionstart = printf %%b "Subject: [Fail2Ban] : started # actionstop = if [ -f ]; then printf %%b "Subject: [Fail2Ban] : summary - From: Fail2Ban <> + From: <> To: \n Hi,\n These hosts have been banned by Fail2Ban.\n @@ -58,7 +62,7 @@ actionban = printf %%b "`date`: ( failures)\n" >> LINE=$( wc -l | awk '{ print $1 }' ) if [ $LINE -ge ]; then printf %%b "Subject: [Fail2Ban] : summary - From: Fail2Ban <> + From: <> To: \n Hi,\n These hosts have been banned by Fail2Ban.\n @@ -82,14 +86,6 @@ actionunban = # name = default -# Destination/Addressee of the mail -# -dest = root - -# Sender of the mail -# -sender = fail2ban - # Default number of lines that are buffered # lines = 5 diff --git a/config/action.d/sendmail-common.conf b/config/action.d/sendmail-common.conf new file mode 100644 index 00000000..e2820470 --- /dev/null +++ b/config/action.d/sendmail-common.conf @@ -0,0 +1,23 @@ +# Fail2Ban configuration file +# +# Common settings for sendmail actions +# +# Users can override the defaults in sendmail-common.local + +[INCLUDES] + +after = sendmail-common.local + +[Init] + +# Recipient mail address +# +dest = root + +# Sender mail address +# +sender = fail2ban + +# Sender display name +# +sendername = Fail2Ban diff --git a/config/action.d/sendmail-whois-lines.conf b/config/action.d/sendmail-whois-lines.conf index bc5074c6..2cb27bd2 100644 --- a/config/action.d/sendmail-whois-lines.conf +++ b/config/action.d/sendmail-whois-lines.conf @@ -4,6 +4,10 @@ # # +[INCLUDES] + +before = sendmail-common.conf + [Definition] # Option: actionstart @@ -12,7 +16,7 @@ # actionstart = printf %%b "Subject: [Fail2Ban] : started Date: `LC_TIME=C date -u +"%%a, %%d %%h %%Y %%T +0000"` - From: Fail2Ban <> + From: <> To: \n Hi,\n The jail has been started successfully.\n @@ -25,7 +29,7 @@ actionstart = printf %%b "Subject: [Fail2Ban] : started # actionstop = printf %%b "Subject: [Fail2Ban] : stopped Date: `LC_TIME=C date -u +"%%a, %%d %%h %%Y %%T +0000"` - From: Fail2Ban <> + From: <> To: \n Hi,\n The jail has been stopped.\n @@ -46,7 +50,7 @@ actioncheck = # actionban = printf %%b "Subject: [Fail2Ban] : banned Date: `LC_TIME=C date -u +"%%a, %%d %%h %%Y %%T +0000"` - From: Fail2Ban <> + From: <> To: \n Hi,\n The IP has just been banned by Fail2Ban after @@ -72,14 +76,6 @@ actionunban = # name = default -# Destination/Addressee of the mail -# -dest = root - -# Sender of the mail -# -sender = fail2ban - # Path to the log files which contain relevant lines for the abuser IP # logpath = /dev/null diff --git a/config/action.d/sendmail-whois.conf b/config/action.d/sendmail-whois.conf index 0d1fd97e..b111e19f 100644 --- a/config/action.d/sendmail-whois.conf +++ b/config/action.d/sendmail-whois.conf @@ -4,6 +4,10 @@ # # +[INCLUDES] + +before = sendmail-common.conf + [Definition] # Option: actionstart @@ -12,7 +16,7 @@ # actionstart = printf %%b "Subject: [Fail2Ban] : started Date: `LC_TIME=C date -u +"%%a, %%d %%h %%Y %%T +0000"` - From: Fail2Ban <> + From: <> To: \n Hi,\n The jail has been started successfully.\n @@ -25,7 +29,7 @@ actionstart = printf %%b "Subject: [Fail2Ban] : started # actionstop = printf %%b "Subject: [Fail2Ban] : stopped Date: `LC_TIME=C date -u +"%%a, %%d %%h %%Y %%T +0000"` - From: Fail2Ban <> + From: <> To: \n Hi,\n The jail has been stopped.\n @@ -46,7 +50,7 @@ actioncheck = # actionban = printf %%b "Subject: [Fail2Ban] : banned Date: `LC_TIME=C date -u +"%%a, %%d %%h %%Y %%T +0000"` - From: Fail2Ban <> + From: <> To: \n Hi,\n The IP has just been banned by Fail2Ban after @@ -70,11 +74,3 @@ actionunban = # name = default -# Destination/Addressee of the mail -# -dest = root - -# Sender of the mail -# -sender = fail2ban - diff --git a/config/action.d/sendmail.conf b/config/action.d/sendmail.conf index 8054050d..55d388fc 100644 --- a/config/action.d/sendmail.conf +++ b/config/action.d/sendmail.conf @@ -4,6 +4,10 @@ # # +[INCLUDES] + +before = sendmail-common.conf + [Definition] # Option: actionstart @@ -12,7 +16,7 @@ # actionstart = printf %%b "Subject: [Fail2Ban] : started Date: `LC_TIME=C date -u +"%%a, %%d %%h %%Y %%T +0000"` - From: Fail2Ban <> + From: <> To: \n Hi,\n The jail has been started successfully.\n @@ -25,7 +29,7 @@ actionstart = printf %%b "Subject: [Fail2Ban] : started # actionstop = printf %%b "Subject: [Fail2Ban] : stopped Date: `LC_TIME=C date -u +"%%a, %%d %%h %%Y %%T +0000"` - From: Fail2Ban <> + From: <> To: \n Hi,\n The jail has been stopped.\n @@ -46,7 +50,7 @@ actioncheck = # actionban = printf %%b "Subject: [Fail2Ban] : banned Date: `LC_TIME=C date -u +"%%a, %%d %%h %%Y %%T +0000"` - From: Fail2Ban <> + From: <> To: \n Hi,\n The IP has just been banned by Fail2Ban after @@ -68,11 +72,3 @@ actionunban = # name = default -# Destination/Addressee of the mail -# -dest = root - -# Sender of the mail -# -sender = fail2ban - From 2155f6bfa58ed820d95ce50ce7488d6c43c31a20 Mon Sep 17 00:00:00 2001 From: Alexander Dietrich Date: Thu, 4 Jul 2013 08:57:52 +0200 Subject: [PATCH 2/2] Update ChangeLog and jail.conf example --- ChangeLog | 3 +++ config/jail.conf | 2 ++ 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 39c0a5aa..dd5426a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,9 @@ ver. 0.8.11 (2013/XX/XXX) - wanna-be-released * fail2ban-client -- log to standard error. Closes gh-264 * Fail to configure if not a single log file was found for an enabled jail. Closes gh-63 + Alexander Dietrich + * action.d/sendmail-common.conf -- added common sendmail settings file + and made the sender display name configurable ver. 0.8.10 (2013/06/12) - wanna-be-secure ----------- diff --git a/config/jail.conf b/config/jail.conf index c999cc7b..e4e7e5b0 100644 --- a/config/jail.conf +++ b/config/jail.conf @@ -66,6 +66,8 @@ enabled = false filter = sshd action = iptables[name=SSH, port=ssh, protocol=tcp] sendmail-whois[name=SSH, dest=you@example.com, sender=fail2ban@example.com] +# Alternative example: +# sendmail-whois[name=SSH, sendername="Fail2Ban - example.com"] logpath = /var/log/sshd.log maxretry = 5