improve config check
This commit is contained in:
@@ -237,8 +237,12 @@ class AddDisclaimer:
|
||||
raise RuntimeError(e)
|
||||
body = html.find('body')
|
||||
self.html_template = body or html
|
||||
self.action = action
|
||||
self.error_policy = error_policy
|
||||
self.action = action.lower()
|
||||
assert self.action in ["prepend", "append"], \
|
||||
f"invalid action '{action}'"
|
||||
self.error_policy = error_policy.lower()
|
||||
assert self.error_policy in ["ignore", "reject", "wrap"], \
|
||||
f"invalid error_policy '{error_policy}'"
|
||||
self.pretend = pretend
|
||||
|
||||
def patch_message_body(self, milter, logger):
|
||||
|
||||
@@ -101,17 +101,12 @@ def main():
|
||||
if not rule["actions"]:
|
||||
raise RuntimeError(
|
||||
f"{rule['name']}: no actions configured")
|
||||
ModifyMilter.set_config(cfg, args.debug)
|
||||
|
||||
except (RuntimeError, AssertionError) as e:
|
||||
logger.error(f"config error: {e}")
|
||||
sys.exit(255)
|
||||
|
||||
try:
|
||||
ModifyMilter.set_config(cfg, args.debug)
|
||||
except RuntimeError as e:
|
||||
logger.error(e)
|
||||
sys.exit(254)
|
||||
|
||||
if args.test:
|
||||
print("Configuration OK")
|
||||
sys.exit(0)
|
||||
|
||||
Reference in New Issue
Block a user