![如何使 DynamicUser 的 StateDirectory 可供其他用户读取?](https://linux22.com/image/227622/%E5%A6%82%E4%BD%95%E4%BD%BF%20DynamicUser%20%E7%9A%84%20StateDirectory%20%E5%8F%AF%E4%BE%9B%E5%85%B6%E4%BB%96%E7%94%A8%E6%88%B7%E8%AF%BB%E5%8F%96%EF%BC%9F.png)
假设我有 nginx 在 systemd 下运行,如下所示:
# /lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=https://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/sh -c "/bin/kill -s HUP $(/bin/cat /var/run/nginx.pid)"
ExecStop=/bin/sh -c "/bin/kill -s TERM $(/bin/cat /var/run/nginx.pid)"
[Install]
WantedBy=multi-user.target
另一项服务如下所示:
[Unit]
Description=...
After=network.target
[Service]
Type=simple
User=unitname
Group=unitname
DynamicUser=true
StateDirectory=unitname
PrivateTmp=true
ExecStart=somecommand
我如何向用户授予对/var/lib/unitname
(链接/var/lib/private/unitname
)的访问权限nginx
(这nginx
会删除权限并切换到)?