On Wed, Jun 19, 2019 at 3:19 PM Ian Zimmerman <i...@very.loosely.org> wrote: > > On 2019-06-19 15:10, Jack wrote: > > > Won't "sudo halt" work? I frequently do "sudo reboor" or just > > "reboot" from a root shell. (I am also systemd free.) > > I would prefer to avoid sudo for security reasons (to get root I > normally login on an otherwise unused virtual console). But yes, I'm > pretty sure that would work.
This certainly isn't the only way to accomplish your goal, but this is a pretty typical use of sudo. Note that sudo isn't limited to just giving users all-or-nothing access to run commands as root. You can give a particular user the ability to run a particular command line as root as well. So, you could give a user the ability to run shutdown/etc as root, perhaps with a specific set of parameters, and possibly without entering a password. The user wouldn't necessarily be able to do anything else. So, if that user were compromised it could only be used to shut down the system. That of course can be used as a DOS, but the same issue applies to your proposed solution. These days there are other ways to do the same - I'm sure you can do something like this with polkit if you're using a PID1 that can accept messages over dbus. I'm not sure if POSIX capabilities would be of use here - maybe to power off but I'm not sure they're granular enough to send signals to PID 1 and do an orderly shutdown. > > I'm also just curious what the intended prupose of the "halt" user is. My beard isn't quite that long, but I'm guessing it is more-or-less what you think it is. It just isn't fully implemented on Gentoo. I'm guessing that the default passwd file had it in there for compatibility to reserve the UID/etc. I doubt anything actually relies on these accounts these days. -- Rich