Login session: keep the real session bus so the PAM-unlocked GNOME keyring works

As a login session, launched apps were put on a private dbus-daemon bus (meant
only to stop single-instance apps forwarding to a host session when nested).
That bus has no org.freedesktop.secrets, so apps D-Bus-activated a second,
locked gnome-keyring-daemon on it: unlock prompts / "create default keyring"
dialogs, even though pam_gnome_keyring had already unlocked the login keyring.
The session script also wrapped everything in dbus-run-session whenever
DBUS_SESSION_BUS_ADDRESS was unset, splitting off from systemd's user bus.

- host-wasm + native sys stub: start the private bus only when nested
  (WAYLAND_DISPLAY or DISPLAY set); under --drm apps use the session bus.
- moon-plasma-session: use $XDG_RUNTIME_DIR/bus when it exists, fall back to
  re-running itself under dbus-run-session; push WAYLAND_DISPLAY and
  XDG_* into the D-Bus/systemd activation environment so gcr-prompter can show
  unlock prompts; run gnome-keyring-daemon --start --components=secrets.
- justfile run-drm(-native): update the activation environment too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hhWvZgm7r2v8NpS2g4
This commit is contained in:
Claude authored and V committed 2026-11-25 17:07:33 +00:00
1 parent d0d375c071
commit 11d7e4d276
4 files changed
+63 -5

No files matched your search

+12 -1
View File
@@ -337,13 +337,24 @@ int32_t mp_has_exe(moonbit_bytes_t name_bytes) {
/* Private session bus for launched apps, so single-instance apps (Firefox, Kate,
* Dolphin...) don't forward the launch to an instance on the host session.
* Started lazily; dies with the compositor. */
* Started lazily; dies with the compositor.
*
* Only when nested inside another graphical session (WAYLAND_DISPLAY or DISPLAY set).
* As a login session (--drm) the session bus is ours, and it is where the PAM-unlocked
* gnome-keyring (org.freedesktop.secrets), portals and notifications live: a private bus
* would hide them, so apps would D-Bus-activate a fresh, locked keyring on it. */
static char private_bus[256];
static int private_bus_tried = 0;
static int env_set(const char *name) {
const char *v = getenv(name);
return v && v[0];
}
static void start_private_bus(void) {
if (private_bus_tried) return;
private_bus_tried = 1;
if (!env_set("WAYLAND_DISPLAY") && !env_set("DISPLAY")) return;
int fds[2];
if (pipe(fds) != 0) return;
pid_t pid = fork();