postfix.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. """ manages the certificates for postfix
  23. :param config: configuration for the service
  24. :type config: dict
  25. :param acme_dir: path to the acme state dir
  26. :type acme_dir: str
  27. :param named_key_path: path to the named session.key
  28. :type named_key_path: str
  29. """
  30. hostname = socket.gethostname()
  31. if not config:
  32. config = {
  33. "certificate_path": "/etc/postfix/%s.crt" % hostname,
  34. "key_path": "/etc/postfix/%s.key" % hostname,
  35. "tlsa": True,
  36. "tlsa_ports": [25, 465, 587]
  37. }
  38. service.run("postfix", config, acme_dir, named_key_path)