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

Can't read QR-codes in wayland #773

Closed
traffic-light opened this issue Jan 18, 2022 · 15 comments
Closed

Can't read QR-codes in wayland #773

traffic-light opened this issue Jan 18, 2022 · 15 comments
Labels

Comments

@traffic-light
Copy link

traffic-light commented Jan 18, 2022

  • Yubico Authenticator version: V5.1.0
  • Operating system and version: Arch linux with KDE, using wayland as window magager
  • YubiKey model and version: Yubikey 5 nfc
  • Bug description summary: Can't read QR-code from Xwayland window

The application runs in wayland but firefox and chrome runs in Xwayland (X11 server of wayland)

I don't think there is an easy (if there is) fix for it. But I wanted to let you guys know.

(didn't find a dirty fix to force run it in Xwayland...)

JonnieCache did look further into it. His post:

In my testing I've found that yubico a
uthenticator runs under xwayland, and so does chrome. Firefox runs under native wayland. QR code scanning doesnt work from either browser.

Firefox is 97.0, Chrome is 98.0.4758.80, running ubuntu 21.10.

@traffic-light traffic-light changed the title Can't read in wayland from Xwayland Can't read QR-codes in wayland from Xwayland Jan 19, 2022
@JonnieCache
Copy link

In my testing I've found that yubico authenticator runs under xwayland, and so does chrome. Firefox runs under native wayland. QR code scanning doesnt work from either browser.

Firefox is 97.0, Chrome is 98.0.4758.80, running ubuntu 21.10.

@traffic-light
Copy link
Author

traffic-light commented Feb 11, 2022

Ah. so it's completely a wayland issue ;-)
Thanks for looking into it @JonnieCache

@traffic-light traffic-light changed the title Can't read QR-codes in wayland from Xwayland Can't read QR-codes in wayland Feb 11, 2022
@fdennis
Copy link
Contributor

fdennis commented Feb 11, 2022

@traffic-light Is the issue solved by that reply? If so, can this be closed?

@traffic-light
Copy link
Author

I don't think it's really resolved. There is no solution ;-)

But I think it's just a specific windowmanager issue...

@JonnieCache
Copy link

JonnieCache commented Feb 14, 2022

The app needs to be updated to use the new wayland screen capture api, something like this.

Beyond my ken I'm afraid.

@alienscience
Copy link

alienscience commented Apr 1, 2022

I just hit this problem and used the following workaround on a site that only had the qr code and did not display the secret key:

  • Save the image to a file using the web browser.
  • Use the zbarimg program that is in most linux repositories to print the contents of the qr code.
  • Delete the image file after setting up the yubikeys.

@dainnilsson
Copy link
Member

Yubico Authenticator 6.0 has now been released and uses a new codebase. As such, this issue has been marked with the legacy label, and will be automatically closed in 7 days. If this issue is still relevant to Yubico Authenticator 6, please comment on the issue saying so, and it will be kept open (or be re-opened). Sorry for the inconvenience!

@schmitmd
Copy link

I don't believe this works under Yubico Authenticator 6.

@dainnilsson
Copy link
Member

@schmitmd This should work in version 6 on Wayland, but it requires the gnome-screenshot tool to be installed. We mention it here: https://github.com/Yubico/yubioath-flutter/blob/main/resources/linux/README.adoc but I'll make sure we also put it in the main README.

@TheBigK02
Copy link

gnome-screenshot i installed but didnt work still

the error is:

{"status":"invalid-command","message":"Invalid parameters: Unable to capture screenshot","body":{},"kind":"error"}

im using the flatpak version of Yubico Autenticator:

Yubico Authenticator com.yubico.yubioath 6.1.0 stable flathub system

@dainnilsson
Copy link
Member

My guess would be that this is caused by the Flatpak sandbox and permissions required to run an external command (gnome-screenshot).

The flatpack package of Yubico Authenticator is not maintained by Yubico, so I would suggest opening an issue here instead: https://github.com/flathub/com.yubico.yubioath

@liferooter
Copy link

@schmitmd This should work in version 6 on Wayland, but it requires the gnome-screenshot tool to be installed. We mention it here: https://github.com/Yubico/yubioath-flutter/blob/main/resources/linux/README.adoc but I'll make sure we also put it in the main README.

It looks like a hack. You should use screenshot portal:

https://flatpak.github.io/xdg-desktop-portal/#gdbus-org.freedesktop.portal.Screenshot

@trinitronx
Copy link

trinitronx commented Jun 22, 2023

This still seems to be an issue on ArchLinux / Manjaro Linux using Sway window manager (as opposed to Gnome Shell running on Mutter).

Tested with:

  • wayland 1.22.0
  • sway 1.8.1
  • yubioath-desktop-beta-bin 6.2.0-1 (via AUR package)
  • gnome-screenshot 41.0+r25+g45f08f0-1

Symptoms:

