core/namespace: allow using ProtectSubset=pid and ProtectHostname=true together
authorChristian Brauner <brauner@kernel.org>
Fri, 21 Jan 2022 12:08:19 +0000 (13:08 +0100)
committerLuca Boccassi <bluca@debian.org>
Tue, 15 Feb 2022 01:13:47 +0000 (01:13 +0000)
commiteeb50421761e3ac562e96c47fb5f0f6ed622cfe1
tree913798c3f7f3e74a3811e4f264c04b057db0ff8a
parent7a23db67795b6583028b7d7c0d5d8ef63c67d8c9
core/namespace: allow using ProtectSubset=pid and ProtectHostname=true together

If a service requests both ProtectSubset=pid and ProtectHostname=true
then it will currently fail to start. The ProcSubset=pid option
instructs systemd to mount procfs for the service with subset=pid which
hides all entries other than /proc/<pid>. Consequently trying to
interact with the two files /proc/sys/kernel/{hostname,domainname}
covered by ProtectHostname=true will fail.

Fix this by only performing this check when ProtectSubset=pid is not
requested. Essentially ProtectSubset=pid implies/provides
ProtectHostname=true.

(cherry picked from commit 1361f015773e3b4d74e382edf1565f3315a3396b)
(cherry picked from commit a727941affa7821592d503c8a5033c92d615f64c)
src/core/namespace.c