Btrfs-assistant works in xfce4 desktop, not xfce4 xrdp sessions

I have a VM with the latest Endeavour OS on it, and I selected xfce4 during install. Since it is a VM I will be usually accessing it via RDP. I installed xrdp for that. I also installed btrfs-assistant to help manage the btrfs volume. The problem is if I console into my desktop, I can open btrfs-assistant via the GUI shortcut. If I RDP into the desktop, I get the xfce4 mouse desktop, and btrfs-assistant will not open. For comparison, Firefox opens in both.

I don’t understand the difference, technically, between the console/desktop experience and the xrdp experience. I don’t know why btrfs-assistant works on the console/desktop but not inside xrdp. Can someone help explain and troubleshoot this with me?

Are you opening it the same way when you come through RDP?

Yes. Taskbar → EndeavourOS. Search for Btrfs Assistant, click the icon. This loads when I’m in the console, but simply does nothing when I’m in xrdp.

What happens if you open a terminal and run btrfs-assistant-launcher

Running both from xrdp session:

[user@pc ~]$ btrfs-assistant-launcher
Error executing command as another user: Not authorized

This incident has been reported.

Running sudo first gives:

ISPLAY / WAYLAND_DISPLAY variable is set, launching in GUI mode
Authorization required, but no authorization protocol specified

qt.qpa.xcb: could not connect to display :10.0
qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vkkhrdisplay, vnc, wayland-brcm, wayland-egl, wayland, xcb.

/usr/bin/btrfs-assistant: line 46:  6395 Aborted                    (core dumped) btrfs-assistant-bin ${params}

This is probably the issue. Is pkexec not working in your environment.

That should not work.

I’m not familiar with pkexec, but it seems to work. Or at least, pkexec btrfs-assistant-launcher outputs the help of the application instead of a permissions issue. I can’t seem to pass parameters to it though.

pc ~]$ pkexec btrfs-assistant-launcher --list
Usage: btrfs-assistant-bin [options]
An application for managing Btrfs and Snapper

Options:
-h, --help                         Displays help on commandline options.
--help-all                         Displays help, including generic Qt
options.
-v, --version                      Displays version information.
-l, --list                         List snapshots
-r, --restore   Restore the given snapshot

But modifying the icon/launcher (to “pkexec btrfs-assistant-launcher”) doesn’t do much. I get prompted to authorize, but the application still doesn’t actually load.

Does pkexec work at all?

Can you run pkexec ls

It seems to work. It prompts me to enter my credentials for my user account. pkexec ls returned nothing originially since there were no normal files there, but pkexec ls -lah shows .bash_history, .cache, .config, .ssh, .get-hsts. pkexec pwd shows /root.

There seems to be something wrong with your environment when connected through RDP. That message isn’t thrown by btrfs assistant.

As a workaround, you can try:

sudo -E btrfs-assistant-bin

That actually pulled up the GUI, thanks. Some Qt text in the terminal that I’m not sure what to do with, but the app loaded.

[user@user-pc ~]$ sudo -E btrfs-assistant-bin
[sudo] password for user: 
DISPLAY / WAYLAND_DISPLAY variable is set, launching in GUI mode
qt.qpa.theme.dbus: Session DBus not running.
qt.qpa.theme.dbus: Application will not react to setting changes.
 Check your DBus installation.
qt.qpa.theme.gnome: dbus connection failed. Last error:  QDBusError("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.")
qt.qpa.theme.dbus: Session DBus not running.
qt.qpa.theme.dbus: Application will not react to setting changes.
 Check your DBus installation.
qt.qpa.theme.gnome: dbus connection failed. Last error:  QDBusError("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.")
Warning: No translations available

Agreed that something is different with xrdp and presumably how lightdm is doing the desktop. Something is getting lost when launching xrdp/.xsession/.xinitrc. I just can’t quite pinpoint what.

.xsession: “#xfce4-session”

.xinitrc: “exec dbus-launch --sh-syntax startxfce4”

Adding a polkit policy fixed the app issue. I detest that AI generated this, but it seems to work.

sudo nano /etc/polkit-1/rules.d/45-allow-xrdp-pkexec.rules

polkit.addRule(function(action, subject) {
    if (subject.isInGroup("wheel")) {
        return polkit.Result.YES;
    }
});

The above is insecure. The below option is better and I think represents the intended behavior:

polkit.addRule(function(action, subject) {
    if (subject.local === false && subject.isInGroup("wheel")) {
        return polkit.Result.AUTH_ADMIN;
    }
});

Credit to https://askubuntu.com/questions/1524884/how-to-make-polkit-work-with-xrdp