File: 00_close_log.dpatch

package info (click to toggle)
fail2ban 0.7.5-2etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 620 kB
  • ctags: 754
  • sloc: python: 3,245; sh: 735; makefile: 43
file content (29 lines) | stat: -rw-r--r-- 1,087 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /bin/sh /usr/share/dpatch/dpatch-run
## 00_close_log.dpatch by Yaroslav Halchenko <debian@onerussian.com>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: post release patches

@DPATCH@
diff -urNad fail2ban~/server/server.py fail2ban/server/server.py
--- fail2ban~/server/server.py	2007-11-06 14:26:10.000000000 -0500
+++ fail2ban/server/server.py	2007-11-06 14:33:46.000000000 -0500
@@ -314,12 +314,17 @@
 			else:
 				# Target should be a file
 				try:
-					open(target, "a")
+					open(target, "a").close()
 					hdlr = logging.FileHandler(target)
 				except IOError:
 					logSys.error("Unable to log to " + target)
 					return False
 			self.__logTarget = target
+			# Removes previous handlers
+			for handler in logging.getLogger("fail2ban").handlers:
+				# Closes the handler.
+				handler.close()
+				logging.getLogger("fail2ban").removeHandler(handler)
 			# set a format which is simpler for console use
 			formatter = logging.Formatter("%(asctime)s %(name)-16s: %(levelname)-6s %(message)s")
 			# tell the handler to use this format