mirror of https://github.com/fail2ban/fail2ban
The tricky bug fixed - last position of log file will be never retrieved (#795):
addJail (executed before addLog) early uses a "INSERT OR REPLACE" statement to update "enabled" to 1 (and add jail the first time used at once), but this syntax in sqlite always deletes an entry (cause of constraint) and inserts it again, so because of CASCADE all log entries with this jail will be also deleted from logs table.f2b-perfom-prepare-716
parent
60db8b68a6
commit
515032b6e6
|
@ -274,7 +274,11 @@ class Fail2BanDb(object):
|
|||
Jail to be added to the database.
|
||||
"""
|
||||
cur.execute(
|
||||
"INSERT OR REPLACE INTO jails(name, enabled) VALUES(?, 1)",
|
||||
"INSERT OR IGNORE INTO jails(name, enabled) VALUES(?, 1)",
|
||||
(jail.name,))
|
||||
if cur.rowcount <= 0:
|
||||
cur.execute(
|
||||
"UPDATE jails SET enabled = 1 WHERE name = ? AND enabled != 1",
|
||||
(jail.name,))
|
||||
|
||||
@commitandrollback
|
||||
|
|
|
@ -575,7 +575,7 @@ class FileFilter(Filter):
|
|||
if lastpos and not tail:
|
||||
container.setPos(lastpos)
|
||||
self.__logPath.append(container)
|
||||
logSys.info("Added logfile = %s" % path)
|
||||
logSys.info("Added logfile = %s (pos = %s, hash = %s)" , path, container.getPos(), container.getHash())
|
||||
self._addLogPath(path) # backend specific
|
||||
|
||||
def _addLogPath(self, path):
|
||||
|
|
Loading…
Reference in New Issue