Xfce "pkexec: authorization could not be obtained" starting cpu-x daemon

Hi, I wonder if anyone can help me troubleshoot this issue I'm seeing with cpu-x 4.5.3, running XFCE 4.18 on 14.0-RELEASE-p3. I installed the cpu-x binary package 4.5.3_1, and normally pressing the "Start daemon" GUI button should prompt for a password and then start cpu-x-daemon, located at /usr/local/libexec/cpu-x-daemon. Instead, I get a pop-up message saying "pkexec: authorization could not be obtained (not authorized)" as shown below. As a result the daemon does not start.

pkexec_error.png


My userid is a member of group 'wheel', but I'm not sure if that's relevant in this case:
Code:
rasm@t420fbsd:~ $ grep wheel /etc/group
wheel:*:0:root,rasm

Running pkexec from the command line, I get "Error reading line from helper" + "AUTHENTICATION FAILED" + "Bus error":
Code:
rasm@t420fbsd:~ $ pkexec /usr/local/libexec/cpu-x-daemon
==== AUTHENTICATING FOR org.cpu-x-daemon ====
Authentication is required to run CPU-X daemon.
Authenticating as: rasm

** (process:91089): WARNING **: 23:02:34.705: Error reading line from helper: nothing to read
==== AUTHENTICATION FAILED ====
Bus error

There appears to be a valid polkit rule/action configured at /usr/local/share/polkit-1/actions/org.cpu-x-daemon.policy:
Code:
rasm@t420fbsd:~ $ pkaction -av org.cpu-x-daemon
org.cpu-x-daemon:
  description:       Run CPU-X daemon
  message:           Authentication is required to run CPU-X daemon.
  vendor:            The CPU-X Project
  vendor_url:        https://thetumultuousunicornofdarkness.github.io/CPU-X/
  icon:              cpu-x
  implicit any:      auth_admin
  implicit inactive: auth_admin
  implicit active:   auth_admin
  annotation:        org.freedesktop.policykit.exec.path -> /usr/local/libexec/cpu-x-daemon

rasm@t420fbsd:~ $ 
rasm@t420fbsd:~ $ ll /usr/local/share/polkit-1/actions/org.cpu-x-daemon.policy
-rw-r--r--  1 root wheel uarch 793 Feb  6 17:38 /usr/local/share/polkit-1/actions/org.cpu-x-daemon.policy

I did find this thread about a config issue with polkit, so I upgraded to package version 124_1 as suggested there but I still see this behavior. I also found this thread with a similar pkexec "Bus error" to what I'm seeing, suggesting re-installing all packages which I did, with # pkg update && pkg upgrade -f but no joy.

Unfortunately I don't remember if the "Start daemon" GUI button was working correctly before I ran freebsd-update:
Code:
rasm@t420fbsd:~ $ freebsd-version -kru
14.0-RELEASE-p3
14.0-RELEASE-p3
14.0-RELEASE-p4

Could this be a problem running -p3 kernel with -p4 userland?

Thanks very much for your help.
 
You're up to date. Kernel is on p3 and userland is on p4.

cpu-x works here. Ditto pkexec. Have you restarted Xorg or the whole machine since you upgraded polkit?
 
You're up to date. Kernel is on p3 and userland is on p4.

cpu-x works here. Ditto pkexec. Have you restarted Xorg or the whole machine since you upgraded polkit?

Hi, thank you yes, I rebooted the machine after upgrading polkit as well as after re-installing all the packages, but that odd pkexec behavior remains.

For good measure, I just now re-installed polkit, cpu-x, and consolekit2 (because the polkit UPDATING file on freshports.org said they are related) and rebooted again but still no luck.

I might have access to another machine in the next few days where I can try this all over again and compare the two. Thanks again.

Code:
rasm@t420fbsd:~ $ pkg info polkit cpu-x consolekit2
polkit-124_1
cpu-x-4.5.3_1
consolekit2-1.2.6_3
rasm@t420fbsd:~ $
 
An update on this issue, it seems to be related to XFCE only.

After a fresh re-install of 14.0-RELEASE and sticking strictly to the quarterly binary package repo, I cannot reproduce the problem with KDE Plasma nor with MATE, but the problem does indeed persist with XFCE.

I guess something has gone awry with XFCE's handling of polkit/pkexec events, as evidenced by my issue as well as that detailed in this thread. In that thread, OP mentioned pkexec thunar fails mysteriously with "Bus error", and I can confirm that behavior as well with my own XFCE misadventure. In my case a (seemingly) simple pkexec bash also failed with "Bus error" on XFCE.

YMMV, but I wonder if anyone out there can reproduce/confirm.

