On Sat, Mar 21, 2015 at 1:47 PM, Rich Freeman <ri...@gentoo.org> wrote:
>
> On Sat, Mar 21, 2015 at 3:39 PM, German <gentger...@gmail.com> wrote:
> >
> > No, I am trying to shutdown from a console
>
> Well, the old answer would be that you need to use sudo to run it, as
> shutting down is a privileged operation.
>
> I suspect that the new answer is that with appropriate
> policykit/consolekit/etc settings you can probably allow somebody
> sitting at a physical console to shut down the system, or any
> logged-in user if you prefer.  However, I haven't actually set that up
> myself.

logind does that for you automagically™. The first seat has the rights to
poweroff or reboot the machine, and it can differentiate between local and
remote logins. You can check if your user session has the permissions to
poweroff/reboot via dbus:

$ gdbus call --system --dest org.freedesktop.login1 --object-path
/org/freedesktop/login1 --method org.freedesktop.login1.Manager.CanPowerOff
('yes',)

$ gdbus call --system --dest org.freedesktop.login1 --object-path
/org/freedesktop/login1 --method org.freedesktop.login1.Manager.CanReboot
('yes',)

But you need systemd to use logind1. There has been some attempts to
reimplement logind outside systemd, but I'm not sure how advanced they are.

This kind of problems were one of the reasons for creating logind.

Regards.
--
Canek Peláez Valdés
Profesor de asignatura, Facultad de Ciencias
Universidad Nacional Autónoma de México

Reply via email to