executable path is prefixed with "!":!的含义是 ?

sh/bash/dash/ksh/zsh等Shell脚本
回复
pengsir
帖子: 137
注册时间: 2015-07-24 8:29
系统: ubuntu

executable path is prefixed with "!":!的含义是 ?

#1

帖子 pengsir » 2023-08-23 10:19

安装motion后:

代码: 全选

cat  /lib/systemd/system/motion.service | grep !
ExecStartPre=!/bin/mkdir -p /var/log/motion
ExecStartPre=!/bin/chown motion:adm /var/log/motion
参看手册https://www.freedesktop.org/software/systemd/man/systemd.serv...

Similar to the "+" character discussed above this permits invoking command lines with elevated privileges. However, unlike "+" the "!" character exclusively alters the effect of User=, Group= and SupplementaryGroups=, i.e. only the stanzas that affect user and group credentials. Note that this setting may be combined with DynamicUser=, in which case a dynamic user/group pair is allocated before the command is invoked, but credential changing is left to the executed process itself.

阅读了,勉强理解了字面含义,还是有点不明白,有哪位再详细解释一下?
头像
astolia
论坛版主
帖子: 6452
注册时间: 2008-09-18 13:11

Re: executable path is prefixed with "!":!的含义是 ?

#2

帖子 astolia » 2023-08-23 14:34

就是执行这两个ExecStartPre时不管User=、Group=、SupplementaryGroups=的设置,还是用默认的root账号执行

你那个motion.service里面应该是设置了User=motion去执行正主程序的,但它又要预先创建一个/var/log/motion目录,用motion用户又搞不了,就加个!让systemd还是用root去执行ExecStartPre
回复