[Unit]
Description=@Description@
Documentation=man:pdns_recursor(1)
Documentation=man:rec_control(1)
Documentation=https://doc.powerdns.com
Wants=network-online.target
After=network-online.target time-sync.target

[Service]
ExecStart=@StaticBinDir@/pdns_recursor @ConfigName@ @SocketDir@ --daemon=no --write-pid=no --disable-syslog --log-timestamp=no
ExecStop=@BinDir@/rec_control @ConfigName@ @RecControlSocketDir@ quit-nicely
User=@ServiceUser@
Group=@ServiceGroup@
Type=notify
Restart=on-failure
StartLimitInterval=0
RuntimeDirectory=@RuntimeDirectory@
SyslogIdentifier=@SyslogIdentifier@

# Tuning
LimitNOFILE=16384

# Sandboxing
CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_CHOWN
AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_CHOWN
@LockPersonality@
NoNewPrivileges=true
@PrivateDevices@
@PrivateTmp@
# Setting PrivateUsers=true prevents us from opening our sockets
@ProtectClock@
@ProtectControlGroups@
@ProtectHome@
@ProtectHostname@
@ProtectKernelLogs@
@ProtectKernelModules@
@ProtectKernelTunables@
@ProtectSystem@
@RestrictAddressFamilies@
@RestrictNamespaces@
@RestrictRealtime@
@RestrictSUIDSGID@
@SystemCallArchitectures@
@SystemCallFilter@
@ProtectProc@
@PrivateIPC@
@RemoveIPC@
DevicePolicy=closed
# Not enabled by default because it does not play well with LuaJIT
@MemoryDenyWriteExecute@

[Install]
WantedBy=multi-user.target
