Sujet : Re: Simple way for web to execute root shell script.
De : jpstewart (at) *nospam* personalprojects.net (John-Paul Stewart)
Groupes : comp.os.linux.misc comp.sys.raspberry-piDate : 23. May 2025, 15:14:42
Autres entêtes
Message-ID : <m9be6iFj8hrU1@mid.individual.net>
References : 1
User-Agent : Mozilla Thunderbird
On 2025-05-23 8:26 a.m., The Natural Philosopher wrote:
I have a shell script that monitors hardware stuff - it needs to run as
root and be called by Apache as user www.
Bookworm linux on a Pi4.
Its all inside a domestic firewall so security is not a huge issue.
What is the quickest and simplest solution to this?
Use sudo to call the script. First, drop a file into /etc/sudoers.d/
containing something like the following (untested):
www ALL = (root) NOPASSWD: /path/to/script
That should allow Apache running as www to call 'sudo /path/script' to
run 'script' as root with no password needed. But at the same time, the
www user won't be able to run anything else as root (nor any other user).