yocto - 在 Yocto 中以非 root 身份安装守护进程
问题描述
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 用户吗?
解决方案
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).
推荐阅读
- java - 尝试从库模块中的主 Android 应用程序调用 TimerTask 时出现 ExceptionInInitializerError
- java - 无效的 RFC 2047 编码
- database - 通过Oracle中的脚本创建新表时将列名更改为大写如何解决这个问题?
- javascript - 动态地将单词拉伸到任何屏幕高度
- reactjs - neom 网站中使用了哪些动画
- caching - 分布式模式 Infinispan 的节点之间是否可能存在数据延迟?
- angular - 进入页面时检查 async observable 的值
- twilio - 自动驾驶仪、Python 快速入门、ngrok 404 消息
- python - 从 Flask API 调用 shell 脚本
- c - 如何摆脱 C 中的分段错误(核心转储)?