mirror of https://github.com/fail2ban/fail2ban
Added addLogPath and delLogPath functionality (adds/removes paths from the WatchManager)
parent
b0830385ed
commit
4c13063498
|
@ -54,6 +54,7 @@ class FilterPyinotify(FileFilter):
|
||||||
# Pyinotify watch manager
|
# Pyinotify watch manager
|
||||||
self.monitor = pyinotify.WatchManager()
|
self.monitor = pyinotify.WatchManager()
|
||||||
logSys.debug("Created FilterPyinotify")
|
logSys.debug("Created FilterPyinotify")
|
||||||
|
self.__watches = dict()
|
||||||
|
|
||||||
|
|
||||||
def callback(self, path):
|
def callback(self, path):
|
||||||
|
@ -76,7 +77,8 @@ class FilterPyinotify(FileFilter):
|
||||||
if self.containsLogPath(path):
|
if self.containsLogPath(path):
|
||||||
logSys.error(path + " already exists")
|
logSys.error(path + " already exists")
|
||||||
else:
|
else:
|
||||||
self.monitor.add_watch(path, pyinotify.IN_MODIFY)
|
wd = self.monitor.add_watch(path, pyinotify.IN_MODIFY)
|
||||||
|
self.__watches.update(wd)
|
||||||
FileFilter.addLogPath(self, path, tail)
|
FileFilter.addLogPath(self, path, tail)
|
||||||
logSys.info("Added logfile = %s" % path)
|
logSys.info("Added logfile = %s" % path)
|
||||||
|
|
||||||
|
@ -89,8 +91,14 @@ class FilterPyinotify(FileFilter):
|
||||||
if not self.containsLogPath(path):
|
if not self.containsLogPath(path):
|
||||||
logSys.error(path + " is not monitored")
|
logSys.error(path + " is not monitored")
|
||||||
else:
|
else:
|
||||||
FileFilter.delLogPath(self, path)
|
wdInt = self.__watches[path]
|
||||||
logSys.info("Removed logfile = %s" % path)
|
wd = self.monitor.rm_watch(wdInt)
|
||||||
|
if wd[wdInt]:
|
||||||
|
del self.__watches[path]
|
||||||
|
FileFilter.delLogPath(self, path)
|
||||||
|
logSys.info("Removed logfile = %s" % path)
|
||||||
|
else:
|
||||||
|
logSys.error("Failed to remove watch on path: %s", path)
|
||||||
|
|
||||||
##
|
##
|
||||||
# Main loop.
|
# Main loop.
|
||||||
|
|
Loading…
Reference in New Issue