在新贵脚本中的用户之间切换 [英] Switch between users in an upstart script

查看:27
本文介绍了在新贵脚本中的用户之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能有一个新贵脚本以 root 身份运行预脚本,但其余的以 normal_user 运行.我正在尝试类似的东西:

Is it possible to have a upstart script that runs the pre-script as root but the rest as normal_user. I'm trying something like:

setuid normal_user

pre-start exec su -c "echo I'm root" root

script
exec /bin/bash <<"EOT"
    echo "haha, I'm normal user"
EOT

有必要去掉setuid吗?

Is it necessary to drop setuid?

推荐答案

我终于通过删除 setuid normal_user 并更改

I finally got it working by removing setuid normal_user and change

exec /bin/bash <<"EOT"

exec sudo -u normal_user /bin/bash <<"EOT"

这篇关于在新贵脚本中的用户之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