summaryrefslogtreecommitdiff
path: root/script/qmauth.py
diff options
context:
space:
mode:
Diffstat (limited to 'script/qmauth.py')
-rwxr-xr-xscript/qmauth.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/script/qmauth.py b/script/qmauth.py
index 0c63c7d..38e5d58 100755
--- a/script/qmauth.py
+++ b/script/qmauth.py
@@ -21,13 +21,14 @@ Exit codes::
111 reserved
"""
+import email.parser
+import email.policy
import json
import logging
import re
from argparse import ArgumentParser
from datetime import datetime
-from email import message_from_binary_file, policy
from functools import cache
from glob import glob
from mailbox import Maildir, MaildirMessage
@@ -80,7 +81,7 @@ def _get_rcv_time(mid):
return float(mid[:idx])
-def startup(maildir, su, user):
+def startup(maildir, su, user, headers_only):
del environ['PATH']
@@ -96,7 +97,7 @@ def startup(maildir, su, user):
maildir / user,
create=False,
factory=lambda x: MaildirMessage(
- message_from_binary_file(x, policy=policy.default)
+ email.parser.BytesParser(policy=email.policy.default).parse(x, headersonly=headers_only)
),
)
@@ -339,7 +340,12 @@ if __name__ == '__main__':
)
args = vars(ap.parse_args())
logging.debug("started with %s", args)
- s = startup(args.pop('maildir_path'), args.pop('os_user'), args.pop('mail_user'))
+ s = startup(
+ args.pop('maildir_path'),
+ args.pop('os_user'),
+ args.pop('mail_user'),
+ args['run'] == list_mails,
+ )
logging.debug("setuid successful")
run = args.pop('run')
reply = run(s, **args)