示例#1
0
	def getOptions(self, section=None):
		"""Reads configuration for jail(s) and adds enabled jails to __jails
		"""
		opts = []
		self.__opts = ConfigReader.getOptions(self, "Definition", opts)

		if section is None:
			sections = self.sections()
		else:
			sections = [ section ]

		# Get the options of all jails.
		parse_status = True
		for sec in sections:
			jail = JailReader(sec, basedir=self.getBaseDir(),
							  force_enable=self.__force_enable)
			jail.read()
			ret = jail.getOptions()
			if ret:
				if jail.isEnabled():
					# We only add enabled jails
					self.__jails.append(jail)
			else:
				logSys.error("Errors in jail %r. Skipping..." % sec)
				parse_status = False
		return parse_status
示例#2
0
    def getOptions(self, section=None):
        opts = []
        self.__opts = ConfigReader.getOptions(self, "Definition", opts)

        if section:
            # Get the options of a specific jail.
            jail = JailReader(section)
            jail.read()
            ret = jail.getOptions()
            if ret:
                if jail.isEnabled():
                    # We only add enabled jails
                    self.__jails.append(jail)
            else:
                logSys.error("Errors in jail '%s'. Skipping..." % section)
                return False
        else:
            # Get the options of all jails.
            for sec in self.sections():
                jail = JailReader(sec)
                jail.read()
                ret = jail.getOptions()
                if ret:
                    if jail.isEnabled():
                        # We only add enabled jails
                        self.__jails.append(jail)
                else:
                    logSys.error("Errors in jail '" + sec + "'. Skipping...")
                    return False
        return True
	def getOptions(self, section = None):
		opts = []
		self.__opts = ConfigReader.getOptions(self, "Definition", opts)

		if section:
			# Get the options of a specific jail.
			jail = JailReader(section)
			jail.read()
			ret = jail.getOptions()
			if ret:
				if jail.isEnabled():
					# We only add enabled jails
					self.__jails.append(jail)
			else:
				logSys.error("Errors in jail '%s'. Skipping..." % section)
				return False
		else:
			# Get the options of all jails.
			for sec in self.sections():
				jail = JailReader(sec)
				jail.read()
				ret = jail.getOptions()
				if ret:
					if jail.isEnabled():
						# We only add enabled jails
						self.__jails.append(jail)
				else:
					logSys.error("Errors in jail '" + sec + "'. Skipping...")
					return False
		return True
    def getOptions(self):
        opts = [["bool", "enabled", "false"],
                ["string", "logpath", "/var/log/messages"],
                ["string", "backend", "auto"], ["int", "maxretry", 3],
                ["int", "findtime", 600], ["int", "bantime", 600],
                ["string", "failregex", None], ["string", "ignoreregex", None],
                ["string", "ignoreip", None], ["string", "filter", ""],
                ["string", "action", ""]]
        self.__opts = ConfigReader.getOptions(self, self.__name, opts)

        if self.isEnabled():
            # Read filter
            self.__filter = FilterReader(self.__opts["filter"], self.__name)
            ret = self.__filter.read()
            if ret:
                self.__filter.getOptions(self.__opts)
            else:
                logSys.error("Unable to read the filter")
                return False

            # Read action
            for act in self.__opts["action"].split('\n'):
                try:
                    splitAct = JailReader.splitAction(act)
                    action = ActionReader(splitAct, self.__name)
                    ret = action.read()
                    if ret:
                        action.getOptions(self.__opts)
                        self.__actions.append(action)
                    else:
                        raise AttributeError("Unable to read action")
                except Exception, e:
                    logSys.error("Error in action definition " + act)
                    logSys.debug(e)
                    return False
示例#5
0
    def getOptions(self, section=None):
        """Reads configuration for jail(s) and adds enabled jails to __jails
		"""
        opts = []
        self.__opts = ConfigReader.getOptions(self, "Definition", opts)

        if section is None:
            sections = self.sections()
        else:
            sections = [section]

        # Get the options of all jails.
        parse_status = True
        for sec in sections:
            jail = JailReader(sec,
                              basedir=self.getBaseDir(),
                              force_enable=self.__force_enable)
            jail.read()
            ret = jail.getOptions()
            if ret:
                if jail.isEnabled():
                    # We only add enabled jails
                    self.__jails.append(jail)
            else:
                logSys.error("Errors in jail %r. Skipping..." % sec)
                parse_status = False
        return parse_status
示例#6
0
 def getOptions(self, pOpts):
     opts = [
         ["string", "timeregex", None],
         ["string", "timepattern", None],
         ["string", "ignoreregex", ""],
         ["string", "failregex", ""],
     ]
     self.__opts = ConfigReader.getOptions(self, "Definition", opts, pOpts)
    def getOptions(self, pOpts):
        opts = [["string", "actionstart", ""], ["string", "actionstop", ""],
                ["string", "actioncheck", ""], ["string", "actionban", ""],
                ["string", "actionunban", ""]]
        self.__opts = ConfigReader.getOptions(self, "Definition", opts, pOpts)

        if self.has_section("Init"):
            for opt in self.options("Init"):
                if not self.__cInfo.has_key(opt):
                    self.__cInfo[opt] = self.get("Init", opt)
