Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Reopen] XBMC Shutdown,DBUS Polkit Authorization is required
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
musv
Advocate
Advocate


Joined: 01 Dec 2002
Posts: 2658
Location: de

PostPosted: Sun Jan 22, 2012 5:07 pm    Post subject: [Reopen] XBMC Shutdown,DBUS Polkit Authorization is required Reply with quote

Hi there.

I'm still installing my HTPC with XBMC. Currently I'm fighting with (better against) Polkit to allow the xbmc-user to shutdown the computer. Therefore I configured the power button of my remote:

/home/xbmc/.xbmc/userdata/keymaps/remote.xml:
<keymap>
        <global>
                <remote>
                        <start>XBMC.ActivateWindow(Home)</start>
                        <power>XBMC.Powerdown()</power>
...


XBMC starts automatically without Windowmanager. I managed this via:
/etc/inittab:
...
c8:2345:respawn:/sbin/mingetty --autologin xbmc tty8
...


/home/xbmc/.bashrc:
#!/bin/bash
source /etc/profile
exec startx


/home/xbmc/.xinitrc:
#!/bin/sh
exec dbus-launch ck-launch-session xbmc --standalone


When I press the Power button, the xmbc logfile complains:

/home/xbmc/.xbmc/temp/xbmc.log:
17:57:05 T:140724288997184  NOTICE: Storing total System Uptime
17:57:05 T:140724288997184  NOTICE: Saving settings
17:57:05 T:140724288997184  NOTICE: stop all
17:57:05 T:140724288997184  NOTICE: PVRManager - stopping
17:57:06 T:140724288997184  NOTICE: ES: Stopping event server
17:57:06 T:140723991078656  NOTICE: ES: UDP Event server stopped
17:57:06 T:140724288997184  NOTICE: stop dvd detect media
17:57:06 T:140724288997184  NOTICE: stop sap announcement listener
17:57:06 T:140724288997184  NOTICE: clean cached files!
17:57:06 T:140724288997184  NOTICE: unload skin
17:57:06 T:140724288997184  NOTICE: stop python
17:57:07 T:140724288997184  NOTICE: stopped
17:57:07 T:140724288997184  NOTICE: destroy
17:57:07 T:140724288997184  NOTICE: closing down remote control service
17:57:07 T:140724288997184  NOTICE: unload sections
17:57:07 T:140724288997184   ERROR: DBus: Error org.freedesktop.ConsoleKit.Manager.NotPrivileged - Authorization is required
17:57:07 T:140724288997184  NOTICE: destroy
17:57:07 T:140724288997184 WARNING: Attempted to remove window 10013 from the window manager when it didn't exist

XBMC exits and restarts.

The needed polkit rule:
/etc/polkit-1/localauthority/50-local.d/xbmc_shutdown.pkla:
[Actions for xbmc user]
Identity=unix-user:xbmc
Action=org.freedesktop.devicekit.power.*;org.freedesktop.upower.*;org.freedesktop.consolekit.system.*
ResultActive=yes
ResultAny=auth_admin
ResultInactive=yes


What's wrong?


Last edited by musv on Mon Sep 17, 2012 2:06 pm; edited 3 times in total
Back to top
View user's profile Send private message
ppurka
Advocate
Advocate


Joined: 26 Dec 2004
Posts: 3205

PostPosted: Sun Jan 22, 2012 6:13 pm    Post subject: Reply with quote

polkit is a complete mess. I ran into similar permissions problem some time ago. Maybe this thread will help you.
_________________
emerge --quiet redefined | E17 vids: I, II
Back to top
View user's profile Send private message
musv
Advocate
Advocate


Joined: 01 Dec 2002
Posts: 2658
Location: de

PostPosted: Mon Jan 23, 2012 8:19 pm    Post subject: Reply with quote

ppurka wrote:
polkit is a complete mess. I ran into similar permissions problem some time ago. Maybe this thread will help you.

Hmm, I didn't figure out howto configure it for my case.

Nevertheless I have another idea:

ck-list-sessions:
Session4:
   unix-user = '1001'
   realname = '(null)'
   seat = 'Seat3'
   session-type = ''
   active = FALSE
   x11-display = ':0'
   x11-display-device = '/dev/tty7'
   display-device = '/dev/tty8'
   remote-host-name = ''
   is-local = FALSE
   on-since = '2012-01-23T20:07:06.682289Z'
   login-session-id = ''

active = FALSE
is-local = FALSE

seems very wrong to me. How can I convice consolekit of the opposite?
Back to top
View user's profile Send private message
ppurka
Advocate
Advocate


Joined: 26 Dec 2004
Posts: 3205

PostPosted: Tue Jan 24, 2012 3:15 am    Post subject: Reply with quote

You will have to go through this post:
http://forums.gentoo.org/viewtopic-p-6535389.html#6535389
_________________
emerge --quiet redefined | E17 vids: I, II
Back to top
View user's profile Send private message
musv
Advocate
Advocate


Joined: 01 Dec 2002
Posts: 2658
Location: de

PostPosted: Fri Jan 27, 2012 11:32 pm    Post subject: Reply with quote

Ok, I studied the linked thread again and again. I googled the whole internet. I HATE THIS F***ING *KIT STUFF.

http://forums.gentoo.org/viewtopic-t-858965-postdays-0-postorder-asc-start-150.html
https://bbs.archlinux.org/viewtopic.php?pid=880200
https://bbs.archlinux.org/viewtopic.php?id=112768

The situation seems to be:
1. inittab mingetty autologin -> slim -> xbmc: works (session active = true, local = true)
2. inittab mingetty autologin -> startx -> xbmc: doesn't work (session active = false, local = true)

Putting slim in the login chain is not necessary and not useful. Additional it prevents restarting XBMC in case of a crash. So slim is no option.

Google means consolekit doesn't work with (anything?) mingetty. What's the best alternative?
- sudo: I don't think XBMC tries: sudo shutdown -h now
- Setuid-Bit: chmod u+s /sbin/shutdown and halt

The setuid option seems not to be the right way due to security reasons and more maintain expenses after every system update. What other alternatives do I have?
Back to top
View user's profile Send private message
musv
Advocate
Advocate


Joined: 01 Dec 2002
Posts: 2658
Location: de

PostPosted: Sun Jan 29, 2012 11:25 am    Post subject: Reply with quote

Ok, finally I got it working. Thanks to the Arch Wiki.

Again a short summary: The goal is to shutdown the computer by the remote control from inside XBMC.

0. Installed software and enviroment
  • consolekit (Runlevel default)
  • polkit
  • dbus (Runlevel default)

The xbmc-user is called xbmc (really?), the *kit-stuff is activated and installed due to the consolekit-USE-flag.

1. Autostart
I posted only the changed lines. Important is the first line, that initiates the auto-login.
/etc/inittab:
c1:12345:respawn:/sbin/agetty -a xbmc -8 -s 38400 tty1 linux
#c1:12345:respawn:/sbin/agetty 38400 tty1 linux
c2:2345:respawn:/sbin/agetty 38400 tty2 linux
#c3:2345:respawn:/sbin/agetty 38400 tty3 linux
#c4:2345:respawn:/sbin/agetty 38400 tty4 linux
#c5:2345:respawn:/sbin/agetty 38400 tty5 linux
#c6:2345:respawn:/sbin/agetty 38400 tty6 linux


Nothing to be done here:
/home/xbmc/.bashrc:
#!/bin/bash
source /etc/profile


The X-Login will be in this file:
/home/xbmc/.bash_profile:
if [[ -z $DISPLAY && ! -e /tmp/.X11-unix/X0 ]] && (( EUID )); then
        exec startx
fi


And XBMC will be started via .xinitrc:
/home/xbmc/.xinitrc:
exec dbus-launch --sh-syntax --exit-with-session /usr/bin/xbmc --standalone -fs

I don't have any idea, if dbus-launch is really necessary. The manpage says, if the dbus-session it isn't started together with the application, the application will do if needed. Furthermore they write, that would not be the preferred behavior. So, no idea. The shutdown works with and without dbus-launch. Important is, not to call ck-launch-session as it will for some unknown reason deny the right to shutdown the box.

