listmonk@.service 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. [Unit]
  2. Description=listmonk mailing list and newsletter manager (%I)
  3. ConditionPathExists=/etc/listmonk/%i.toml
  4. Wants=network.target
  5. # The PostgreSQL database may not be on the same host but if it
  6. # is listmonk should wait for it to start up.
  7. After=postgresql.service
  8. [Service]
  9. Type=simple
  10. EnvironmentFile=-/etc/default/listmonk
  11. EnvironmentFile=-/etc/default/listmonk-%i
  12. ExecStartPre=/usr/bin/mkdir -p "${HOME}/uploads"
  13. ExecStartPre=/usr/bin/listmonk --config /etc/listmonk/%i.toml --upgrade --yes
  14. ExecStart=/usr/bin/listmonk --config /etc/listmonk/%i.toml $SYSTEMD_LISTMONK_ARGS
  15. Restart=on-failure
  16. # Create dynamic users for listmonk service instances
  17. # but create a state directory for uploads in /var/lib/private/%i.
  18. DynamicUser=True
  19. StateDirectory=listmonk-%i
  20. Environment=HOME=%S/listmonk-%i
  21. WorkingDirectory=%S/listmonk-%i
  22. # Use systemd’s ability to disable security-sensitive features
  23. # that listmonk does not explicitly need.
  24. # NoNewPrivileges should be enabled by DynamicUser=yes but systemd-analyze
  25. # still recommended to explicitly enable it.
  26. NoNewPrivileges=True
  27. # listmonk doesn’t need any capabilities as defined by the linux kernel
  28. # see: https://man7.org/linux/man-pages/man7/capabilities.7.html
  29. CapabilityBoundingSet=
  30. # listmonk only executes native code with no need for any other ABIs.
  31. SystemCallArchitectures=native
  32. # Only enable a reasonable set of system calls.
  33. # see: https://www.freedesktop.org/software/systemd/man/systemd.exec.html#SystemCallFilter=
  34. SystemCallFilter=@system-service
  35. SystemCallFilter=~@privileged
  36. # ProtectSystem=strict, which is implied by DynamicUser=True, already disabled write calls
  37. # to the entire filesystem hierarchy, leaving only /dev/, /proc/, and /sys/ writable.
  38. # listmonk doesn’t need access to those so might as well disable them.
  39. PrivateDevices=True
  40. ProtectControlGroups=True
  41. ProtectKernelTunables=True
  42. # Make /home/, /root/, and /run/user/ inaccessible.
  43. ProtectHome=True
  44. # listmonk doesn’t handle any specific device nodes.
  45. DeviceAllow=False
  46. # listmonk doesn’t make use of linux namespaces.
  47. RestrictNamespaces=True
  48. # listmonk doesn’t need realtime scheduling.
  49. RestrictRealtime=True
  50. # Make sure files created by listmonk are only readable by itself and
  51. # others in the listmonk system group.
  52. UMask=0027
  53. # Disable memory mappings that are both writable and executable.
  54. MemoryDenyWriteExecute=True
  55. # listmonk doesn’t make use of linux personality switching.
  56. LockPersonality=True
  57. # listmonk only needs to support the IPv4 and IPv6 address families.
  58. RestrictAddressFamilies=AF_INET AF_INET6
  59. # listmonk doesn’t need to load any linux kernel modules.
  60. ProtectKernelModules=True
  61. # Create a sandboxed environment where the system users are mapped to a
  62. # service-specific linux kernel namespace.
  63. PrivateUsers=True
  64. [Install]
  65. WantedBy=multi-user.target