Only care about the mail handler's sock-group when using LMTP

The "not None" logic was copied from listssrht:
372eda06cb/item/listssrht-lmtp (L349-352)
This commit is contained in:
David Florness 2021-02-21 14:38:31 -05:00 committed by Drew DeVault
parent 837d887647
commit 6efba83e54
1 changed files with 4 additions and 2 deletions

View File

@ -332,7 +332,6 @@ class MailHandler:
return "250 Unsubscribed"
async def create_server():
sock_gid = getgrnam(cfg("todo.sr.ht::mail", "sock-group")).gr_gid
handler = MailHandler()
sock = cfg("todo.sr.ht::mail", "sock")
if "/" in sock:
@ -340,7 +339,10 @@ async def create_server():
lambda: LMTP(handler, enable_SMTPUTF8=True),
path=sock)
os.chmod(sock, 0o775)
os.chown(sock, os.getuid(), sock_gid)
sock_group = cfg("todo.sr.ht::mail", "sock-group", default=None)
if sock_group is not None:
sock_gid = getgrnam(sock_group).gr_gid
os.chown(sock, os.getuid(), sock_gid)
else:
host, port = sock.split(":")
await loop.create_server(