Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polkit/wayland support #177

Open
1 task done
ToxicMushroom opened this issue Mar 13, 2024 · 8 comments
Open
1 task done

Polkit/wayland support #177

ToxicMushroom opened this issue Mar 13, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@ToxicMushroom
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Description

I've been failing to use this on sway because efibooteditor needs access to privileged files:

Error trace:
efivarfs.c:402 efivarfs_set_variable(): : failed to open /sys/firmware/efi/efivars/Boot0000-8be4df61-93ca-11d2-aa0d-00e098032b8c for writing

I think the intended way on wayland is to ask a polkit service for access ?
I cannot just run it with sudo because then it can't find a display to render on.
Like ask the admin for their password when they want to elevate privilege
image

Additional information

Arch linux: 6.7.9
EFI Boot Editor: 1.4.0-aur.1
Sway: 1.9
Polkit: the one from gnome
exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1

@ToxicMushroom ToxicMushroom added the enhancement New feature or request label Mar 13, 2024
@Neverous
Copy link
Owner

There is https://github.com/Neverous/efibooteditor/blob/master/misc/org.x.efibooteditor.policy for this, though at least in my tests it requires running explicitly with pkexec efibooteditor 🤔 I guess there is a way to enforce it automatically? Will take a look.

@ToxicMushroom
Copy link
Author

ToxicMushroom commented Mar 17, 2024

It gives me platform plugin errors

merlijn@arch ~ % echo "$QT_QPA_PLATFORM"
wayland
merlijn@arch ~ % pkexec echo "$QT_QPA_PLATFORM"
wayland
merlijn@arch ~ % pkexec efibooteditor
Invalid MIT-MAGIC-COOKIE-1 key
qt.qpa.xcb: could not connect to display :0
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, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

[1]    3465 IOT instruction (core dumped)  pkexec efibooteditor
134 merlijn@arch ~ %

@Neverous
Copy link
Owner

Neverous commented Mar 17, 2024

pkexec echo "$QT_QPA_PLATFORM"

resolves the QT_QPA_PLATFORM in current session not under pkexec. I think thats why it complains about xcb.

Apparently you can bypass that with pkexec env QT_QPA_PLATFORM="$QT_QPA_PLATFORM" efibooteditor

Not sure what the right/global solution for that would be. Ideally there would be a way to pass that QT_QPA_PLATFORM automatically with pkexec but there doesn't seem to be a way 🤔

I guess the "proper" solution within the application itself would be to divide it into client-server with just the server (with no GUI) with elevated permissions and client (GUI) talking with it, but that's a fair bit of work (and not sure what to do with that on Windows) 🤔

@ToxicMushroom
Copy link
Author

I still had no success with the commands you suggested

merlijn@arch ~ % pkexec env QT_QPA_PLATFORM="wayland" efibooteditor
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
Failed to create wl_display (No such file or directory)
qt.qpa.plugin: Could not load the Qt platform plugin "wayland" 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, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

[1]    4658 IOT instruction (core dumped)  pkexec env QT_QPA_PLATFORM="wayland" efibooteditor
134 merlijn@arch ~ % pkexec env QT_QPA_PLATFORM="wayland" XDG_RUNTIME_DIR=/run/user/1000 efibooteditor
Failed to create wl_display (No such file or directory)
qt.qpa.plugin: Could not load the Qt platform plugin "wayland" 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, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

[1]    4821 IOT instruction (core dumped)  pkexec env QT_QPA_PLATFORM="wayland" XDG_RUNTIME_DIR=/run/user/1000
134 merlijn@arch ~ % 

@Neverous
Copy link
Owner

🤔 Have you tried the full thing they mentioned: pkexec env QT_QPA_PLATFORM="$QT_QPA_PLATFORM" XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" HOME="$HOME" efibooteditor ?

I don't have wayland unfortunately, but with X11 for the above command to work I also had to add DISPLAY: pkexec env DISPLAY="$DISPLAY" QT_QPA_PLATFORM="$QT_QPA_PLATFORM" XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" HOME="$HOME" efibooteditor maybe that will be useful?

@Neverous
Copy link
Owner

Neverous commented Mar 17, 2024

Another option I see gparted seems to be using is xhost +si:localuser:root but that's if you have Xwayland available

Or maybe something from Arch Wiki would work?

@ToxicMushroom
Copy link
Author

xhost works as a workaround for now ty

@ToxicMushroom
Copy link
Author

pkexec env QT_QPA_PLATFORM="$QT_QPA_PLATFORM" XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" HOME="$HOME" efibooteditor
outputs the same wl_display error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants