mirror of https://github.com/fail2ban/fail2ban
jail configuration extended with new syntax to pass options to the backend (see gh-1408),
examples: - `backend = systemd[journalpath=/run/log/journal/machine-1]` - `backend = systemd[journalfiles="/run/log/journal/machine-1/system.journal, /run/log/journal/machine-1/user.journal"]` - `backend = systemd[journalflags=2]`pull/1523/head
parent
1c4733ef89
commit
7ed6cab120
|
@ -54,6 +54,11 @@ releases.
|
||||||
* New forward compatibility method assertRaisesRegexp (normally python >= 2.7).
|
* New forward compatibility method assertRaisesRegexp (normally python >= 2.7).
|
||||||
Methods assertIn, assertNotIn, assertRaisesRegexp, assertLogged, assertNotLogged
|
Methods assertIn, assertNotIn, assertRaisesRegexp, assertLogged, assertNotLogged
|
||||||
are test covered now
|
are test covered now
|
||||||
|
* Jail configuration extended with new syntax to pass options to the backend (see gh-1408),
|
||||||
|
examples:
|
||||||
|
- `backend = systemd[journalpath=/run/log/journal/machine-1]`
|
||||||
|
- `backend = systemd[journalfiles="/run/log/journal/machine-1/system.journal, /run/log/journal/machine-1/user.journal"]`
|
||||||
|
- `backend = systemd[journalflags=2]`
|
||||||
|
|
||||||
|
|
||||||
ver. 0.9.5 (2016/07/15) - old-not-obsolete
|
ver. 0.9.5 (2016/07/15) - old-not-obsolete
|
||||||
|
|
|
@ -27,6 +27,7 @@ import logging
|
||||||
import Queue
|
import Queue
|
||||||
|
|
||||||
from .actions import Actions
|
from .actions import Actions
|
||||||
|
from ..client.jailreader import JailReader
|
||||||
from ..helpers import getLogger
|
from ..helpers import getLogger
|
||||||
|
|
||||||
# Gets the instance of the logger.
|
# Gets the instance of the logger.
|
||||||
|
@ -82,6 +83,7 @@ class Jail:
|
||||||
return "%s(%r)" % (self.__class__.__name__, self.name)
|
return "%s(%r)" % (self.__class__.__name__, self.name)
|
||||||
|
|
||||||
def _setBackend(self, backend):
|
def _setBackend(self, backend):
|
||||||
|
backend, beArgs = JailReader.extractOptions(backend)
|
||||||
backend = backend.lower() # to assure consistent matching
|
backend = backend.lower() # to assure consistent matching
|
||||||
|
|
||||||
backends = self._BACKENDS
|
backends = self._BACKENDS
|
||||||
|
@ -98,7 +100,7 @@ class Jail:
|
||||||
for b in backends:
|
for b in backends:
|
||||||
initmethod = getattr(self, '_init%s' % b.capitalize())
|
initmethod = getattr(self, '_init%s' % b.capitalize())
|
||||||
try:
|
try:
|
||||||
initmethod()
|
initmethod(**beArgs)
|
||||||
if backend != 'auto' and b != backend:
|
if backend != 'auto' and b != backend:
|
||||||
logSys.warning("Could only initiated %r backend whenever "
|
logSys.warning("Could only initiated %r backend whenever "
|
||||||
"%r was requested" % (b, backend))
|
"%r was requested" % (b, backend))
|
||||||
|
@ -117,28 +119,28 @@ class Jail:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"Failed to initialize any backend for Jail %r" % self.name)
|
"Failed to initialize any backend for Jail %r" % self.name)
|
||||||
|
|
||||||
def _initPolling(self):
|
def _initPolling(self, **kwargs):
|
||||||
from filterpoll import FilterPoll
|
from filterpoll import FilterPoll
|
||||||
logSys.info("Jail '%s' uses poller" % self.name)
|
logSys.info("Jail '%s' uses poller %r" % (self.name, kwargs))
|
||||||
self.__filter = FilterPoll(self)
|
self.__filter = FilterPoll(self, **kwargs)
|
||||||
|
|
||||||
def _initGamin(self):
|
def _initGamin(self, **kwargs):
|
||||||
# Try to import gamin
|
# Try to import gamin
|
||||||
from filtergamin import FilterGamin
|
from filtergamin import FilterGamin
|
||||||
logSys.info("Jail '%s' uses Gamin" % self.name)
|
logSys.info("Jail '%s' uses Gamin %r" % (self.name, kwargs))
|
||||||
self.__filter = FilterGamin(self)
|
self.__filter = FilterGamin(self, **kwargs)
|
||||||
|
|
||||||
def _initPyinotify(self):
|
def _initPyinotify(self, **kwargs):
|
||||||
# Try to import pyinotify
|
# Try to import pyinotify
|
||||||
from filterpyinotify import FilterPyinotify
|
from filterpyinotify import FilterPyinotify
|
||||||
logSys.info("Jail '%s' uses pyinotify" % self.name)
|
logSys.info("Jail '%s' uses pyinotify %r" % (self.name, kwargs))
|
||||||
self.__filter = FilterPyinotify(self)
|
self.__filter = FilterPyinotify(self, **kwargs)
|
||||||
|
|
||||||
def _initSystemd(self): # pragma: systemd no cover
|
def _initSystemd(self, **kwargs): # pragma: systemd no cover
|
||||||
# Try to import systemd
|
# Try to import systemd
|
||||||
from filtersystemd import FilterSystemd
|
from filtersystemd import FilterSystemd
|
||||||
logSys.info("Jail '%s' uses systemd" % self.name)
|
logSys.info("Jail '%s' uses systemd %r" % (self.name, kwargs))
|
||||||
self.__filter = FilterSystemd(self)
|
self.__filter = FilterSystemd(self, **kwargs)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
Loading…
Reference in New Issue