1 Star 0 Fork 94

Mingtai/systemd

forked from src-openEuler/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-core-namespace-allow-using-ProtectSubset-pid-and-Pro.patch 2.13 KB
一键复制 编辑 原始数据 按行查看 历史
From eeb50421761e3ac562e96c47fb5f0f6ed622cfe1 Mon Sep 17 00:00:00 2001
From: Christian Brauner <brauner@kernel.org>
Date: Fri, 21 Jan 2022 13:08:19 +0100
Subject: [PATCH] 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)
Conflict:NA
Reference:https://github.com/systemd/systemd/commit/eeb50421761e3ac562e96c47fb5f0f6ed622cfe1
---
src/core/namespace.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/core/namespace.c b/src/core/namespace.c
index e3aebe8b5e..5961b14f98 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -2115,14 +2115,19 @@ int setup_namespace(
goto finish;
}
+ /* Note, if proc is mounted with subset=pid then neither of the
+ * two paths will exist, i.e. they are implicitly protected by
+ * the mount option. */
if (ns_info->protect_hostname) {
*(m++) = (MountEntry) {
.path_const = "/proc/sys/kernel/hostname",
.mode = READONLY,
+ .ignore = ignore_protect_proc,
};
*(m++) = (MountEntry) {
.path_const = "/proc/sys/kernel/domainname",
.mode = READONLY,
+ .ignore = ignore_protect_proc,
};
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yangmingtaip/systemd.git
git@gitee.com:yangmingtaip/systemd.git
yangmingtaip
systemd
systemd
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385