The Glassfish application server provides scripts to administer the application server and also start and stop them and I would like to restrict the root user from running this script. The reason is that some key developers forget to administer the server as the non-privileged user and if they restart the application server as the root user, then the application server has to run by the root user [*].
It isn't an option to avoid giving root access and the developers forget because they are so used to do this on their local machine. I would like the asadmin
script to either change to run as the non privileged user or optionally display an error message each time the script is run by root.
Bash shell is used.
[*]: I've tried to fix the rights on files, but even though I've tracked down lots of files which root owns and chmod them, the application experience strange errors and I have to run as root again.
sudo
bit. Now it should do the job. – l0b0 Sep 09 '11 at 07:55$@
is empty, and I've changed it to use a pattern found elsewhere. – l0b0 Aug 31 '17 at 12:33sudo
(it's not usingexec
) and the parent would wait for it, so you would eventually end up with a full process table. It's still worth puttingexec
in there (if you don't intend the code afterfi
to run as the wrong user). – Toby Speight Aug 31 '17 at 15:00exec
; fixed. – l0b0 Aug 31 '17 at 15:10