Hello,
I'm writing an embedded application on the Linux platform. It is designed to run without a window manager, and as the sole application that runs on the computer. I would prefer have the program running as an ordinary user, in keeping with the Principle of least privilege.I also require the application to be able to shut-down the entire system. I guess the way to do this is to have it invoke some shell script.
Seemingly, root access is required in order to shut-down the system, or make whatever POSIX system call(s) are necessary to shut-down the system. Window managers are generally split into two or more processes, one of which runs as root to handle things like this. For example, in KDE, this is the kdm process.
My questions are:
1. What shell commands/series of commands will shut-down a Linux system that is maximally portable across Linux distributions/shells? I see my OpenSuse distro has /sbin/shutdown, /sbin/halt, etc. All of these require root access.
2. How can I shutdown the system without giving my application root access? It occurs to me that I could have a process running as root specifically to shutdown the system, with which my application can communicate with through some sort of Inter-process communication. I'd rather avoid such an elaborate solution, though.
Thanks a lot,
Sternocera
Start Free Trial