My application needs administrative permissions to run (it's a tool to modify the grub 2 settings). 6 month ago or so I decided to switch from su-to-root (a script runs the best matching graphical sudo agent) to policykit. I've set up an action for my application containing the key "org.freedesktop.policykit.exec.allow_gui". When using GDM as display manager everything works well, but when using KDM I got the message: No protocol specified No protocol specified (grub-customizer:2002): Gtk-WARNING **: cannot open display: :0 …when trying to launch it using `pkexec grub-customizer`. I just had to install and run GDM -> login (still using KDE as desktop environment), then it works well. Also I saw some workaround of the ubuntu devs to make synapic runnable on kubuntu. They solved it by setting the flag "X-KDE-SubstituteUID=true" as option into the .desktop to use the KDE specific authorization method. I did the same as it's an easy change, however I think this cannot be the final way to fix this problem. The problem is not Kubuntu specific as I saw the same problem on magaia. Also I tried theese commands: $ su - # grub-customizer doesn't work (same error like when using policykit) $ sudo -i # grub-customizer doesn't work (same error like when using policykit) $ sudo -s # grub-customizer works $ xhost + $ pkexec grub-customizer works initial bug: https://bugs.freedesktop.org/show_bug.cgi?id=49707 Reproducible: Always Steps to Reproduce: 1. create a policykit action containing <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate> and the path to the graphical application you want to try 2. run this applicatiion using `pkexec YOUR_APPLICATION` 3. run GDM and login from this display manager (session type KDE is ok). Then try step 2 again. Actual Results: on KDM I get the errors, GDM works well Expected Results: KDM should work well too ;-)
it works with gdm (unless you use su -), because it always sets the XAUTHORITY environment variable and root can simply read the pointed-to file. but that's not the right answer. what you really want is adding session optional pam_xauth.so to your /etc/pam.d/ su and sudo. modern distributions do that for you.
In Mageia the file /etc/pam.d/su contains "session optional pam_xauth.so" and the problem remains when runing grub-customizer as a regular user, polit it asks to enter a password but then does not run grub-customizer. The only way to run it is to "su" or "su -", still when running with "su" it says cant connect to dbus but does run it: ]# grub-customizer (grub-customizer:7672): GVFS-RemoteVolumeMonitor-WARNING **: cannot connect to the session bus: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken. *** initializing (w/o specified bootloader type)…