2 ################################################
 
   3 ### Managed by someone's ansible provisioner ###
 
   4 ################################################
 
   5 # Part of: https://git.somenet.org/root/pub/somesible.git
 
   6 # 2017-2025 by someone <someone@somenet.org>
 
  10 Description=Postfix Mail Transport Agent (main/default instance)
 
  11 Documentation=man:postfix(1)
 
  12 After=network.target nss-lookup.target
 
  13 # network-online.target is a semi-working work-around for specific
 
  14 # network_interfaces, https://bugs.debian.org/854475#126
 
  15 # Please add local override wanting network-online.target or
 
  16 # systemd-networkd-wait-online@INTERFACE:no-carrier.service
 
  17 #After=network-online.target
 
  18 #Wants=network-online.target
 
  19 ConditionPathExists=/etc/postfix/main.cf
 
  20 # pre-3.9.1-7 multi-instance setup:
 
  21 Conflicts=postfix@-.service
 
  25 # Force operations on single default instance, do not run postmulti wrapper
 
  26 Environment=MAIL_CONFIG=/etc/postfix
 
  27 # perform 2-stage startup
 
  28 ExecStartPre=+postfix check
 
  29 ExecStart=postfix debian-systemd-start
 
  31 ExecReload=postfix reload
 
  33 # Postfix consists of multiple processes run by a master(8) orchestrator,
 
  34 # each of them having different requirements.  From the whole set, local(8)
 
  35 # (the Postfix local delivery agent) is the most demanding one, because it
 
  36 # runs things as user, and a user needs to be able to run suid/sgid programs
 
  37 # (if not only to be able to deliver mail to /var/spool/postfix/postdrop).
 
  38 # Individual Postfix daemons are started as root, optionally perform chroot
 
  39 # into the queue directory, and drop privileges voluntary
 
  41 # listen(2) on privileged ports (smtp)
 
  42 CapabilityBoundingSet=CAP_NET_BIND_SERVICE
 
  43 # chroot into queue dir
 
  44 CapabilityBoundingSet=CAP_SYS_CHROOT
 
  45 # drop root privs, run as user when delivering local mail
 
  46 CapabilityBoundingSet=CAP_SETGID CAP_SETUID
 
  47 # processes access protected files in non-root-owned dirs (acl root:rwx);
 
  48 CapabilityBoundingSet=CAP_DAC_OVERRIDE
 
  49 # https://bugs.debian.org/1099891 :
 
  50 CapabilityBoundingSet=CAP_DAC_READ_SEARCH
 
  51 # chown(2) is needed for procmal &Co to create /var/mail/$USER
 
  52 CapabilityBoundingSet=CAP_CHOWN
 
  54 # users might run suid/sgid programs from ~/.forward:
 
  56 # for the same reason, NoNewPrivileges can not be set to yes
 
  59 # if you don't use procmail for delivery to /var/mail/$USER,
 
  60 # CAP_CHOWN can be removed.
 
  61 # if you don't use local(8) at all, only doing local delivery over LMTP
 
  62 # or using virtual(8), you can also set
 
  65 # Also, CAP_DAC_OVERRIDE can be eliminated by adding root user to ACL to
 
  66 # postfix-owned dis in spool: public, private; and whatever maps in protected
 
  67 # subdirs you use, relying on cap_dac_override
 
  70 MemoryDenyWriteExecute=yes
 
  71 ProtectControlGroups=yes
 
  76 ProtectKernelModules=yes
 
  77 ProtectKernelTunables=yes
 
  78 # ProtectProc is not usable with User=root:
 
  81 # ProtectSystem can be "yes" if rw maps are in /etc, or "full"
 
  82 # Alternative would be "strict" +ReadWritePaths=/var
 
  84 # Need to write to ~/Maildir/ etc:
 
  86 RestrictAddressFamilies=AF_UNIX AF_NETLINK AF_INET AF_INET6
 
  87 RestrictNamespaces=yes
 
  90 SystemCallFilter=@system-service @setuid chroot
 
  97 WantedBy=multi-user.target