compile shell script so can use suid
-
18-09-2019 - |
Question
I need to suid a script so that it can be executed by users with less permissions. Since you can't suid a script and can only suid an executable I wanted to use the generic script compiler "shc" to create an executable and then set that executable's suid bit. Only problem is that on ubuntu jaunty I can't find shc or when I do apt-get install shc, it's comes back as not found. Is there an alternative to using shc (except writing my own C program) or is it included into a repo that I could add, so that apt-get would find it?
Solution
I had this same question over on serverfault - you can edit the sudoers file to grant permission to run a shell script.
OTHER TIPS
Inside the script use sudo
to execute any administrative commands.
If you need sudo to work without requiring a password look at editing the sudoers file to specify the script and give the NOPASSWD option something like this.
USERNAME ALL=(root) NOPASSWD: /usr/local/SCRIPT_NAME ""