kolide / launcher

Osquery launcher, autoupdater, and packager
https://kolide.com/launcher
Other
506 stars 103 forks source link

Can't open browser from menu bar app or notification on Ubuntu 23 with Wayland, PopOS 22.04, potentially others #1537

Closed RebeccaMahany closed 3 months ago

RebeccaMahany commented 10 months ago

For Ubuntu 23 with Wayland: we rely on Xwayland to be running in order to grab the DISPLAY, which we need to be able to open URLs from the menu bar app and from notifications. I updated some software on Ubuntu 23.04 and now I don't have an xwayland process, just gdm-wayland-session, which does not have DISPLAY as an arg.

We've also had reports of the browser not opening on PopOS 22.04.

Overall, the way(s) that we're finding and setting DISPLAY is feeling increasingly brittle. We've had issues come up like this on the last several releases. This issue is for, at the very least, fixing the issue on Ubuntu 23.04 with wayland and PopOS, but ideally to find a less brittle way to set DISPLAY in general.


Workarounds

Consolidating some workarounds from the comments here:

Ubuntu-specific workarounds

Switching from wayland to x11 temporarily should let you open links from the menu bar app, and from notifications. After switching to x11, you will have to restart the launcher service via sudo systemctl restart launcher.kolide-k2.service first to get the menu bar app to show up.

Registering your device when you can't access the registration URL from the menu bar app

Any route through auth will also force registration on an unregistered device, so attempting to log in to any Kolide-protected app should get you to the correct registration URL.

rolandoscott commented 10 months ago

I can confirm this is also happening for me on Ubuntu 23.10.. the tray icon appears.. the menu option appear.. but nothing happens when I click on them..

In the meantime, is there any way to trigger the "Register Device" option somehow else.. either via terminal or is it a specific URL that I can just go to?

RebeccaMahany commented 10 months ago

I know we discussed on https://github.com/kolide/launcher/issues/1543, just adding info on the workaround here for ease of access in case anyone else runs into it --

Switching from wayland to x11 temporarily should let you open links from the menu bar app, and from notifications. After switching to x11, you will have to restart the launcher service via sudo systemctl restart launcher.kolide-k2.service first to get the menu bar app to show up.

tobybellwood commented 9 months ago

Just popping in here to say that I had the same issue as Rolando, except that my system is X11 (and has never been on Wayland). I ended up capturing the process call from the menubar click and visiting the registration URL myself.

Is it possible to get these URLs via the CLI anyway, or is the menubar icon the only option?

RebeccaMahany commented 9 months ago

Hey @tobybellwood, thanks for reporting -- would you mind passing along your OS/OS version too so we can make sure it's covered when we address this?

It's not possible to get these URLs via the CLI -- I will check to see if it's possible to get the URL another way and update.

bomoko commented 9 months ago

I'm having the same issues as described by @tobybellwood - I'm running X11 on Pop!_OS 22.04 LTS.

tobybellwood commented 9 months ago

Thanks @RebeccaMahany - I'm also running X11 on Pop!_OS 22.04 LTS

RebeccaMahany commented 9 months ago

@bomoko @tobybellwood -- You can grab the registration URL from a JSON file that stores the menu data, which is located at /var/kolide-k2/k2device.kolide.com/menu.json. (Thank you @James-Pickett for the proposed workaround. 🙂 ) I re-registered my device to confirm -- I think jq -r '.items[0].action.action.url' /var/kolide-k2/k2device.kolide.com/menu.json should do the trick.

bomoko commented 9 months ago

Thanks @RebeccaMahany - that worked like a charm.

RebeccaMahany commented 9 months ago

For anyone else experiencing this issue specifically with device registration in the future, an easier workaround: any route through auth will also force registration on an unregistered device, so attempting to log in to any Kolide-protected app should get you to the correct registration URL. 🙂

RebeccaMahany commented 9 months ago

At least for Ubuntu+wayland, I'm having success per this if I set WAYLAND_DISPLAY and XDG_RUNTIME_DIR in addition to the other env vars

RebeccaMahany commented 9 months ago

Leaving a note here for the next time I or someone else comes back to this: for finding DISPLAY, @Micah-Kolide suggested tracking down the display sockets in use (ss -xlnp) -- after a little bit of research, this is looking promising.

We're already searching for the Xwayland/Xorg process for the given user => I think we can tie that process's PID to the appropriate socket from ss -xlnp, which is a well-known file that we can map to the appropriate DISPLAY.

RebeccaMahany commented 9 months ago

At least for Ubuntu and Debian, this issue should be addressed by today's release https://github.com/kolide/launcher/releases/tag/v1.5.3.