The Scan QR Code button in Yubico Authenticator initially doesn't appear to do anything but display a spinner when clicked. While this is happening, it appears that gnome-screenshot process is launched, yet hanging in the background seemingly stuck:

$ ps auxww | grep -i gn
ome-screenshot
trinitr+  752812  1.6  0.0 471492 49020 pts/2    Sl+  19:20   0:00 gnome-screenshot -f /tmp/pyscreenshot3tco5mf3/screenshot.png


# gnome-screenshot processes get stuck running in background:
$ pstree -p 752812
gnome-screensho(752812)─┬─{gnome-screensho}(752813)
                        ├─{gnome-screensho}(752814)
                        ├─{gnome-screensho}(752815)
                        └─{gnome-screensho}(752817)

# Viewing parent processes, we can see that dart:flutter_to + `authenticator-helper` started them
## NOTE: The first 2 processes can be ignored ("foot" is the default terminal app on Manjaro Sway edition. SystemD inherits all processes b/c it's init PID 1.)
## This run was after testing out latest git app via flutter SDK + Dart launch method
## PID 752732 = authenticator-helper (output cuts off due to concatenation of output from pstree)
systemd(1)───foot(751953)───zsh(751954)───dart:flutter_to(752582)───authenticator(752732)───authenticator-h(752777)───gnome-screensho(752812)─┬─{gno+
                                                                                                                                              ├─{gno+
                                                                                                                                              ├─{gno+
                                                                                                                                              └─{gno+

However, the following errors appear when running gnome-screenshot in interactive standalone mode:

/usr/bin/gnome-screenshot  -i                                                           INT ✘ 
** Message: 16:54:19.154: Unable to use GNOME Shell's builtin screenshot interface, resorting to fallback X11.

(gnome-screenshot:734865): Gdk-CRITICAL **: 16:54:19.155: gdk_pixbuf_get_from_surface: assertion 'width > 0 && height > 0' failed

(gnome-screenshot:734865): GdkPixbuf-CRITICAL **: 16:54:19.155: gdk_pixbuf_get_width: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(gnome-screenshot:734865): GdkPixbuf-CRITICAL **: 16:54:19.155: gdk_pixbuf_get_height: assertion 'GDK_IS_PIXBUF (pixbuf)' failed
*** BUG ***
In pixman_region32_init_rect: Invalid rectangle passed
Set a breakpoint on '_pixman_log_error' to debug


(gnome-screenshot:734865): GdkPixbuf-CRITICAL **: 16:54:19.155: gdk_pixbuf_get_width: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(gnome-screenshot:734865): GdkPixbuf-CRITICAL **: 16:54:19.155: gdk_pixbuf_get_height: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(gnome-screenshot:734865): Gtk-CRITICAL **: 16:54:19.155: gtk_window_resize: assertion 'width > 0' failed

** (gnome-screenshot:734865): CRITICAL **: 16:54:19.155: Unable to capture a screenshot of any window

In any case, this seems to be a bug in gnome-screenshot so it should probably be reported on that project.

EDIT: I've tested out PR #1053, and unfortunately it doesn't solve this issue. The problem lies in the gnome-screenshot program not supporting Wayland without Gnome Shell + Mutter compositor. Some other apps such as ksnip have found success using xdg-desktop-portal for Flatpak support and apparently say that this works outside the Flatpak sandbox as well. Maybe it's worth a try?

@trinitronx
Copy link

trinitronx commented Jun 22, 2023

Looking into this further, it appears that this was reported upstream: GNOME/gnome-screenshot#201

However, the GNOME developer closed it as effectively Won't Fix, saying that only running it under gnome-shell (and thus Mutter) is supported.

So that leaves the possibility of someone doing the work to detangle gnome-screenshot from depending on the gnome-shell + mutter stack and hoping the GNOME devs will accept a PR. Or, more likely yubioath-flutter app could instead support an alternate native Wayland screenshot provider such as grim. (This seems to be the preferred app of choice at the moment for Sway, as it's pre-installed in Manjaro Sway edition).

EDIT: Quoting the latest README commit log from grim where they removed mention of Sway specifically:

grim is the de-facto tool for screenshots on wlroots-based compositors, so no need to reference a specific compositor.

So it seems this could be a good option on any generic Wayland + wlroots-based compositors. Wayland is more secure than X11 when it comes to screen capture and screen locking, so tools such as gnome-screenshot or any other tool would have to support the protocol for getting permission to get a screenshot. Note that grim is a CLI option that supports this as well as piping screenshots to other tools such as wl-copy, and slurp. Other tools exist as well, although I haven't tested them personally.

The final option which looks promising is using xdg-desktop-portal, which generally speaking is for Flatpak sandbox support. Yet, other apps such as ksnip have found success and apparently say that this works outside the Flatpak sandbox too.

@joepie91
Copy link

joepie91 commented Oct 7, 2024

It seems to me that this issue shouldn't be marked closed, given that scanning QR codes still doesn't work on any Wayland system that isn't GNOME?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

10 participants