2. Polkit
/etc/polkit-1/localauthority/50-local.d/xbmc_shutdown.pkla:
[Actions for xbmc user]
Identity=unix-user:xbmc
Action=org.freedesktop.devicekit.power.*;org.freedesktop.upower.*;org.freedesktop.consolekit.system.*
ResultActive=yes
ResultInactive=yes
ResultAny=auth_admin


3. More Details
ck-list-sessions:
Session1:
   unix-user = '1001'
   realname = '(null)'
   seat = 'Seat1'
   session-type = ''
   active = FALSE
   x11-display = ''
   x11-display-device = ''
   display-device = '/dev/tty1'
   remote-host-name = ''
   is-local = TRUE
   on-since = '2012-01-29T11:01:02.185356Z'
   login-session-id = '20'
   idle-since-hint = '2012-01-29T11:01:32.024099Z'

You'll get an inactive local session. That seems to be enough for polkit to allow the shutdown.

Improvements and critics are welcome.
Back to top
View user's profile Send private message
ppurka
Advocate
Advocate


Joined: 26 Dec 2004
Posts: 3205

PostPosted: Sun Jan 29, 2012 11:33 am    Post subject: Reply with quote

musv wrote:
You'll get an inactive local session. That seems to be enough for polkit to allow the shutdown.
Great :roll: So, that deepens the mystery around these *kits. It is a major hassle to get them to work. The man pages seem to carry a lot of documentation, but are actually quite useless in describing exactly how these *kits dance around with your authorizations, and exactly how to correctly configure them. I suspect that these *kits are not really understood by anyone other than their devs.
_________________
emerge --quiet redefined | E17 vids: I, II
Back to top
View user's profile Send private message
musv
Advocate
Advocate


Joined: 01 Dec 2002
Posts: 2658
Location: de

PostPosted: Sat Sep 15, 2012 3:52 pm    Post subject: Reply with quote

Already solved and working I have to remove the [solved] prefix. Since a few weeks and updates it isn't working again. :evil:

The config is still exactly as in the last posting described. Except of any version updates there wasn't changed anything in the configuration. So I assume, they changed the behavior of polkit again.

XBMC shuts down to the console but isn't shutdown the machine anymore. Mounting any usb devices doesn't work anymore too.

Is there any posibility to analyze this terrible consolekit and polkit stuff to realize somehow the shutdown and mount action? Polkit or Consolekit don't seem to log something.

Versions:
Code:
[I] sys-auth/consolekit
     Available versions:  0.4.5_p20120320 (~)0.4.5_p20120320-r1 {{acl debug doc kernel_linux pam policykit selinux test}}
     Installed versions:  0.4.5_p20120320-r1(12:30:31 18.08.2012)(kernel_linux pam policykit -acl -debug -doc -selinux -test)
     Homepage:            http://www.freedesktop.org/wiki/Software/ConsoleKit
     Description:         Framework for defining and tracking users, login sessions and seats.

[I] sys-auth/polkit
     Available versions:  0.104-r1 (~)0.107 {{debug doc examples gtk +introspection kde nls pam selinux systemd}}
     Installed versions:  0.107(12:28:55 18.08.2012)(introspection nls pam -examples -gtk -kde -selinux -systemd)
     Homepage:            http://www.freedesktop.org/wiki/Software/polkit
     Description:         Policy framework for controlling privileges for system-wide services
Back to top
View user's profile Send private message
Mr. M
Tux's lil' helper
Tux's lil' helper


Joined: 18 Sep 2004
Posts: 78
Location: USA

PostPosted: Sat Nov 24, 2012 2:22 pm    Post subject: Reply with quote

When I setup my XBMC PC, I followed your guide to get suspend working.. and like for you it broke when I updated my system a few days ago. As a temporary solution, I downgraded to sys-auth/polkit-0.104-r1 and it is working again.

EDIT: This breakage is obviously because with V >=0.105 you have to write java script to define the rules, see this thread: http://forums.gentoo.org/viewtopic-t-933724-start-0.html
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum