mirror of https://github.com/fail2ban/fail2ban
ENH: issue a warning if jail name is longer than 19 symbols (Close #222)
parent
90b8433ac5
commit
571ff33fde
|
@ -140,6 +140,7 @@ else: # pragma: no cover
|
||||||
# Server
|
# Server
|
||||||
#tests.addTest(unittest.makeSuite(servertestcase.StartStop))
|
#tests.addTest(unittest.makeSuite(servertestcase.StartStop))
|
||||||
tests.addTest(unittest.makeSuite(servertestcase.Transmitter))
|
tests.addTest(unittest.makeSuite(servertestcase.Transmitter))
|
||||||
|
tests.addTest(unittest.makeSuite(servertestcase.JailTests))
|
||||||
tests.addTest(unittest.makeSuite(actiontestcase.ExecuteAction))
|
tests.addTest(unittest.makeSuite(actiontestcase.ExecuteAction))
|
||||||
# FailManager
|
# FailManager
|
||||||
tests.addTest(unittest.makeSuite(failmanagertestcase.AddFailure))
|
tests.addTest(unittest.makeSuite(failmanagertestcase.AddFailure))
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Jail:
|
||||||
_BACKENDS = ['pyinotify', 'gamin', 'polling']
|
_BACKENDS = ['pyinotify', 'gamin', 'polling']
|
||||||
|
|
||||||
def __init__(self, name, backend = "auto"):
|
def __init__(self, name, backend = "auto"):
|
||||||
self.__name = name
|
self.setName(name)
|
||||||
self.__queue = Queue.Queue()
|
self.__queue = Queue.Queue()
|
||||||
self.__filter = None
|
self.__filter = None
|
||||||
logSys.info("Creating new jail '%s'" % self.__name)
|
logSys.info("Creating new jail '%s'" % self.__name)
|
||||||
|
@ -102,6 +102,10 @@ class Jail:
|
||||||
self.__filter = FilterPyinotify(self)
|
self.__filter = FilterPyinotify(self)
|
||||||
|
|
||||||
def setName(self, name):
|
def setName(self, name):
|
||||||
|
if len(name) >= 20:
|
||||||
|
logSys.warning("Jail name %r might be too long and some commands "
|
||||||
|
"might not function correctly. Please shorten"
|
||||||
|
% name)
|
||||||
self.__name = name
|
self.__name = name
|
||||||
|
|
||||||
def getName(self):
|
def getName(self):
|
||||||
|
|
|
@ -26,6 +26,7 @@ __license__ = "GPL"
|
||||||
|
|
||||||
import unittest, socket, time, tempfile, os
|
import unittest, socket, time, tempfile, os
|
||||||
from server.server import Server
|
from server.server import Server
|
||||||
|
from server.jail import Jail
|
||||||
from common.exceptions import UnknownJailException
|
from common.exceptions import UnknownJailException
|
||||||
|
|
||||||
class StartStop(unittest.TestCase):
|
class StartStop(unittest.TestCase):
|
||||||
|
@ -507,3 +508,12 @@ class TransmitterLogging(TransmitterBase):
|
||||||
self.setGetTest("loglevel", "-1", -1)
|
self.setGetTest("loglevel", "-1", -1)
|
||||||
self.setGetTest("loglevel", "0", 0)
|
self.setGetTest("loglevel", "0", 0)
|
||||||
self.setGetTestNOK("loglevel", "Bird")
|
self.setGetTestNOK("loglevel", "Bird")
|
||||||
|
|
||||||
|
|
||||||
|
class JailTests(unittest.TestCase):
|
||||||
|
|
||||||
|
def testLongName(self):
|
||||||
|
# Just a smoke test for now
|
||||||
|
longname = "veryveryverylongname"
|
||||||
|
jail = Jail(longname)
|
||||||
|
self.assertEqual(jail.getName(), longname)
|
||||||
|
|
Loading…
Reference in New Issue