mirror of https://github.com/fail2ban/fail2ban
BF: use hashlib instead of deprecated md5
Bugfix revision. Fixes bug 260337,283629,301139,315073,343955. Thanks to Robert Trace <bugzilla-gentoo@farcaster.org>, Harley Peters <harley@thepetersclan.com> 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\=markuppull/8/head
parent
5812abb987
commit
492d8e5ff8
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue