postfix.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # This file is part of acme-updater, written by Helmut Pozimski 2016-2017.
  2. #
  3. # stov is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, version 2 of the License.
  6. #
  7. # stov is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with stov. If not, see <http://www.gnu.org/licenses/>.
  14. # -*- coding: utf8 -*-
  15. """ Contains the postfix module which manages certificates for the postfix
  16. mail server.
  17. """
  18. import socket
  19. from amulib import service
  20. def run(config=None, acme_dir="/var/lib/acme",
  21. named_key_path="/run/named/session.key",
  22. dns_server="localhost"):
  23. """ manages the certificates for postfix
  24. :param config: configuration for the service
  25. :type config: dict
  26. :param acme_dir: path to the acme state dir
  27. :type acme_dir: str
  28. :param named_key_path: path to the named session.key
  29. :type named_key_path: str
  30. :param dns_server: DNS server to use to create TLSA records
  31. :type dns_server: str
  32. """
  33. hostname = socket.gethostname()
  34. if not config:
  35. config = {
  36. "certificate_path": "/etc/postfix/%s.crt" % hostname,
  37. "key_path": "/etc/postfix/%s.key" % hostname,
  38. "tlsa": True,
  39. "tlsa_ports": [25, 465, 587]
  40. }
  41. service.run("postfix", config, acme_dir, named_key_path, dns_server)