Right now this issue is fixed on my thinkpad t420 with MATE desktop. Thanks.
Code:
rasm@t420fbsd:~ $ pkg info cpu-x polkit consolekit2 mate
cpu-x-4.5.3_1
polkit-123_1
consolekit2-1.2.6_2
mate-1.26.0_2
rasm@t420fbsd:~ $ freebsd-version -kru
14.0-RELEASE
14.0-RELEASE
14.0-RELEASE
 
It makes sense. I use LXDE. If I have time, I will try to set a VM with XFCE to test that (I gave up XFCE for some locale problems).
 
Alright then, another update.

This can be made to work correctly on XFCE using xfce-polkit, an auth. agent, which isn't currently available as a package for FreeBSD. Note that the last commit to xfce-polkit was 2 years ago. Big thanks to the Arch Linux wiki page on polkit authentication agents for pointing me in the right direction. "gh-repos" below is just my own directory where I keep various github repos.

Code:
rasm@t420fbsd ~ $ doas pkg install -y pkgconf meson ninja
rasm@t420fbsd ~ $ cd gh-repos 
rasm@t420fbsd ~/gh-repos $ git clone https://github.com/ncopa/xfce-polkit.git
rasm@t420fbsd ~/gh-repos $ cd xfce-polkit 
rasm@t420fbsd ~/gh-repos/xfce-polkit (master) $ mkdir build   
rasm@t420fbsd ~/gh-repos/xfce-polkit (master) $ cd build      
rasm@t420fbsd ~/gh-repos/xfce-polkit/build (master) $ meson setup --prefix=/usr/local ..
rasm@t420fbsd ~/gh-repos/xfce-polkit/build (master) $ ninja
rasm@t420fbsd ~/gh-repos/xfce-polkit/build (master) $ ./xfce-polkit

Now start cpu-x and click the "Start daemon" GUI button. The expected authentication dialog appears!

cpu-x-daemon-success.png


Success.

This should be useful for other privilege-escalating GUI apps on XFCE, not just cpu-x.

To install the xfce-polkit binary, run $ doas ninja install from the build directory, which will drop it into /usr/local/libexec. This also creates xfce-polkit.desktop in /usr/local/etc/xdg/autostart. Great fun.

I've spent waaay too much time on this.
 
Glad you solved the problem.

So, I installed a FreeBSD VM with XFCE. I obviously get exactly the same problem than you concerning CPU-X.

Well, not so long ago it was my preferred DE. As I said, I left it for some unsolved problems, but now, it's worse. I can't even automatically launch it at boot with slim. Hum... Will work a little on this. Have you ever considered to change your DE? :rolleyes:
 
Out of the box, for this laptop anyway, XFCE seems to be the least-worst option. The look and feel is ok, and it performs well under XRDP.

I've never cared for GNOME, and the fonts in KDE Plasma by default are sort of ugly and behave inconsistently for some reason. I was willing to use MATE but it actually performs *very* badly in an XRDP session (lots of lag) which was a deal-breaker. So I was settling into LXQT when I stumbled upon that Arch Linux wiki page and realized a solution for XFCE was possible. LXQT is ok but I'm a bit stubborn and I really wanted to fix the XFCE issue.

I should mention, for anyone possibly searching in the future, that xfce-polkit can be replaced with polkit-gnome, which *is* available as a FreeBSD package. You'll just have to create your own /usr/local/etc/xdg/autostart/*.desktop entry, since the package doesn't ship one. So I imagine it would also work with Cinnamon desktop though I haven't tried it.

Also it seems that polkit auth. agents don't quite work properly under XRDP, but that's an issue for another day.
 
Just in case anybody searches on this later, as I mentioned previously, polkit-gnome wasn't working correctly over XRDP. polkit-gnome wouldn't autostart, and invoking it manually at the shell would give the error

Code:
GDBus.Error:org.freedesktop.Consolekit.Manager.GeneralError: Unable to lookup session information for process 'xxxx'.

But sitting in front of the machine, in a lightdm-managed X session, polkit-gnome would autostart just fine and authentication worked correctly as expected.

This led me down several blind alleys but the final fix was to update /usr/local/etc/xrdp/startwm.sh, adding the --with-ck-launch option to the exec startxfce4 call:

Code:
# launch XFCE with consolekit for polkit over XRDP
exec startxfce4 --with-ck-launch

This thread was very helpful but not quite the right solution since invoking dbus-launch would be redundant; XFCE already provides the option and use of --exit-with-session is discouraged by dbus-launch(1) anyway. Hopefully this helps someone else in the future.
 
Back
Top