5 ms·
If you use Python, you can restart the computer in one line using subprocess. Example: https://www.tutorialspoint.com/python-script-to-restart-computer https:/
by nickpsecurity 3y ago
If you use Python, you can restart the computer in one line using subprocess. Example:
https://www.tutorialspoint.com/python-script-to-restart-computer https://www.tutorialspoint.com/python-script-to-restart-comp...
You can also use two scripts for security:
1. One that’s privileged for the shutdown command.
2. One with no privileges to accept the network request (eg Flask/REST), safely parse it, and send a message to process 1.
You could send the message in many ways. It doesn’t even have to be parsed or contain more than one byte. The reboot process might act if it receives any message from the other process in their dedicated channel.
Set both of these processes to run on startup however you normally do on your system.
If not a message, you could have the network enabled process write to a file in a shared directory. The reboot process periodically checks for the file’s existence. If it sees it, then it reboots the system. That file can be cleared on startup. I say on startup to reduce the risk of any kind of contention causing a problem later on.
The reboot process could also be easily ported to a systems language for resource efficiency. I’d keep the network-facing app in a memory-safe language just in case. D or Rust could handle both, though.
- pmdfgy 3y agoYes of course, the spec can be implemented in any language. I've used Go mainly for personal preferences and portability with only one binary to scp on the server. I'm going to try to propose other implementations as you suggest.
- nickpsecurity 3y agoGo totally slipped my mind. It's also a good choice for the design I outlined.