mirror of https://github.com/fail2ban/fail2ban
Check for unicode and encode before md5sum in filter
parent
c926c88ea1
commit
99c92a56ca
|
@ -526,6 +526,9 @@ class FileContainer:
|
||||||
try:
|
try:
|
||||||
firstLine = handler.readline()
|
firstLine = handler.readline()
|
||||||
# Computes the MD5 of the first line.
|
# Computes the MD5 of the first line.
|
||||||
|
if isinstance(firstLine, unicode):
|
||||||
|
self.__hash = md5sum(firstLine.encode('utf-8')).digest()
|
||||||
|
else:
|
||||||
self.__hash = md5sum(firstLine).digest()
|
self.__hash = md5sum(firstLine).digest()
|
||||||
# Start at the beginning of file if tail mode is off.
|
# Start at the beginning of file if tail mode is off.
|
||||||
if tail:
|
if tail:
|
||||||
|
@ -546,6 +549,9 @@ class FileContainer:
|
||||||
fcntl.fcntl(fd, fcntl.F_SETFD, fd | fcntl.FD_CLOEXEC)
|
fcntl.fcntl(fd, fcntl.F_SETFD, fd | fcntl.FD_CLOEXEC)
|
||||||
firstLine = self.__handler.readline()
|
firstLine = self.__handler.readline()
|
||||||
# Computes the MD5 of the first line.
|
# Computes the MD5 of the first line.
|
||||||
|
if isinstance(firstLine, unicode):
|
||||||
|
myHash = md5sum(firstLine.encode('utf-8')).digest()
|
||||||
|
else:
|
||||||
myHash = md5sum(firstLine).digest()
|
myHash = md5sum(firstLine).digest()
|
||||||
stats = os.fstat(self.__handler.fileno())
|
stats = os.fstat(self.__handler.fileno())
|
||||||
# Compare hash and inode
|
# Compare hash and inode
|
||||||
|
|
Loading…
Reference in New Issue