分页: 1 / 1

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

发表于 : 2023-08-23 10:19
pengsir
安装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.

阅读了,勉强理解了字面含义,还是有点不明白,有哪位再详细解释一下?

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

发表于 : 2023-08-23 14:34
astolia
就是执行这两个ExecStartPre时不管User=、Group=、SupplementaryGroups=的设置,还是用默认的root账号执行

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