0

We would like to use Upstart to manage a Java process and run it as non-root using sudo. We are on RHEL 6 which means that Upstart is too old to allow us to explicitly specify a user hence the use of sudo.

However, the Sudo configuration file specifies Defaults requiretty which means we can't run sudo -u to launch the command as a non-root user. We get the following error

sudo: sorry, you must have a tty to run sudo

Is there a way to get Upstart to allocate a pseudo TTY so that sudo will allow us to launch this process? The sudoers file is set according company policy and we are unable to change it.

0

You don't need to - and shouldn't - use sudo to change users in an init script. Use su or better, runuser instead. The runuser command should be available from RHEL 5 and will do the right thing with respect to SELinux contexts, etc.

runuser -u username -g groupname command arguments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.