postfix.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # SPDX-FileCopyrightText: 2016-2017 Helmut Pozimski <helmut@pozimski.eu>
  2. #
  3. # SPDX-License-Identifier: GPL-2.0-only
  4. # -*- coding: utf8 -*-
  5. """ Contains the postfix module which manages certificates for the postfix
  6. mail server.
  7. """
  8. import socket
  9. from amulib import service
  10. def run(config=None, acme_dir="/var/lib/acme",
  11. named_key_path="/run/named/session.key",
  12. dns_server="localhost"):
  13. """ manages the certificates for postfix
  14. :param config: configuration for the service
  15. :type config: dict
  16. :param acme_dir: path to the acme state dir
  17. :type acme_dir: str
  18. :param named_key_path: path to the named session.key
  19. :type named_key_path: str
  20. :param dns_server: DNS server to use to create TLSA records
  21. :type dns_server: str
  22. """
  23. hostname = socket.gethostname()
  24. if not config:
  25. config = {
  26. "certificate_path": "/etc/postfix/%s.crt" % hostname,
  27. "key_path": "/etc/postfix/%s.key" % hostname,
  28. "tlsa": True,
  29. "tlsa_ports": [25, 465, 587]
  30. }
  31. service.run("postfix", config, acme_dir, named_key_path, dns_server)