Sophie

Sophie

sources > fail2ban > fail2ban-0.8.3-fd_cloexec.patch > 2bcafda229e925185e691185ca8c6dbb
Prev Next
diff -Naur fail2ban-0.8.3/server/filter.py fail2ban-0.8.3.tpg/server/filter.py
--- fail2ban-0.8.3/server/filter.py	2008-05-19 21:05:54.000000000 +0000
+++ fail2ban-0.8.3.tpg/server/filter.py	2009-07-26 18:17:04.000000000 +0000
@@ -428,6 +428,7 @@
 # is computed and compared to the previous hash of this line.
 
 import md5
+import fcntl
 
 class FileContainer:
 	
@@ -455,6 +456,11 @@
 	
 	def open(self):
 		self.__handler = open(self.__filename)
+
+		# Set the file descriptor to be FD_CLOEXEC
+		fd = self.__handler.fileno()
+		fcntl.fcntl (self.__handler.fileno(), fcntl.F_SETFD, fd | fcntl.FD_CLOEXEC)
+
 		firstLine = self.__handler.readline()
 		# Computes the MD5 of the first line.
 		myHash = md5.new(firstLine).digest()