9

I am reading the book Linux kernel development, in chapter 5 "System Call Implementation" page 77 says

For example, capable(CAP_SYS_NICE) checks whether the caller has the ability to modify nice values of other processes. By default, the superuser possesses all capabilities and nonroot possesses none. For example, here is the reboot() system call. Note how its first step is ensuring that the calling process has the CAP_SYS_REBOOT . If that one conditional statement were removed, any process could reboot the system.

However, in my Debian Sid I can reboot my machine by using gnome or by executing /sbin/reboot without sudo or su. How is this possible?

Maybe with systemctl?

ls -l /sbin/reboot 
lrwxrwxrwx 1 root root 14 Jun 28 04:23 /sbin/reboot -> /bin/systemctl

EDIT: My user groups

[damian@xvz:~]$ groups 
damian sudo wireshark bumblebee

EDIT 2: systemctl permissions

[damian@xvz:~]$ ls -l /bin/systemctl 
-rwxr-xr-x 1 root root 626640 Jun 28 04:23 /bin/systemctl
1

1 Answer 1

17

This is done via an authorization manager called polkit:

polkit provides an authorization API intended to be used by privileged programs (“MECHANISMS”) offering service to unprivileged programs (“SUBJECTS”) often through some form of inter-process communication mechanism.

With systemd and polkit users with non-remote session can issue power related commands. You can list all polkit registered actions and get details about any of them with pkaction (invoked with no arguments it will list all action ids).
In this particular case the action id is org.freedesktop.login1.reboot so if you run:

pkaction --action-id org.freedesktop.login1.reboot --verbose

the output should be something like:

org.freedesktop.login1.reboot:
  description:       Reboot the system
  message:           Authentication is required for rebooting the system.
  vendor:            The systemd Project
  vendor_url:        http://www.freedesktop.org/wiki/Software/systemd
  icon:              
  implicit any:      auth_admin_keep
  implicit inactive: auth_admin_keep
  implicit active:   yes

Here, active: yes means the user in the active session is authorized to reboot the system (details about implicit authorizations on polkit page). You can check if your session is active with:

loginctl show-session $XDG_SESSION_ID --property=Active
Active=yes
6
  • 1
    that mean any program I run can reboot my machine without my permission?
    – osdamv
    Jul 17, 2015 at 20:17
  • 1
    @osdamv - just like any program you run could rm -rf your user files... Jul 17, 2015 at 20:29
  • 3
    @osdamv Note that you could run all programs you don't trust using sudo --user=jimmy where the user jimmy does not have the right to execute that polkit command...
    – Bakuriu
    Jul 18, 2015 at 4:24
  • How do I actually run this pkaction?
    – Geremia
    Jun 4, 2019 at 21:27
  • @Geremia - I don't understand the question. Jun 5, 2019 at 10:09

You must log in to answer this question.

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