示例#8
0
	def getOptions(self, pOpts):
		opts = [["string", "actionstart", ""],
				["string", "actionstop", ""],
				["string", "actioncheck", ""],
				["string", "actionban", ""],
				["string", "actionunban", ""]]
		self.__opts = ConfigReader.getOptions(self, "Definition", opts, pOpts)
		
		if self.has_section("Init"):
			for opt in self.options("Init"):
				if not self.__cInfo.has_key(opt):
					self.__cInfo[opt] = self.get("Init", opt)
示例#9
0
	def getOptions(self):
		opts = [["bool", "enabled", "false"],
				["string", "logpath", "/var/log/messages"],
				["string", "backend", "auto"],
				["int", "maxretry", 3],
				["int", "findtime", 600],
				["int", "bantime", 600],
				["string", "usedns", "warn"],
				["string", "failregex", None],
				["string", "ignoreregex", None],
				["string", "ignorecommand", None],
				["string", "ignoreip", None],
				["string", "filter", ""],
				["string", "action", ""]]
		self.__opts = ConfigReader.getOptions(self, self.__name, opts)
		if not self.__opts:
			return False
		
		if self.isEnabled():
			# Read filter
			if self.__opts["filter"]:
				self.__filter = FilterReader(self.__opts["filter"], self.__name,
											 basedir=self.getBaseDir())
				ret = self.__filter.read()
				if ret:
					self.__filter.getOptions(self.__opts)
				else:
					logSys.error("Unable to read the filter")
					return False
			else:
				self.__filter = None
				logSys.warn("No filter set for jail %s" % self.__name)
		
			# Read action
			for act in self.__opts["action"].split('\n'):
				try:
					if not act:			  # skip empty actions
						continue
					splitAct = JailReader.splitAction(act)
					action = ActionReader(splitAct, self.__name, basedir=self.getBaseDir())
					ret = action.read()
					if ret:
						action.getOptions(self.__opts)
						self.__actions.append(action)
					else:
						raise AttributeError("Unable to read action")
				except Exception, e:
					logSys.error("Error in action definition " + act)
					logSys.debug("Caught exception: %s" % (e,))
					return False
			if not len(self.__actions):
				logSys.warn("No actions were defined for %s" % self.__name)
示例#10
0
	def getOptions(self):
		opts = []
		self.__opts = ConfigReader.getOptions(self, "Definition", opts)
		for sec in self.sections():
			jail = JailReader(sec)
			jail.read()
			ret = jail.getOptions()
			if ret:
				if jail.isEnabled():
					
					self.__jails.append(jail)
			else:
				logSys.error("Errors in jail '" + sec + "'. Skipping...")
				return False
		return True
示例#11
0
	def getOptions(self):
		opts = [["bool", "enabled", "false"],
				["string", "logpath", "/var/log/messages"],
				["string", "backend", "auto"],
				["int", "maxretry", 3],
				["int", "findtime", 600],
				["int", "bantime", 600],
				["string", "usedns", "warn"],
				["string", "failregex", None],
				["string", "ignoreregex", None],
				["string", "ignoreip", None],
				["string", "filter", ""],
				["string", "action", ""]]
		self.__opts = ConfigReader.getOptions(self, self.__name, opts)
		
		if self.isEnabled():
			# Read filter
			self.__filter = FilterReader(self.__opts["filter"], self.__name,
										 basedir=self.getBaseDir())
			ret = self.__filter.read()
			if ret:
				self.__filter.getOptions(self.__opts)
			else:
				logSys.error("Unable to read the filter")
				return False
			
			# Read action
			for act in self.__opts["action"].split('\n'):
				try:
					splitAct = JailReader.splitAction(act)
					action = ActionReader(splitAct, self.__name, basedir=self.getBaseDir())
					ret = action.read()
					if ret:
						action.getOptions(self.__opts)
						self.__actions.append(action)
					else:
						raise AttributeError("Unable to read action")
				except Exception, e:
					logSys.error("Error in action definition " + act)
					logSys.debug(e)
					return False
示例#12
0
	def getOptions(self):
		opts = [["int", "loglevel", 1],
				["string", "logtarget", "STDERR"]]
		self.__opts = ConfigReader.getOptions(self, "Definition", opts)
示例#13
0
	def getEarlyOptions(self):
		opts = [["string", "socket", "/tmp/fail2ban.sock"],
				["string", "pidfile", "/var/run/fail2ban/fail2ban.pid"]]
		return ConfigReader.getOptions(self, "Definition", opts)
示例#14
0
 def getOptions(self, pOpts):
     opts = [["string", "ignoreregex", ""], ["string", "failregex", ""]]
     self.__opts = ConfigReader.getOptions(self, "Definition", opts, pOpts)
示例#15
0
	def getOptions(self, pOpts):
		opts = [["string", "ignoreregex", ""],
				["string", "failregex", "failmodel", ""]]
		self.__opts = ConfigReader.getOptions(self, "Definition", opts, pOpts)
示例#16
0
 def getOptions(self):
     opts = [["int", "loglevel", 1], ["string", "logtarget", "STDERR"]]
     self.__opts = ConfigReader.getOptions(self, "Definition", opts)
示例#17
0
 def getEarlyOptions(self):
     opts = [["string", "socket", "/var/run/fail2ban/fail2ban.sock"],
             ["string", "pidfile", "/var/run/fail2ban/fail2ban.pid"]]
     return ConfigReader.getOptions(self, "Definition", opts)
示例#18
0
 def getEarlyOptions(self):
     opts = [["string", "socket", "/tmp/fail2ban.sock"]]
     return ConfigReader.getOptions(self, "Definition", opts)