Isn't this just how your router works? The web interface of a router
basically has root access and in most cases you can set a bash script
to run, surely that's just as insecure as what I'm trying to achieve
with the Raspberry Pi.
The problem with this logic is you are looking at the end result of a process & assuming the process beneath it. Remember, even when you click reboot
on a router the process is not instantaneous. That alone should give you a clue that something more is happening there.
To avoid risks with sudo being hijacked, you could do a proxy method of doing the follwing:
- Have a superuser cronjob set that runs every minute.
- That cronjob will call a
bash
script.
- That
bash
script checks for the existance of a file that is something called reboot.txt
that can be located in /opt/reboot.txt
While some would balk at superusers running a cronjob like this, I say it is a better alternative than giving www-data
sudo privileges. Why? Well, if www-data
has sudo privileges it can do anything including wiping out your system. Having a cronjob that is restricted which then calls a bash
script which is restricted to then run a process that is restricted gives you more security.