Search code examples
bashubuntuupstart

Switch between users in an upstart script


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

Is it necessary to drop setuid?


Solution

  • I finally got it working by removing setuid normal_user and change

    exec /bin/bash <<"EOT"
    

    to

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