Using a directory is fine, as long as it is used only once: because
mktemp verifies that the directory didn't exists before when creating
it, the same temporary directory name cannot be safely used after
removing it. But actionstop which removes the temporary directory
should be run only once when closing fail2ban. If the configuration is
reloaded, a new temporary directory will be created, which is good.
Patch untested :(
---
config/action.d/dshield.conf |5 +++--
config/action.d/mail-buffered.conf |4 +++-
config/action.d/mynetwatchman.conf |9 ++---
config/action.d/sendmail-buffered.conf |5 +++--
4 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/config/action.d/dshield.conf b/config/action.d/dshield.conf
index b80698b..8dba15f 100644
--- a/config/action.d/dshield.conf
+++ b/config/action.d/dshield.conf
@@ -44,6 +44,7 @@ actionstop = if [ -f .buffer ]; then
date +%%s > .lastsent
fi
rm -f .buffer .first
+ rmdir
# Option: actioncheck
# Notes.: command executed once before each actionban command
@@ -206,5 +207,5 @@ dest = repo...@dshield.org
# Notes.: Base name of temporary files used for buffering
# Values: [ STRING ] Default: /tmp/fail2ban-dshield
#
-tmpfile = /tmp/fail2ban-dshield
-
+tmpdir = `mktemp --directory --suffix=-f2ban-dshield`
+tmpfile = /dshield
diff --git a/config/action.d/mail-buffered.conf
b/config/action.d/mail-buffered.conf
index 8a33d0e..00b734f 100644
--- a/config/action.d/mail-buffered.conf
+++ b/config/action.d/mail-buffered.conf
@@ -29,6 +29,7 @@ actionstop = if [ -f ]; then
Fail2Ban"|mail -s "[Fail2Ban] : Summary"
rm
fi
+ rmdir
printf %%b "Hi,\n
The jail has been stopped.\n
Regards,\n
@@ -81,7 +82,8 @@ lines = 5
# Default temporary file
#
-tmpfile = /tmp/fail2ban-mail.txt
+tmpdir = `mktemp --directory --suffix=-f2ban-mail`
+tmpfile = /buffer.txt
# Destination/Addressee of the mail
#
diff --git a/config/action.d/mynetwatchman.conf
b/config/action.d/mynetwatchman.conf
index 15b91b1..9a1600f 100644
--- a/config/action.d/mynetwatchman.conf
+++ b/config/action.d/mynetwatchman.conf
@@ -66,7 +66,8 @@ actionban = MNWLOGIN=`perl -e
'$s=shift;$s=~s/([\W])/"%%".uc(sprintf("%%2.2x",or
PROTOCOL=`awk '{IGNORECASE=1;if($1==""){print $2;exit}}'
/etc/protocols`
if [ -z "$PROTOCOL" ]; then PROTOCOL=; fi
DATETIME=`perl -e '@t=gmtime();printf
"%%4d-%%02d-%%02d+%%02d:%%02d:%%02d",1900+$t[5],$t[4]+1,$t[3],$t[2],$t[1],$t[0]'`
-
"?AT=2&AV=0&AgentEmail=$MNWLOGIN&AgentPassword=$MNWPASS&AttackerIP=&SrcPort=&ProtocolID=$PROTOCOL&DestPort=&AttackCount=&VictimIP=&AttackDateTime=$DATETIME"
2>&1 >> .out && grep -q 'Attack Report Insert Successful'
.out && rm -f .out
+TMPFILE=`mktemp --suffix -f2ban-mynetwatchman.out`
+
"?AT=2&AV=0&AgentEmail=$MNWLOGIN&AgentPassword=$MNWPASS&AttackerIP=&SrcPort=&ProtocolID=$PROTOCOL&DestPort=&AttackCount=&VictimIP=&AttackDateTime=$DATETIME"
2>&1 >> "$TMPFILE" && grep -q 'Attack Report Insert Successful' "$TMPFILE" &&
rm -f "$TMPFILE"
# Option: actionunban
# Notes.: command executed when unbanning an IP. Take care that the
@@ -136,9 +137,3 @@ srcport = 0
# Values: STRING Default: http://mynetwatchman.com/insertwebreport.asp
#
mnwurl = http://mynetwatchman.com/insertwebreport.asp
-
-# Option: tmpfile
-# Notes.: Base name of temporary files
-# Values: [ STRING ] Default: /tmp/fail2ban-mynetwatchman
-#
-tmpfile = /tmp/fail2ban-mynetwatchman
diff --git a/config/action.d/sendmail-buffered.conf
b/config/action.d/sendmail-buffered.conf
index de8166a..3a4e950 100644
--- a/config/action.d/sendmail-buffered.conf
+++ b/config/action.d/sendmail-buffered.conf
@@ -35,6 +35,7 @@ actionstop = if [ -f ]; then
Fail2Ban" | /usr/sbin/sendmail -f
rm
fi
+ rmdir
printf %%b "Subject: [Fail2Ban] : stopped
From: Fail2Ban <>
To: \n
@@ -101,5 +102,5 @@ lines = 5
# Default temporary file
#
-tmpfile = /tmp/fail2ban-mail.txt
-
+tmpdir = `mktemp --directory --suffix=-f2ban-mail`
+tmpfile = /buffer.txt
--
1.6.4.124.g27bb1
--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org