microsoft / wslg

Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios
MIT License
10.26k stars 309 forks source link

No Gcr System Prompter available #1033

Open thijsputman opened 1 year ago

thijsputman commented 1 year ago

Windows Version

Microsoft Windows [Version 10.0.22621.1485]

WSL Version

1.2.0.0

Are you using WSL 1 or WSL 2?

Kernel Version

5.15.90.1

Distro Version

Ubuntu 22.04.2

Other Software

Running WLS2 with systemd enabled.

Repro Steps

echo getpin | pinentry-gnome3

Expected Behavior

A WSLg pin-entry prompt window opens on my desktop.

As part of SSH/GPG-operations, until a couple days ago (probably WSL2 version 1.1.6) a WSLg pin-entry prompt window would open on my desktop. Recently I started getting a ncurses pin-entry prompt in the terminal instead.

WSLg itself is working fine (e.g., gnome-system-monitor opens System Monitor as expected).

Actual Behavior

No Gcr System Prompter available, falling back to curses
OK Pleased to meet you

Diagnostic Logs

No response

purefunctor commented 1 year ago

I'm seeing this issue as well:

C:\Users\Justin>wsl --version
WSL version: 1.2.0.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51

My current workaround is to install pinentry-qt and set it as the pinentry-program in gpg-agent.conf

sebastian-de commented 1 year ago

I'm also having this issue at work since a few days. My WSL VM is running Debian Bookworm with systemd enabled, which worked fine so far.

This seems to be an issue with DBUS - running dbus-update-activation-environment --systemd --all fixes the issue for me.

It appears that the DBUS socket takes a few seconds after boot before it becomes available. So my complete block for gpg-agent in ~/.config/fish/config.fish now looks like this:

if status is-interactive
  set -e SSH_AGENT_PID
  set -g -x SSH_AUTH_SOCK (gpgconf --list-dirs agent-ssh-socket)
  set -g -x GPG_TTY (tty)
  while ! test -S "$XDG_RUNTIME_DIR"bus; sleep 1; end
  systemctl --user start gpg-agent.service
  dbus-update-activation-environment --systemd --all
end

That way, the first WSL terminal tab will take a few seconds to become usable, but once the DBUS socket is ready, new terminal tabs open immediately.

Very in-depth information about DBUS and pinentry can be found in the comments of this ticket: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911768

thijsputman commented 1 year ago

This seems to be an issue with DBUS - running dbus-update-activation-environment --systemd --all fixes the issue for me.

Thanks; that does the trick here too!

It appears sufficient to use dbus-update-activation-environment --systemd DBUS_SESSION_BUS_ADDRESS DISPLAY XAUTHORITY (as per the examples in the manual).

It does result in an odd issue with the pinentry window's border/chrome not getting styled properly:

Screenshot 2023-04-21 113224

Previously the popup was properly styled — all other WSLg windows still are...

sebastian-de commented 1 year ago

quoting @smcv from the Debian issue I linked above:

pinentry-gnome3 is presumably a D-Bus client that wants to communicate with the D-Bus service in gcr (which pops up a GNOME Shell system-modal dialog if you're running a full GNOME environment, or an ordinary X11 window with appropriate grabs and other magic otherwise), falling back to curses if it can't.

That might explain why it's not properly themed. Maybe there are other environment variables missing? This could also be a X11 vs. Wayland issue. Here, all applications running on X11 have window decorations like the one on your screenshot, all native Wayland apps have the Gnome window decorations. Have you tried GDK_BACKEND=wayland?

thijsputman commented 1 year ago

Setting GDK_BACKEND to anything other than x11 causes both pinentry and WSLg as a whole to fail (cannot open display: :0).

Anyway, it's not that much of an issue. Just a curious by-product of (what I assume is) the underlying issue...