0
 if [ -f "${S}/abc/abcd.service" ]; then
      install -m 0644 ${S}/abc/abcd.service -D ${D}${systemd_unitdir}/system/abcd.service
      ln -sf ${systemd_unitdir}/system/abcd.service ${D}${systemd_unitdir}/system/multi-user.target.wants/abcd.service
      ln -sf ${systemd_unitdir}/system/abcd.service ${D}${systemd_unitdir}/system/ffbm.target.wants/abcd.service
 fi

我已经安装了一个像上面一样的示例守护程序“abcd.service”,但是在目标上,我看到它被列为 root。如果我检查“ ps -ax | grep abcd ”,那么它会显示我不想要的root。知道如何将其更改为非 root 用户吗?

4

1 回答 1

2

Edit the systemd unit file to use the User= or DynamicUser= directive: https://www.freedesktop.org/software/systemd/man/systemd.exec.html?_sm_au_=iVVHkLwvwFJL8SMPL321jK0f1JH33#User=. The DynamicUser directive might be easier because you won't have to figure out how to create a new user in Yocto (maybe it's actually easy but I don't know how to do it off the top of my head).

于 2021-07-20T16:35:42.907 回答