Dependiing on the desktop you are using, a polkit agent should have been started.
- KDE automatically starts /usr/lib64/kde4/libexec/polkit-kde-authentication-agent-1 from /usr/share/autostart/polkit-kde-authentication-agent-1.desktop. For this to work, the package polkit-kde-agent has to be installed. The polkit agent will ask for root password when you start virt-manager.
http://imageshack.us/a/img197/2108/polkitkde.png
- Gnome2 and Gnome fallback, as well as XFCE and LXDE automatically starts /usr/lib/polkit-gnome-authentication-agent-1 from /etc/xdg/autostart/polkit-gnome-authentication-agent-1.desktop. For this to work, the package polkit-gnome has to be installed. As with kde, the polkit agent will ask for root password when you start virt-manager.
http://imageshack.us/a/img838/26/polkitgnome.png
- Gnome3 (gnome-shell) doesn’t need to start a polkit agent, since it uses pkexec internally.
http://imageshack.us/a/img24/5686/pkexecgnome.png
- Cinnamon would use pkexec too but does not because the polkit agent gets autostarted although it is not needed. Hence this error message under cinnamon:
Window manager warning: Log level 16: Unable to register authentication agent: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: An authentication agent already exists for the given subject
Window manager warning: Log level 16: Error registering polkit authentication agent: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: An authentication agent already exists for the given subject (polkit-error-quark 0)
To use pkexec under cinnamon, you have to copy /etc/xdg/autostart/polkit-gnome-authentication-agent-1.desktop in ~/.config/autostart/polkit-gnome-authentication-agent-1.desktop and replace this line:
AutostartCondition=GNOME3 unless-session gnome
with this
AutostartCondition=GNOME3 if-session gnome-fallback
You can call this a bug if you want. Well … yes, it’s a bug. I haven’t found a minute to report it.
- If you’re using a DE or WM other than the ones mentioned above, you have to start the polkit agent in the init script of your DE, or in xinitrc, Xsession, however you start X.
I use this for icewm in ~/.icewm/startup:
#!/bin/bash
( sleep 1 && conky.sh ) &
**/usr/lib/polkit-gnome-authentication-agent-1 &**
start-pulseaudio-x11
this for sawfish in ~/.sawfish/rc:
(system "conky.sh &")
**(system "/usr/lib/polkit-gnome-authentication-agent-1 &")
**(system "start-pulseaudio-x11 &")
this for WIndowMaker in ~/GNUstep/Library/WindowMaker/autostart
#!/bin/sh
#
# Place applications to be executed when WindowMaker is started here.
# This should only be used for non-X applications or applications that
# do not support session management. Other applications should be restarted
# by the WindowMaker session restoring mechanism. For that, you should
# either set SaveSessionOnExit=YES or select "Save Session" in the Workspace
# submenu of the root menu when all applications you want started are
# running.
#
# WindowMaker will wait until this script finishes, so if you run any
# commands that take long to execute (like a xterm), put a ``&'' in the
# end of the command line.
#
# This file must be executable.
#
xset m 20/10 4
**/usr/lib/polkit-gnome-authentication-agent-1 &**
Alternatively you can use the polkit wrapper I wrote for other WMs which don’t have an autostart script (or use too inconvenient functions), among others, twm, ctwm, mwm and fvwm(2):
#! /bin/bash
prg=$1
"$prg" ] || exec echo "missing argument"
-x "$prg" ] || which $prg &>/dev/null || exec echo "program not found: $1"
shift
args=$*
`id -u` -eq 0 ] && exec $prg $args
uname -m | grep -q 64 && lib=/usr/lib64 || lib=/usr/lib
if "$DESKTOP_SESSION" = "kde" ]; then
pga=polkit-kde-authentication-agent-1
lpga=/usr/$lib/kde4/libexec/$pka
else
pga=polkit-gnome-authentication-agent-1
lpga=/usr/lib/$pga
fi
case $DESKTOP_SESSION in
gnome|gnome-shell|cinnamon*) exec $prg $args ;;
*) ps nc -C $pga &>/dev/null && exec $prg $args || { ! -x $lpga ] && exec echo "program not found: $lpga" || $lpga & $prg $args ;} ;;
esac
Save it in /usr/bin as “polkitexec”. To start virt-manager, just type:
$ polkitexec virt-manager
and never see this again:
http://imageshack.us/a/img440/869/polkitnone.png
It should work in all situations. If a polkit agent is already running, it won’t start another one and execute the command directly. If you’re running this script as root (but why would you?!), it won’t start a polkit agent either.
This doesn’t only apply to virt-manager but to any other application that needs to be started over polkit or pkexec. And indeed, you can use the polkitexec script to start other applications. |