Skip to main content
Topic: A (Read 2560 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

A

A

Re: Enable OpenRC shutdown command for ALL users

Reply #1
Shutdown is an administrative operation, which should be done by the system administrator. Unix (and by extension, Unix-like systems like GNU/Linux) was designed to be a multi-user system with a dedicated system administrator, not as a single-user desktop system. In Unix-like systems, multiple users can be logged into one system at a time. Of course, when used as desktop systems, typically only one user will be logged in at a time, and that user will also usually know the root password, but that doesn't change what's said above.

Display managers usually handle shutdown using their own methods.

You could setuid the /usr/bin/shutdown executable, but that is a security hole. Otherwise, just use privilege escalation.

 

Re: Enable OpenRC shutdown command for ALL users

Reply #2
loginctl poweroff and loginctl reboot should allow you to poweroff and shutdown from your graphical session without asking for password. If muscle memory becomes annoying, you can set up aliases on your sell.

That's the direct equivalent of just shutdown, reboot, poweroff, etc. on Arch (as they were replaced with "dumb" executables that do IPC with systemd there).

Alternatively, you can make the executables nopass/NOPASSWD in doas/sudo/whatever you like.




Re: Enable OpenRC shutdown command for ALL users

Reply #3
loginctl poweroff and loginctl reboot should allow you to poweroff and shutdown from your graphical session without asking for password. If muscle memory becomes annoying, you can set up aliases on your sell.
This depends on elogind installed. With seatd, there is no loginctl command.

This is one more example of how systemd has deviated from the design of Unix. elogind is unfortunately still a necessary evil to have (all the functionality of a) eye candy desktop like GNOME or KDE/Plasma.

Related: https://forum.artixlinux.org/index.php/topic,3050.msg20869.html#msg20869

A

Reply #4
A

Re: Enable OpenRC shutdown command for ALL users

Reply #5
Quote
Would it be possible for one of these commands to be executed whenever I execute 'shutdown' or 'reboot'?[/size][/color]

As I said:

Quote
If muscle memory becomes annoying, you can set up aliases on your sell.

Just create/edit the .bashrc (or .zshrc, or w.e.) file in your home folder and add lines like

Code: [Select]
alias poweroff='loginctl poweroff'

Quote
-[K] IMSOASIAN (Quite sad that elogind has to be required for this indeed.)

Elogind isn't strictly necessary. Remember the classic priv-esc tools like sudo or doas also work for this if you enable no-password mode for these commands (and aliases work the same if you want not to keep typing sudo, sudo, sudo, etc.).

Hey, you can even use s6-sudo for this, like I do on my seatd install.

Re: Enable OpenRC shutdown command for ALL users

Reply #6
(Quite sad that elogind has to be required for this indeed
If you are using seatd, you can create your own substitute for loginctl (although that is not necessary, every init has its own shutdown/reboot command). In the example, I use 66-hpr (halt/poweroff/reboot) program.

But I assume most people using desktop environments would find this method advanced.

Also, back to this:
loginctl poweroff and loginctl reboot should allow you to poweroff and shutdown from your graphical session without asking for password. If muscle memory becomes annoying, you can set up aliases on your sell.
I believe there are two reasons why this works:
  • Hardcoded reliance on "loginctl": program which DMs run has to be named loginctl and accept its parameters,
  • Display managers (sddm, lightdm...) run with root privileges, so they are allowed to shutdown/reboot. When you activate a menu item to shutdown/reboot in your DE, you are sending a message to your DM, which is running as root.