I want to allow one user to run specialscript.sh as root
so in his folder i created
-rwxr---- 1 root deployers 142 Jul 16 14:07 specialscript.sh
and in sudoers.d/specialscripts:
user123 ALL=(root) NOPASSWD: /home/user123/specialscript.sh
$ sudo specialscript.sh
Running script as user root
$
perfect
other users can't access to /home/user123
files - so it is secure. if some user moves it to other folder it won't work.
BUT
because user is in group deployers he can see the content of this file (and this is intentional).
BUT he can also edit this file. After save the ownership changed to
-rwxr---- 1 user123 user123 142 Jul 16 14:07 specialscript.sh
BUT he can still run it as root...
$ sudo specialscript.sh
Running script as user root
HAHAHA! I CAN RUN rm -rf!
$
for now the only prevention i can see is to change group or remove read (which prevents reading)
or chattr +i /home/user123/specialscript.sh
but this is not obvious behaviour...