run removal of inactive users daily

This commit is contained in:
holger krekel
2024-07-09 11:31:05 +02:00
parent 823386d824
commit 66c7115cfc
7 changed files with 10 additions and 4 deletions

View File

@@ -2,6 +2,9 @@
## untagged
- BREAKING: new required chatmail.ini value 'delete_inactive_users_after = 25'
which removes users from database and mails after 25 days without any login.
- remove checking of reverse-DNS PTR records. Chatmail-servers don't
depend on it and even in the wider e-mail system it's not common anymore.
If it's an issue, a chatmail operator can still care to properly set reverse DNS.

View File

@@ -26,6 +26,7 @@ chatmail-metadata = "chatmaild.metadata:main"
filtermail = "chatmaild.filtermail:main"
echobot = "chatmaild.echo:main"
chatmail-metrics = "chatmaild.metrics:main"
delete_inactive_users = "chatmaild.delete_inactive_users:main"
[project.entry-points.pytest11]
"chatmaild.testplugin" = "chatmaild.tests.plugin"

View File

@@ -4,6 +4,7 @@ import iniconfig
def read_config(inipath, mail_basedir=None):
assert Path(inipath).exists(), inipath
cfg = iniconfig.IniConfig(inipath)
params = cfg.sections["params"]
if mail_basedir is None:

View File

@@ -1,5 +1,5 @@
"""
Remove old user accounts
Remove inactive users
"""
import shutil

View File

@@ -8,7 +8,7 @@ mail_domain = {mail_domain}
#
#
# Restrictions on user addresses
# Restrictions on user addresses
#
# how many mails a user can send out per minute
@@ -20,7 +20,7 @@ max_mailbox_size = 100M
# days after which mails are unconditionally deleted
delete_mails_after = 20
# days after which users without a login are deleted (database and mails)
# days after which users without a login are deleted (database and mails)
delete_inactive_users_after = 25
# minimum length a username must have

View File

@@ -1,7 +1,7 @@
from time import time as now
from chatmaild.doveauth import lookup_passdb
from chatmaild.delete_inactive_users import delete_inactive_users
from chatmaild.doveauth import lookup_passdb
def test_remove_stale_users(db, example_config):

View File

@@ -9,3 +9,4 @@
2 0 * * * vmail find /home/vmail/mail/{{ config.mail_domain }} -path '*/tmp/*' -mtime +{{ config.delete_mails_after }} -type f -delete
2 0 * * * vmail find /home/vmail/mail/{{ config.mail_domain }} -path '*/.*/tmp/*' -mtime +{{ config.delete_mails_after }} -type f -delete
3 0 * * * vmail find /home/vmail/mail/{{ config.mail_domain }} -name 'maildirsize' -type f -delete
4 0 * * * vmail /usr/local/lib/chatmaild/venv/bin/delete_inactive_users /home/vmail/passdb.lite /usr/local/lib/chatmaild/chatmail.ini