mirror of https://github.com/fail2ban/fail2ban
commit
cf3a1c15a0
|
@ -45,7 +45,8 @@ class Beautifier:
|
||||||
return self.__inputCmd
|
return self.__inputCmd
|
||||||
|
|
||||||
def beautify(self, response):
|
def beautify(self, response):
|
||||||
logSys.debug("Beautify " + `response` + " with " + `self.__inputCmd`)
|
logSys.debug(
|
||||||
|
"Beautify " + repr(response) + " with " + repr(self.__inputCmd))
|
||||||
inC = self.__inputCmd
|
inC = self.__inputCmd
|
||||||
msg = response
|
msg = response
|
||||||
try:
|
try:
|
||||||
|
@ -102,7 +103,7 @@ class Beautifier:
|
||||||
elif response == 4:
|
elif response == 4:
|
||||||
msg = msg + "DEBUG"
|
msg = msg + "DEBUG"
|
||||||
else:
|
else:
|
||||||
msg = msg + `response`
|
msg = msg + repr(response)
|
||||||
elif inC[1] == "dbfile":
|
elif inC[1] == "dbfile":
|
||||||
if response is None:
|
if response is None:
|
||||||
msg = "Database currently disabled"
|
msg = "Database currently disabled"
|
||||||
|
@ -183,13 +184,14 @@ class Beautifier:
|
||||||
msg += ", ".join(response)
|
msg += ", ".join(response)
|
||||||
except Exception:
|
except Exception:
|
||||||
logSys.warning("Beautifier error. Please report the error")
|
logSys.warning("Beautifier error. Please report the error")
|
||||||
logSys.error("Beautify " + `response` + " with " + `self.__inputCmd` +
|
logSys.error("Beautify " + repr(response) + " with "
|
||||||
" failed")
|
+ repr(self.__inputCmd) + " failed")
|
||||||
msg = msg + `response`
|
msg = msg + repr(response)
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
def beautifyError(self, response):
|
def beautifyError(self, response):
|
||||||
logSys.debug("Beautify (error) " + `response` + " with " + `self.__inputCmd`)
|
logSys.debug("Beautify (error) " + repr(response) + " with "
|
||||||
|
+ repr(self.__inputCmd))
|
||||||
msg = response
|
msg = response
|
||||||
if isinstance(response, UnknownJailException):
|
if isinstance(response, UnknownJailException):
|
||||||
msg = "Sorry but the jail '" + response.args[0] + "' does not exist"
|
msg = "Sorry but the jail '" + response.args[0] + "' does not exist"
|
||||||
|
|
|
@ -233,7 +233,7 @@ class ConfigReaderUnshared(SafeConfigParserWithIncludes):
|
||||||
logSys.log(logLevel, "Non essential option '%s' not defined in '%s'.", option[1], sec)
|
logSys.log(logLevel, "Non essential option '%s' not defined in '%s'.", option[1], sec)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
logSys.warning("Wrong value for '" + option[1] + "' in '" + sec +
|
logSys.warning("Wrong value for '" + option[1] + "' in '" + sec +
|
||||||
"'. Using default one: '" + `option[2]` + "'")
|
"'. Using default one: '" + repr(option[2]) + "'")
|
||||||
values[option[1]] = option[2]
|
values[option[1]] = option[2]
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ class DefinitionInitConfigReader(ConfigReader):
|
||||||
|
|
||||||
if self.has_section("Init"):
|
if self.has_section("Init"):
|
||||||
for opt in self.options("Init"):
|
for opt in self.options("Init"):
|
||||||
if not self._initOpts.has_key(opt):
|
if not opt in self._initOpts:
|
||||||
self._initOpts[opt] = self.get("Init", opt)
|
self._initOpts[opt] = self.get("Init", opt)
|
||||||
|
|
||||||
def convert(self):
|
def convert(self):
|
||||||
|
|
|
@ -64,6 +64,6 @@ class CSocket:
|
||||||
while msg.rfind(CSocket.END_STRING) == -1:
|
while msg.rfind(CSocket.END_STRING) == -1:
|
||||||
chunk = sock.recv(6)
|
chunk = sock.recv(6)
|
||||||
if chunk == '':
|
if chunk == '':
|
||||||
raise RuntimeError, "socket connection broken"
|
raise RuntimeError("socket connection broken")
|
||||||
msg = msg + chunk
|
msg = msg + chunk
|
||||||
return loads(msg)
|
return loads(msg)
|
||||||
|
|
|
@ -406,7 +406,7 @@ class CommandAction(ActionBase):
|
||||||
# recursive definitions are bad
|
# recursive definitions are bad
|
||||||
#logSys.log(5, 'recursion fail tag: %s value: %s' % (tag, value) )
|
#logSys.log(5, 'recursion fail tag: %s value: %s' % (tag, value) )
|
||||||
return False
|
return False
|
||||||
if found_tag in cls._escapedTags or not tags.has_key(found_tag):
|
if found_tag in cls._escapedTags or not found_tag in tags:
|
||||||
# Escaped or missing tags - just continue on searching after end of match
|
# Escaped or missing tags - just continue on searching after end of match
|
||||||
# Missing tags are ok - cInfo can contain aInfo elements like <HOST> and valid shell
|
# Missing tags are ok - cInfo can contain aInfo elements like <HOST> and valid shell
|
||||||
# constructs like <STDIN>.
|
# constructs like <STDIN>.
|
||||||
|
|
|
@ -91,7 +91,7 @@ class FailManager:
|
||||||
ip = ticket.getIP()
|
ip = ticket.getIP()
|
||||||
unixTime = ticket.getTime()
|
unixTime = ticket.getTime()
|
||||||
matches = ticket.getMatches()
|
matches = ticket.getMatches()
|
||||||
if self.__failList.has_key(ip):
|
if ip in self.__failList:
|
||||||
fData = self.__failList[ip]
|
fData = self.__failList[ip]
|
||||||
if fData.getLastReset() < unixTime - self.__maxTime:
|
if fData.getLastReset() < unixTime - self.__maxTime:
|
||||||
fData.setLastReset(unixTime)
|
fData.setLastReset(unixTime)
|
||||||
|
@ -136,7 +136,7 @@ class FailManager:
|
||||||
self.__lock.release()
|
self.__lock.release()
|
||||||
|
|
||||||
def __delFailure(self, ip):
|
def __delFailure(self, ip):
|
||||||
if self.__failList.has_key(ip):
|
if ip in self.__failList:
|
||||||
del self.__failList[ip]
|
del self.__failList[ip]
|
||||||
|
|
||||||
def toBan(self):
|
def toBan(self):
|
||||||
|
|
|
@ -63,7 +63,7 @@ class FilterGamin(FileFilter):
|
||||||
|
|
||||||
|
|
||||||
def callback(self, path, event):
|
def callback(self, path, event):
|
||||||
logSys.debug("Got event: " + `event` + " for " + path)
|
logSys.debug("Got event: " + repr(event) + " for " + path)
|
||||||
if event in (gamin.GAMCreated, gamin.GAMChanged, gamin.GAMExists):
|
if event in (gamin.GAMCreated, gamin.GAMChanged, gamin.GAMExists):
|
||||||
logSys.debug("File changed: " + path)
|
logSys.debug("File changed: " + path)
|
||||||
self.__modified = True
|
self.__modified = True
|
||||||
|
|
|
@ -51,7 +51,7 @@ class Transmitter:
|
||||||
|
|
||||||
def proceed(self, command):
|
def proceed(self, command):
|
||||||
# Deserialize object
|
# Deserialize object
|
||||||
logSys.debug("Command: " + `command`)
|
logSys.debug("Command: " + repr(command))
|
||||||
try:
|
try:
|
||||||
ret = self.__commandHandler(command)
|
ret = self.__commandHandler(command)
|
||||||
ack = 0, ret
|
ack = 0, ret
|
||||||
|
|
Loading…
Reference in New Issue