You are not logged in.

#1 2012-07-31 14:19:05

Lennie
Member
From: Sweden
Registered: 2011-10-12
Posts: 146

[Solved] Pkexec doesn't work from menu (polkit not running)

Programs that uses pkexec (for example gparted), I can start it from terminal ('gparted-pkexec', the same as the Exec line in the desktop file) it asks for my password in the terminal and then the program starts. But I can't start it from the menu, it doesn't open that graphical window to ask for my password, and the program doesn't start.

The strange thing is, it works at my work, but not at home. Both computers are very similar; Openbox and Slim, polkit is installed. I don't remember doing anything to make it work at work.

My .xinitrc, if that's relevant:

#!/bin/bash
export GTK2_RC_FILES="$HOME/.gtkrc-2.0"
numlockx &
/usr/bin/xscreensaver -no-splash &
exec dbus-launch openbox-session

I know I can just use gksu, but I want to use pkexec. I have searched the web and the wiki, but I couldn't find anything about this.

Last edited by Lennie (2012-08-04 18:57:04)

Offline

#2 2012-08-01 14:49:56

Lennie
Member
From: Sweden
Registered: 2011-10-12
Posts: 146

Re: [Solved] Pkexec doesn't work from menu (polkit not running)

Solved by installing polkit-gnome.

Offline

#3 2012-08-02 12:28:47

Lennie
Member
From: Sweden
Registered: 2011-10-12
Posts: 146

Re: [Solved] Pkexec doesn't work from menu (polkit not running)

This is mysterious... I first tried to add

# Source scripts in /etc/X11/xinit/xinitrc.d/
if [ -d /etc/X11/xinit/xinitrc.d ]; then
    for f in /etc/X11/xinit/xinitrc.d/*; do
        [ -x "$f" ] && . "$f"
    done
    unset f
fi

to .xinitrc. That in itself didn't help. So I installed polkit-gnome and then it worked. So I deleted those lines from .xinitrc (I don't have them on my computer at work, which don't have this problem.) After reboot it didn't work again. I tried to run those script manually

cd /etc/X11/xinit/xinitrc.d
./30-dbus
./40-libcanberra-gtk-module

but it still didn't work. Add those lines back to .xinitrc, logout-login, and now it works.

The problem is solved, but I'm a curious person, so I also wan't to know why something works or not...

Offline

#4 2012-08-02 12:55:11

mariusmeyer
Member
From: Norway
Registered: 2009-04-25
Posts: 244

Re: [Solved] Pkexec doesn't work from menu (polkit not running)

The first line starts a dbus-session early I believe, so if you run it manually later then you would already have a session running for your openbox-session, and the order would be different. I remember that point confusing a lot of users getting "Not Authorized" when trying to mount stuff with Thunar tongue

Offline

#5 2012-08-02 13:17:33

Lennie
Member
From: Sweden
Registered: 2011-10-12
Posts: 146

Re: [Solved] Pkexec doesn't work from menu (polkit not running)

Is the dbus-session from that script '30-dbus' different than the dbus-session from the line 'exec dbus-launch openbox-session'? Or is this also Slim's fault...? hmm

Offline

#6 2012-08-02 13:45:42

mariusmeyer
Member
From: Norway
Registered: 2009-04-25
Posts: 244

Re: [Solved] Pkexec doesn't work from menu (polkit not running)

I don't believe I've understood how it works exactly, just to point that out tongue

When I used XFCE last year, the dbus-launch in 30-dbus basically made the xfce-session get wrong privilieges from console-kit, polkit etc. So I had to exclude that script from my .xinitrc, and that made my actual desktop session cooperate with polkit etc. via the dbus-launch in the exec line.

Basically you should just have one dbus session going on (of you're the only user logged in of course). I think wink

EDIT: See for example the Xfce Wiki blue box note.

Last edited by mariusmeyer (2012-08-02 13:48:05)

Offline

#7 2012-08-02 14:18:44

Lennie
Member
From: Sweden
Registered: 2011-10-12
Posts: 146

Re: [Solved] Pkexec doesn't work from menu (polkit not running)

As I understand this, I had the right .xinitrc before, and then it didn't work. Now I have wrong .xinitrc,  which starts 2 dbus-sessions, and now it works...

Thank you for your answer. I'm installing systemd right now, and I'm probably messing it up again... "If it ain't broken - break it!"  (But that's for another thread.)

Offline

#8 2012-08-04 08:54:43

Lennie
Member
From: Sweden
Registered: 2011-10-12
Posts: 146

Re: [Solved] Pkexec doesn't work from menu (polkit not running)

The solutions I thought I found earlier in this thread was of the kind: sometimes it works - sometimes it doesn't work... Finally I understand the problem is that polkit authentication agent is not running. Check with:

$ ps x | grep polkit
1065 ?        Sl     0:00 /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
1465 pts/0    S+     0:00 grep polkit

If the first line is missing, it's not running.
The solution I find that works for me (at least now when I tried it...) was to add as last line to ~/.config/openbox/autostart (I only know about Openbox):

/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1

Notice there is no trailing &. (When I added it in the middle of that file and with trailing &, it wasn't running.)


Edit: And here we go again, after shutting down and a few hours later boot up, it's not working again... The authentication agent is not running. How to get it running automatically at login? (Is this also Slim's fault? Many complain about Slim, but I haven't understood what is actually Slim's fault.)

Hm, I don't think this problem is solved afterall, so I'll change the title again.

Edit2: I tried another DM (Cdm) and now everything is working fine. I hate to say this, but I actually think this problem was caused by Slim...

Last edited by Lennie (2012-08-04 18:56:47)

Offline

Board footer

Powered by FluxBB