4

I found the following command line to shut down a Debian/GNU Linux system

dbus-send \
  --system \
  --dest=org.freedesktop.ConsoleKit \
  --type=method_call \
  --print-reply \
  --reply-timeout=2000 \
  /org/freedesktop/ConsoleKit/Manager \
  org.freedesktop.ConsoleKit.Manager.Stop

It works if I execute the command as superuser, but as a non-privileged user it says:

Error org.freedesktop.ConsoleKit.Manager.NotPrivileged: Not Authorized

I would like to know if it is possible to modify such a command in such a way that, interacting with PolicyKit, it can grant the privilege to shut down the system to a normal user.

Kevin
  • 40,087
  • 16
  • 88
  • 112
enzotib
  • 50,671
  • 14
  • 120
  • 105
  • What is your consolekit version? This [Debian bug report](http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=597937) suggests that an upstream change between versions 0.4.1 and 0.4.2 caused this, but no official solution exists yet. You can read the bug report and see if any of the suggestions work for you. – jw013 Jan 21 '12 at 16:34
  • 1
    @jw013: solved installing `lightdm`. Turn your comment into an answer and I will accept it. – enzotib Jan 21 '12 at 17:45

3 Answers3

2

According to this Debian bug report, this is due to an upstream change in ConsoleKit between versions 0.4.1 and 0.4.2. The thread contains a few suggestions and workarounds, one of which is to install a display manager (like GDM or lightdm) that talks with ConsoleKit directly.

jw013
  • 50,274
  • 9
  • 137
  • 141
2

If you use consolekit > 0.4.1 (wheezy and newer) this doesn't work any more out of the box. To get it working again add

session optional        pam_loginuid.so

to /etc/pam.d/common-session.

Stéphane Gimenez
  • 28,527
  • 3
  • 76
  • 87
bla bla
  • 21
  • 1
0

In my case:

  • Debian 8 amd64;
  • fluxbox;
  • startx (without any DM).
  • installed packages:
    • dbus
    • dbus-X11
    • consolekit
    • policykit-1
    • libpam-ck-connector

This solution works good:

Create a custom-actions.pkla file with the following contents:

sudo nano /var/lib/polkit-1/localauthority/50-local.d/custom-actions.pkla

Put this in the file.

[Actions for xbmc user]
Identity=unix-user:xbmc
Action=org.freedesktop.upower.*;org.freedesktop.consolekit.system.*;org.freedesk​top.udisks.*
ResultAny=yes
ResultInactive=no
ResultActive=yes
Gluttton
  • 330
  • 5
  • 17