Handle defaults for Socket differently
We want to be able to select the default for Socket differently in the future. This change augments the API for dkimpy_milter.util.own_socketfile() by adding an optional sockname argument. This is a backward-compatible change. If we aren't committed to API stability for this function, we could make a more invasive change that would probably be a more reasonable API going forward, but this is probably good enough.
This commit is contained in:
@@ -146,12 +146,15 @@ def write_pid(milterconfig):
|
||||
return pid
|
||||
|
||||
|
||||
def own_socketfile(milterconfig):
|
||||
def own_socketfile(milterconfig, sockname=None):
|
||||
"""If socket is Unix socket, chown to UserID before dropping privileges"""
|
||||
import os
|
||||
user, group = user_group(milterconfig.get('UserID'))
|
||||
offset = None
|
||||
sockname = milterconfig.get('Socket')
|
||||
if sockname is None:
|
||||
sockname = milterconfig.get('Socket')
|
||||
if sockname is None:
|
||||
return
|
||||
if sockname[:1] == '/':
|
||||
offset = 0
|
||||
elif sockname[:6] == "local:":
|
||||
|
||||
Reference in New Issue
Block a user