From 9911e381b3c72a1ea9f06568a020fe5f0a8a1fbb Mon Sep 17 00:00:00 2001 From: stqfdyr <89149493+stqfdyr@users.noreply.github.com> Date: Tue, 15 Sep 2026 13:43:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?docs:=20agent=20=E6=94=B9=E7=94=A8=E5=9B=BA?= =?UTF-8?q?=E5=AE=9A=E7=B3=BB=E7=BB=9F=E7=94=A8=E6=88=B7=20monitor-agent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 安全页的身份一栏改为专用系统用户,补充说明没开 nesting 的 LXC 容器里 systemd 跳过挂载类隔离、以及 agent 因此不用 DynamicUser。首页同步措辞, 卸载步骤加上 userdel monitor-agent。 对应 monitor-probe/monitor#5。 --- src/Home.tsx | 2 +- src/content/guide/philosophy.mdx | 8 ++++++-- src/content/install/agent.mdx | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Home.tsx b/src/Home.tsx index f04d8e7..3139e1f 100644 --- a/src/Home.tsx +++ b/src/Home.tsx @@ -23,7 +23,7 @@ const SECURITY = [ }, { t: "两个服务都降权运行", - d: "systemd 单元带 DynamicUser、NoNewPrivileges、ProtectSystem=strict、ProtectHome、PrivateTmp、PrivateDevices,并限死地址族与内存上限。hub 以专用用户运行,只写得了 data/ 一个目录,连自己的二进制都改不了。", + d: "各以专用系统用户运行,systemd 单元带 NoNewPrivileges、ProtectSystem=strict、ProtectHome、PrivateTmp、PrivateDevices,并限死地址族与内存上限。hub 只写得了 data/ 一个目录,连自己的二进制都改不了。", }, { t: "默认只监听回环", diff --git a/src/content/guide/philosophy.mdx b/src/content/guide/philosophy.mdx index a570419..b241c2b 100644 --- a/src/content/guide/philosophy.mdx +++ b/src/content/guide/philosophy.mdx @@ -15,7 +15,7 @@ systemd 单元不是只写一行 `ExecStart`: | | agent | hub | |---|---|---| -| 身份 | `DynamicUser`,每次启动一个临时 uid | 专用系统用户 `monitor` | +| 身份 | 专用系统用户 `monitor-agent` | 专用系统用户 `monitor` | | 文件系统 | `ProtectSystem=strict` + `ProtectHome`,全盘只读 | 同上,另加 `ReadWritePaths` 只开 `data/` | | 提权 | `NoNewPrivileges` | `NoNewPrivileges` | | 隔离 | `PrivateTmp`、`PrivateDevices` | `PrivateTmp`、`PrivateDevices` | @@ -24,11 +24,15 @@ systemd 单元不是只写一行 `ExecStart`: hub 因此连自己的二进制都改不了:可写的只有数据库和主题所在的那一个目录。 +没开 nesting 的 LXC 容器建不了挂载命名空间,systemd 会跳过「文件系统」和「隔离」两行,服务照常启动, +其余几行不受影响。agent 不用 `DynamicUser` 正是为此:带着它的单元在这种容器里 systemd 拒绝启动, +报 `226/NAMESPACE`。 + 节点 token 写在 `/opt/monitor/agent.env`,权限 `0600`,不写进服务定义——那些内容会出现在 `systemctl cat` 和日志里。 - OpenRC 上 agent 以 root 运行。`DynamicUser` 是 systemd 白送的降权,OpenRC 没有对应开关, + OpenRC 上 agent 以 root 运行。上表的隔离项都是 systemd 的单元选项,OpenRC 没有对应开关, 两边等价的只有自动重启和 token 的存放方式。 diff --git a/src/content/install/agent.mdx b/src/content/install/agent.mdx index 3a1513e..f3117cf 100644 --- a/src/content/install/agent.mdx +++ b/src/content/install/agent.mdx @@ -54,6 +54,7 @@ done # systemd systemctl disable --now monitor-agent rm -f /etc/systemd/system/monitor-agent.service && systemctl daemon-reload +userdel monitor-agent # OpenRC rc-update del monitor-agent default && rc-service monitor-agent stop From 17a01856a27f29976b58a172ea209dac65baac30 Mon Sep 17 00:00:00 2001 From: stqfdyr <89149493+stqfdyr@users.noreply.github.com> Date: Wed, 16 Sep 2026 11:27:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?docs:=20=E6=9C=80=E5=B0=8F=E6=9D=83?= =?UTF-8?q?=E9=99=90=E8=A1=A8=E8=A1=A5=E4=B8=8A=20RestrictSUIDSGID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 两个单元都明写了这一项:agent 在换掉 DynamicUser= 时补回(DynamicUser= 原本隐含它),hub 随后对齐。它由 seccomp 实现,不经挂载命名空间,所以 建不了命名空间的容器里仍然生效。 --- src/content/guide/philosophy.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/guide/philosophy.mdx b/src/content/guide/philosophy.mdx index b241c2b..78b265b 100644 --- a/src/content/guide/philosophy.mdx +++ b/src/content/guide/philosophy.mdx @@ -17,7 +17,7 @@ systemd 单元不是只写一行 `ExecStart`: |---|---|---| | 身份 | 专用系统用户 `monitor-agent` | 专用系统用户 `monitor` | | 文件系统 | `ProtectSystem=strict` + `ProtectHome`,全盘只读 | 同上,另加 `ReadWritePaths` 只开 `data/` | -| 提权 | `NoNewPrivileges` | `NoNewPrivileges` | +| 提权 | `NoNewPrivileges`、`RestrictSUIDSGID` | `NoNewPrivileges`、`RestrictSUIDSGID` | | 隔离 | `PrivateTmp`、`PrivateDevices` | `PrivateTmp`、`PrivateDevices` | | 网络 | `RestrictAddressFamilies=AF_INET AF_INET6 AF_NETLINK` | `AF_INET AF_INET6` | | 内存 | `MemoryMax=64M` | `MemoryMax=256M` |