mirror of https://github.com/fail2ban/fail2ban
				
				
				
			RF: Filter.getLogPaths -> getLogs
Since it returns log containers not paths per sepull/1266/head
							parent
							
								
									6ce7522d3c
								
							
						
					
					
						commit
						dd9d1912e8
					
				| 
						 | 
				
			
			@ -565,7 +565,7 @@ class FileFilter(Filter):
 | 
			
		|||
	#
 | 
			
		||||
	# @param path log file path
 | 
			
		||||
 | 
			
		||||
	def addLogPath(self, path, tail = False):
 | 
			
		||||
	def addLogPath(self, path, tail=False):
 | 
			
		||||
		if path in self.__logs:
 | 
			
		||||
			logSys.error(path + " already exists")
 | 
			
		||||
		else:
 | 
			
		||||
| 
						 | 
				
			
			@ -607,11 +607,11 @@ class FileFilter(Filter):
 | 
			
		|||
		pass
 | 
			
		||||
 | 
			
		||||
	##
 | 
			
		||||
	# Get the log file path
 | 
			
		||||
	# Get the log containers
 | 
			
		||||
	#
 | 
			
		||||
	# @return log file path
 | 
			
		||||
	# @return log containers
 | 
			
		||||
 | 
			
		||||
	def getLogPath(self):
 | 
			
		||||
	def getLogs(self):
 | 
			
		||||
		return self.__logs.values()
 | 
			
		||||
 | 
			
		||||
	##
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -129,6 +129,6 @@ class FilterGamin(FileFilter):
 | 
			
		|||
	# Desallocates the resources used by Gamin.
 | 
			
		||||
 | 
			
		||||
	def __cleanup(self):
 | 
			
		||||
		for path in self.getLogPath():
 | 
			
		||||
			self.monitor.stop_watch(path.getFileName())
 | 
			
		||||
		for log in self.getLogs():
 | 
			
		||||
			self.monitor.stop_watch(log.getFileName())
 | 
			
		||||
		del self.monitor
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -88,10 +88,10 @@ class FilterPoll(FileFilter):
 | 
			
		|||
		while self.active:
 | 
			
		||||
			if logSys.getEffectiveLevel() <= 6:
 | 
			
		||||
				logSys.log(6, "Woke up idle=%s with %d files monitored",
 | 
			
		||||
						   self.idle, len(self.getLogPath()))
 | 
			
		||||
						   self.idle, len(self.getLogs()))
 | 
			
		||||
			if not self.idle:
 | 
			
		||||
				# Get file modification
 | 
			
		||||
				for container in self.getLogPath():
 | 
			
		||||
				for container in self.getLogs():
 | 
			
		||||
					filename = container.getFileName()
 | 
			
		||||
					if self.isModified(filename):
 | 
			
		||||
						self.getFailures(filename)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -212,7 +212,7 @@ class Server:
 | 
			
		|||
		filter_ = self.__jails[name].filter
 | 
			
		||||
		if isinstance(filter_, FileFilter):
 | 
			
		||||
			return [m.getFileName()
 | 
			
		||||
					for m in filter_.getLogPath()]
 | 
			
		||||
					for m in filter_.getLogs()]
 | 
			
		||||
		else: # pragma: systemd no cover
 | 
			
		||||
			logSys.info("Jail %s is not a FileFilter instance" % name)
 | 
			
		||||
			return []
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -853,11 +853,11 @@ class GetFailures(LogCaptureTestCase):
 | 
			
		|||
 | 
			
		||||
	def testTail(self):
 | 
			
		||||
		self.filter.addLogPath(GetFailures.FILENAME_01, tail=True)
 | 
			
		||||
		self.assertEqual(self.filter.getLogPath()[-1].getPos(), 1653)
 | 
			
		||||
		self.filter.getLogPath()[-1].close()
 | 
			
		||||
		self.assertEqual(self.filter.getLogPath()[-1].readline(), "")
 | 
			
		||||
		self.assertEqual(self.filter.getLogs()[-1].getPos(), 1653)
 | 
			
		||||
		self.filter.getLogs()[-1].close()
 | 
			
		||||
		self.assertEqual(self.filter.getLogs()[-1].readline(), "")
 | 
			
		||||
		self.filter.delLogPath(GetFailures.FILENAME_01)
 | 
			
		||||
		self.assertEqual(self.filter.getLogPath(),[])
 | 
			
		||||
		self.assertEqual(self.filter.getLogs(), [])
 | 
			
		||||
 | 
			
		||||
	def testNoLogAdded(self):
 | 
			
		||||
		self.filter.addLogPath(GetFailures.FILENAME_01, tail=True)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue