From 492d8e5ff889d55024a1403a4239649eb9fb46b9 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Fri, 18 Nov 2011 14:32:37 -0500 Subject: [PATCH] BF: use hashlib instead of deprecated md5 Bugfix revision. Fixes bug 260337,283629,301139,315073,343955. Thanks to Robert Trace , Harley Peters for the patches. Picked up from http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-analyzer/fail2ban/files/fail2ban-0.8.4-hashlib.patch\?view\=markup --- server/filter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/filter.py b/server/filter.py index 38151d90..d170709e 100644 --- a/server/filter.py +++ b/server/filter.py @@ -446,7 +446,7 @@ class FileFilter(Filter): # In order to detect log rotation, the hash (MD5) of the first line of the file # is computed and compared to the previous hash of this line. -import md5 +import hashlib class FileContainer: @@ -461,7 +461,7 @@ class FileContainer: try: firstLine = handler.readline() # Computes the MD5 of the first line. - self.__hash = md5.new(firstLine).digest() + self.__hash = hashlib.md5(firstLine).digest() # Start at the beginning of file if tail mode is off. if tail: handler.seek(0, 2) @@ -481,7 +481,7 @@ class FileContainer: fcntl.fcntl(fd, fcntl.F_SETFD, fd | fcntl.FD_CLOEXEC) firstLine = self.__handler.readline() # Computes the MD5 of the first line. - myHash = md5.new(firstLine).digest() + myHash = hashlib.md5(firstLine).digest() stats = os.fstat(self.__handler.fileno()) # Compare hash and inode if self.__hash != myHash or self.__ino != stats.st_ino: