2

Please correct me if I am wrong. When we try to shutdown or reboot from terminal by using sudo init 0, sudo init 6( or any other command for the same purpose ) commands we need be root to perform these task but when we do the same thing from Ubuntu( I guess the same thing with most of the Desktops ) UI, it just don't ask any root permission for either of the tasks.

What kind conversation/mechanism is happening in side here ?

2 Answers 2

3

Things like this are controlled by Polkit (its official name, but still often referred to by its former name PolicyKit).

This tool facilitates non-root users being able to perform certain actions to the system that would otherwise require root, and shutting down is one of the actions it is usually configured to grant to regular users. How it works is the user software calls a particular Polkit API asking to shutdown and Polkit will check if that user has the authority to take that action, and if so facilitate it. Polkit is also able to ask for authentication via an authentication agent if the user doesn't have the authority to take that action.

More information about the architecture of Polkit here:

http://manpages.ubuntu.com/manpages/precise/man8/polkit.8.html

0

The command used for shutdown uses dbus. Indeed the shutdown command is:

dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 "org.freedesktop.login1.Manager.PowerOff" boolean:true

Indeed the systemd-logind service is responsible for user losings.

In addition to what @thomasrutter said, Indeed the systemd-logind provides the PolicyKit-based access for users to operations such as system shutdown or sleep.

man systemd-logind

systemd-logind is a system service that manages user logins. It is
       responsible for:


       ·   Providing PolicyKit-based access for users to operations such as
           system shutdown or sleep

Please take a look for my answer https://askubuntu.com/a/632165/150504.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .