Exemplo n.º 1
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", "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
Exemplo n.º 2
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)
Exemplo n.º 3
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