7
4
Folks, I'm having an issue with a bash script which runs a particular command as a different user.
The background: Running on a Linux box (CentOS), the script is quite simple, it's starting the hudson-ci application.
declare -r HOME=/home/hudson
declare -r RUNAS=hudson
declare -r HOME=/home/hudson
declare -r LOG=hudson.log
declare -r PID=hudson.pid
declare -r BINARY=hudson.war
su - ${RUNAS} -c "nohup java -jar ${HOME}/${BINARY} >> ${HOME}/${LOG} 2>&1; echo $! > ${HOME}/${PID}" &
This is the abridged version of the script, when run, the script exits with "standard in must be a tty". Any ideas on what I could be doing wrong? I've tried Dr Google and all the advice hasn't helped thus far.
Other reference: Mandriva Linux 'su' bug
Why must you use
visudo
? Please expand – 8bitjunkie – 2015-11-17T00:25:12.9971
@8bitjunkie Thats why to use
– MadMike – 2018-03-19T08:51:07.573visudo
https://unix.stackexchange.com/questions/27594/why-do-we-need-to-use-visudo-instead-of-directly-modifying-the-sudoers-fileYou can also make security admins happier by limiting the scope of your removal of restrictions by specifying the user who can issue a command with no tty. see: http://serverfault.com/questions/111064/sudoers-how-to-disable-requiretty-per-user
– benvolioT – 2010-10-19T19:03:47.6234Neither of these worked for me. – Cerin – 2010-12-02T22:24:51.557
5Doesn't /etc/sudoers apply to the
sudo
tool, not coreutilssu
? – Felipe Alvarez – 2014-05-07T03:11:48.767