From ce93360257f3b4ef60035a75708148fc814811c1 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Thu, 10 May 2018 21:38:25 +0200 Subject: Erase login IP addresses after seven days Add a script to periodically remove old IP addresses from the users database. The login IP addresses are stored for spam protection and to prevent from abuse. It is quite unlikely that we ever need the IP address of a user whose last login is more than a week old. It makes sense to remove such IP addresses to protect our users' privacy. Signed-off-by: Lukas Fleischer --- aurweb/scripts/usermaint.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 aurweb/scripts/usermaint.py (limited to 'aurweb/scripts/usermaint.py') diff --git a/aurweb/scripts/usermaint.py b/aurweb/scripts/usermaint.py new file mode 100755 index 00000000..1621d410 --- /dev/null +++ b/aurweb/scripts/usermaint.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +import time + +import aurweb.db + + +def main(): + conn = aurweb.db.Connection() + + limit_to = int(time.time()) - 86400 * 7 + conn.execute("UPDATE Users SET LastLoginIPAddress = NULL " + + "WHERE LastLogin < ?", [limit_to]) + conn.execute("UPDATE Users SET LastSSHLoginIPAddress = NULL " + + "WHERE LastSSHLogin < ?", [limit_to]) + + conn.commit() + conn.close() + + +if __name__ == '__main__': + main() -- cgit v1.2.3-24-g4f1b