- Added "socket" option in "fail2ban.conf"

git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@407 a942ae1a-1317-0410-a47c-b1dcaea8d605
0.x
Cyril Jaquier 2006-10-09 18:05:13 +00:00
parent 7989e66270
commit c8fdabf001
4 changed files with 29 additions and 9 deletions

View File

@ -12,7 +12,8 @@ ver. 0.7.4 (2006/09/28) - beta
- Improved configuration files. Thanks to Yaroslav Halchenko - Improved configuration files. Thanks to Yaroslav Halchenko
- Added man page for "fail2ban-regex" - Added man page for "fail2ban-regex"
- Moved ban/unban messages from "info" level to "warn" - Moved ban/unban messages from "info" level to "warn"
- Added "-s" option to specify the socket path - Added "-s" option to specify the socket path and "socket"
option in "fail2ban.conf"
ver. 0.7.3 (2006/09/28) - beta ver. 0.7.3 (2006/09/28) - beta
---------- ----------

View File

@ -46,10 +46,16 @@ class Configurator:
def getBaseDir(self): def getBaseDir(self):
return ConfigReader.getBaseDir() return ConfigReader.getBaseDir()
def readAll(self): def readEarly(self):
self.__fail2ban.read() self.__fail2ban.read()
def readAll(self):
self.readEarly()
self.__jails.read() self.__jails.read()
def getEarlyOptions(self):
return self.__fail2ban.getEarlyOptions()
def getAllOptions(self): def getAllOptions(self):
self.__settings["general"] = self.__fail2ban.getOptions() self.__settings["general"] = self.__fail2ban.getOptions()
self.__settings["jails"] = self.__jails.getOptions() self.__settings["jails"] = self.__jails.getOptions()

View File

@ -38,6 +38,10 @@ class Fail2banReader(ConfigReader):
def read(self): def read(self):
ConfigReader.read(self, "fail2ban") ConfigReader.read(self, "fail2ban")
def getEarlyOptions(self):
opts = [["string", "socket", "/tmp/fail2ban.sock"]]
return ConfigReader.getOptions(self, "Definition", opts)
def getOptions(self): def getOptions(self):
opts = [["int", "loglevel", 1], opts = [["int", "loglevel", 1],
["string", "logtarget", "STDERR"]] ["string", "logtarget", "STDERR"]]

View File

@ -52,13 +52,14 @@ class Fail2banClient:
def __init__(self): def __init__(self):
self.__argv = None self.__argv = None
self.__stream = None self.__stream = None
self.__configurator = Configurator()
self.__conf = dict() self.__conf = dict()
self.__conf["conf"] = "/etc/fail2ban" self.__conf["conf"] = "/etc/fail2ban"
self.__conf["dump"] = False self.__conf["dump"] = False
self.__conf["force"] = False self.__conf["force"] = False
self.__conf["verbose"] = 2 self.__conf["verbose"] = 2
self.__conf["interactive"] = False self.__conf["interactive"] = False
self.__conf["socket"] = "/tmp/fail2ban.sock" self.__conf["socket"] = None
def dispVersion(self): def dispVersion(self):
print "Fail2Ban v" + version print "Fail2Ban v" + version
@ -273,6 +274,16 @@ class Fail2banClient:
stdout.setFormatter(formatter) stdout.setFormatter(formatter)
logSys.addHandler(stdout) logSys.addHandler(stdout)
# Set the configuration path
self.__configurator.setBaseDir(self.__conf["conf"])
# Set socket path
self.__configurator.readEarly()
socket = self.__configurator.getEarlyOptions()
if self.__conf["socket"] == None:
self.__conf["socket"] = socket["socket"]
logSys.warn("Using socket file " + self.__conf["socket"])
if self.__conf["dump"]: if self.__conf["dump"]:
self.__readConfig() self.__readConfig()
self.dumpConfig(self.__stream) self.dumpConfig(self.__stream)
@ -306,12 +317,10 @@ class Fail2banClient:
def __readConfig(self): def __readConfig(self):
# Read the configuration # Read the configuration
cfg = Configurator() self.__configurator.readAll()
cfg.setBaseDir(self.__conf["conf"]) self.__configurator.getAllOptions()
cfg.readAll() self.__configurator.convertToProtocol()
cfg.getAllOptions() self.__stream = self.__configurator.getConfigStream()
cfg.convertToProtocol()
self.__stream = cfg.getConfigStream()
@staticmethod @staticmethod
def dumpConfig(cmd): def dumpConfig(cmd):