Adapt config.py to work with OpenDKIM style config item formatting
This commit is contained in:
+21
-5
@@ -73,6 +73,7 @@ def processConfigFile(filename = None, config = None, useSyslog = 1,
|
|||||||
|
|
||||||
|
|
||||||
#################
|
#################
|
||||||
|
# FIXME - still uses string, refactor
|
||||||
class ExceptHook:
|
class ExceptHook:
|
||||||
def __init__(self, useSyslog = 1, useStderr = 0):
|
def __init__(self, useSyslog = 1, useStderr = 0):
|
||||||
self.useSyslog = useSyslog
|
self.useSyslog = useSyslog
|
||||||
@@ -94,6 +95,18 @@ class ExceptHook:
|
|||||||
def setExceptHook():
|
def setExceptHook():
|
||||||
sys.excepthook = ExceptHook(useSyslog = 1, useStderr = 1)
|
sys.excepthook = ExceptHook(useSyslog = 1, useStderr = 1)
|
||||||
|
|
||||||
|
####################
|
||||||
|
def find_boolean(item):
|
||||||
|
if type(item) == int:
|
||||||
|
item = str(item)
|
||||||
|
if item[0] in ["T", "t", "Y", "y", "1"]:
|
||||||
|
item = True
|
||||||
|
elif item[0] in ["F", "f", "N", "n", "0"]:
|
||||||
|
item = False
|
||||||
|
else:
|
||||||
|
raise dkim.ParameterError()
|
||||||
|
return item
|
||||||
|
|
||||||
|
|
||||||
###############################################################
|
###############################################################
|
||||||
commentRx = re.compile(r'^(.*)#.*$')
|
commentRx = re.compile(r'^(.*)#.*$')
|
||||||
@@ -108,9 +121,9 @@ def readConfigFile(path, configData = None, configGlobal = {}):
|
|||||||
if configData == None: configData = {}
|
if configData == None: configData = {}
|
||||||
nameConversion = {
|
nameConversion = {
|
||||||
'AuthservID' : 'str',
|
'AuthservID' : 'str',
|
||||||
'Syslog' : 'str',
|
'Syslog' : 'bool',
|
||||||
'SyslogFacility' : 'str',
|
'SyslogFacility' : 'str',
|
||||||
'SyslogSuccess' : 'str',
|
'SyslogSuccess' : 'bool',
|
||||||
'UMask' : 'str',
|
'UMask' : 'str',
|
||||||
'Mode' : 'str',
|
'Mode' : 'str',
|
||||||
'Socket' : 'str',
|
'Socket' : 'str',
|
||||||
@@ -140,9 +153,9 @@ def readConfigFile(path, configData = None, configGlobal = {}):
|
|||||||
if not line: break
|
if not line: break
|
||||||
|
|
||||||
# parse line
|
# parse line
|
||||||
line = string.strip(string.split(line, '#', 1)[0])
|
line = line.split('#', 1)[0].strip()
|
||||||
if not line: continue
|
if not line: continue
|
||||||
data = map(string.strip, string.split(line, '=', 1))
|
data = line.split()
|
||||||
if len(data) != 2:
|
if len(data) != 2:
|
||||||
if len(data) == 1:
|
if len(data) == 1:
|
||||||
if debugLevel >= 1:
|
if debugLevel >= 1:
|
||||||
@@ -162,7 +175,10 @@ def readConfigFile(path, configData = None, configGlobal = {}):
|
|||||||
|
|
||||||
if debugLevel >= 5: syslog.syslog('readConfigFile: Found entry "%s=%s"'
|
if debugLevel >= 5: syslog.syslog('readConfigFile: Found entry "%s=%s"'
|
||||||
% ( name, value ))
|
% ( name, value ))
|
||||||
configData[name] = conversion(value)
|
if value == bool:
|
||||||
|
configData[name] = find_boolean(name)
|
||||||
|
else:
|
||||||
|
configData[name] = conversion(value)
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
return(configData)
|
return(configData)
|
||||||
|
|||||||
Reference in New Issue
Block a user