Hi Cheesemill,
I need to run the webserver as the reporter user (with the reporter user's credentials, intended environment settings, etc.). Correct me if I'm wrong, but prepending sudo before the su command will run the webserver with root's settings. I did indeed use sudo visudo to edit /etc/sudoers.
Here is my current /etc/sudoers file that isn't working:
Code:
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
# Allow members of group sudo to execute any command after they have
# provided their password
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# User privilege specification
root ALL=(ALL) ALL
user3 ALL=(ALL)NOPASSWD:/bin/su
user2 ALL=(ALL)NOPASSWD:/bin/su
user1 ALL=(ALL)NOPASSWD:/bin/su
reporter ALL=(ALL)NOPASSWD:/bin/su
Any ideas? =/
Originally Posted by
Cheesemill
If you've added that line to rc.local then it should work without touching sudoers as everything in rc.local is run by the root user.
Also the edits you've made to sudoers look to have an incorrect syntax, did you use visudo to edit it?
If you can't run the script from rc.local and instead have to launch it from a different user (for example rob) then you would need to add:
Code:
rob ALL=(ALL)NOPASSWD:/bin/su
to the bottom of the sudoers file.
Then rob could do:
Code:
sudo su reporter -c "cd /path/to/directorywithscript && bash runwebserver.sh >> /dev/null 2>&1&"
Without having to enter a password.
Bookmarks