How to make a script execute as root, no matter who executes it?
I read about setuid but I'm not sure how to do this.
I'm using Linux, Ubuntu 12.04 LTS.
|
Be really careful: scripts combined with setuid are dangerous! First, please have a look on this question/answers, especially on this answer and security warning. If you still want to execute your script with Wrapper example:
Another solution using
Afterwards, all users can run the script as root without password:
This is similar to using the wrapper/setuid solution above. |
|||||||||||||||||||||
|
|
Easiest and safest way is to use SETUID bits in file permissions. that way command permissions will be elevated to file owner permissions. to prevent script from edition do not set write for everyone bits. |
|||
|
|
setuidwon't work on scripts — it's disabled for security reasons on most *nix distributions these days. You can set it, but it'll be ignored. Maybe you can explain more about your actual problem so we can help you solve this instead? What script is it? Why do you need it to be executed as root? Is usingsudoan alternative? – slhck Jun 22 '12 at 19:45sudo -s? – Nam Phung Jun 22 '12 at 20:05