diff options
author | Lukas Fleischer <lfleischer@archlinux.org> | 2018-05-10 21:38:25 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2018-05-10 21:38:25 +0200 |
commit | ce93360257f3b4ef60035a75708148fc814811c1 (patch) | |
tree | 2d1cac47e524ba6e6164bb92e40bbbf78e2a265b /aurweb/scripts | |
parent | 4381a0d7c23203d19d8c33afc6264fa584ba0a4f (diff) | |
download | aur-ce93360257f3b4ef60035a75708148fc814811c1.tar.gz aur-ce93360257f3b4ef60035a75708148fc814811c1.tar.xz |
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 <lfleischer@archlinux.org>
Diffstat (limited to 'aurweb/scripts')
-rwxr-xr-x | aurweb/scripts/usermaint.py | 22 |
1 files changed, 22 insertions, 0 deletions
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() |