From e3237f057dac679a5f2dd4fe6d020e98a5dfab44 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Fri, 9 Dec 2016 10:36:02 +0100
Subject: [PATCH] systemd: more paranoid security settings

---
 NEWS                   | 1 +
 systemd/mpd.service.in | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/NEWS b/NEWS
index f426c29cb..28ba89c4d 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ ver 0.19.20 (not yet released)
 * output
   - winmm: fix 8 bit playback
 * fix gcc 7.0 -Wimplicit-fallthrough
+* systemd: paranoid security settings
 
 ver 0.19.19 (2016/08/23)
 * decoder
diff --git a/systemd/mpd.service.in b/systemd/mpd.service.in
index c02f55e8d..250ab521c 100644
--- a/systemd/mpd.service.in
+++ b/systemd/mpd.service.in
@@ -12,6 +12,15 @@ LimitRTTIME=infinity
 # disallow writing to /usr, /bin, /sbin, ...
 ProtectSystem=yes
 
+# more paranoid security settings
+NoNewPrivileges=yes
+ProtectKernelTunables=yes
+ProtectControlGroups=yes
+ProtectKernelModules=yes
+# AF_NETLINK is required by libsmbclient, or it will exit() .. *sigh*
+RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX AF_NETLINK
+RestrictNamespaces=yes
+
 [Install]
 WantedBy=multi-user.target
 Also=mpd.socket