From: Remi Gacogne Date: Wed, 22 Apr 2020 10:03:36 +0000 (+0200) Subject: ixfrdist: Use more of systemd's sandboxing options when available X-Git-Tag: rec-4.5.0-alpha0~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ddf3fafa998aacb898f0b7850d85a83c0e48becc;p=thirdparty%2Fpdns.git ixfrdist: Use more of systemd's sandboxing options when available --- diff --git a/pdns/Makefile.am b/pdns/Makefile.am index fdff8b5df5..6bc898eeaf 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -1641,6 +1641,60 @@ CLEANFILES += \ if IXFRDIST ixfrdist.service: ixfrdist.service.in $(AM_V_GEN)sed -e 's![@]bindir[@]!$(bindir)!' < $< > $@ +if !HAVE_SYSTEMD_LOCK_PERSONALITY + $(AM_V_GEN)perl -ni -e 'print unless /^LockPersonality/' $@ +endif +if !HAVE_SYSTEMD_PRIVATE_DEVICES + $(AM_V_GEN)perl -ni -e 'print unless /^PrivateDevices/' $@ +endif +if !HAVE_SYSTEMD_PRIVATE_TMP + $(AM_V_GEN)perl -ni -e 'print unless /^PrivateTmp/' $@ +endif +if !HAVE_SYSTEMD_PRIVATE_USERS + $(AM_V_GEN)perl -ni -e 'print unless /^PrivateUsers/' $@ +endif +if !HAVE_SYSTEMD_PROTECT_CLOCK + $(AM_V_GEN)perl -ni -e 'print unless /^ProtectClock/' $@ +endif +if !HAVE_SYSTEMD_PROTECT_CONTROL_GROUPS + $(AM_V_GEN)perl -ni -e 'print unless /^ProtectControlGroups/' $@ +endif +if !HAVE_SYSTEMD_PROTECT_HOME + $(AM_V_GEN)perl -ni -e 'print unless /^ProtectHome/' $@ +endif +if !HAVE_SYSTEMD_PROTECT_HOSTNAME + $(AM_V_GEN)perl -ni -e 'print unless /^ProtectHostname/' $@ +endif +if !HAVE_SYSTEMD_PROTECT_KERNEL_LOGS + $(AM_V_GEN)perl -ni -e 'print unless /^ProtectKernelLogs/' $@ +endif +if !HAVE_SYSTEMD_PROTECT_KERNEL_MODULES + $(AM_V_GEN)perl -ni -e 'print unless /^ProtectKernelModules/' $@ +endif +if !HAVE_SYSTEMD_PROTECT_KERNEL_TUNABLES + $(AM_V_GEN)perl -ni -e 'print unless /^ProtectKernelTunables/' $@ +endif +if !HAVE_SYSTEMD_PROTECT_SYSTEM + $(AM_V_GEN)perl -ni -e 'print unless /^ProtectSystem/' $@ +endif +if !HAVE_SYSTEMD_RESTRICT_ADDRESS_FAMILIES + $(AM_V_GEN)perl -ni -e 'print unless /^RestrictAddressFamilies/' $@ +endif +if !HAVE_SYSTEMD_RESTRICT_NAMESPACES + $(AM_V_GEN)perl -ni -e 'print unless /^RestrictNamespaces/' $@ +endif +if !HAVE_SYSTEMD_RESTRICT_REALTIME + $(AM_V_GEN)perl -ni -e 'print unless /^RestrictRealtime/' $@ +endif +if !HAVE_SYSTEMD_RESTRICT_SUIDSGID + $(AM_V_GEN)perl -ni -e 'print unless /^RestrictSUIDSGID/' $@ +endif +if !HAVE_SYSTEMD_SYSTEM_CALL_ARCHITECTURES + $(AM_V_GEN)perl -ni -e 'print unless /^SystemCallArchitectures/' $@ +endif +if !HAVE_SYSTEMD_SYSTEM_CALL_FILTER + $(AM_V_GEN)perl -ni -e 'print unless /^SystemCallFilter/' $@ +endif ixfrdist@.service: ixfrdist.service $(AM_V_GEN)sed -e 's!/ixfrdist!& --config $(sysconfdir)/ixfrdist-%i.yml!' \ diff --git a/pdns/ixfrdist.service.in b/pdns/ixfrdist.service.in index a51070ec87..c2efb8ca85 100644 --- a/pdns/ixfrdist.service.in +++ b/pdns/ixfrdist.service.in @@ -12,13 +12,28 @@ ExecStart=@bindir@/ixfrdist Restart=on-failure RestartSec=1 StartLimitInterval=0 -PrivateTmp=true -PrivateDevices=true + +# Sandboxing CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_SETGID CAP_SETUID +LockPersonality=true NoNewPrivileges=true -ProtectSystem=full +PrivateDevices=true +PrivateTmp=true +# Setting PrivateUsers=true prevents us from opening our sockets +ProtectClock=true +ProtectControlGroups=true ProtectHome=true +ProtectHostname=true +ProtectKernelLogs=true +ProtectKernelModules=true +ProtectKernelTunables=true +ProtectSystem=full RestrictAddressFamilies=AF_INET AF_INET6 +RestrictNamespaces=true +RestrictRealtime=true +RestrictSUIDSGID=true +SystemCallArchitectures=native +SystemCallFilter=~ @clock @debug @module @mount @raw-io @reboot @swap @cpu-emulation @obsolete [Install] WantedBy=multi-user.target