Handle unix: socket prefix the same as local:

sendmail's milter.c treats these two declarations the same way, so
what we do for one should also be done for the other.
This commit is contained in:
Daniel Kahn Gillmor
2019-02-21 15:20:02 -05:00
parent bb44f36519
commit a9a6893c89
+11 -4
View File
@@ -150,10 +150,17 @@ def own_socketfile(milterconfig):
"""If socket is Unix socket, chown to UserID before dropping privileges"""
import os
user, group = user_group(milterconfig.get('UserID'))
if milterconfig.get('Socket')[:1] == '/':
os.chown(milterconfig.get('Socket'), user, group)
if milterconfig.get('Socket')[:6] == "local:":
os.chown(milterconfig.get('Socket')[6:], user, group)
offset = None
sockname = milterconfig.get('Socket')
if sockname[:1] == '/':
offset = 0
elif sockname[:6] == "local:":
offset = 6
elif sockname[:5] == "unix:":
offset = 5
if offset is not None:
os.chown(sockname[offset:], user, group)
def read_keyfile(milterconfig, keytype):