diff --git a/docs/keyring.md b/docs/keyring.md new file mode 100644 index 0000000..2cc0833 --- /dev/null +++ b/docs/keyring.md @@ -0,0 +1,29 @@ +# Keyring unlock + +Apps reach the system keychain through `org.freedesktop.secrets` on the session bus. +`chandra-session` uses the per-user systemd bus so it finds the secret service that is already +running there (gnome-keyring or oo7-daemon). It does not unlock anything itself: the login +password is only available while you log in, so unlocking is the login manager's PAM stack's job. + +If the keychain stays locked (apps ask for the password, or `keepsecret` shows it locked), the +stack your login manager uses does not hand the password to your secret service. Check which +stack that is: `loginctl show-session -p Service` (for example `plasmalogin`), and look in +`/etc/pam.d/` and `/usr/lib/pam.d/`. + +For oo7 (`oo7-daemon`, module `pam_oo7.so`) add, next to the existing keyring lines: + +``` +-auth optional pam_oo7.so +-password optional pam_oo7.so +-session optional pam_oo7.so auto_start +``` + +For gnome-keyring the equivalents are `pam_gnome_keyring.so` (`use_authtok` on the password line, +`auto_start` on the session line). Put overrides in `/etc/pam.d`, not `/usr/lib/pam.d`, so package +updates don't replace them. Log in again afterwards; the unlock only happens at login. + +Check with: `busctl --user get-property org.freedesktop.secrets +/org/freedesktop/secrets/aliases/default org.freedesktop.Secret.Collection Locked` (`b false`). + +Limits: the keyring's password must match the login password, and autologin (no password typed) +can't unlock it. diff --git a/session/chandra-session b/session/chandra-session index 445b045..e941068 100755 --- a/session/chandra-session +++ b/session/chandra-session @@ -53,8 +53,8 @@ else fi # Session bus. Use the per-user bus (systemd's $XDG_RUNTIME_DIR/bus) when there is one: that is -# where pam_gnome_keyring's daemon, unlocked with the login password, registers -# org.freedesktop.secrets. A fresh dbus-run-session bus would hide it, and apps would then +# where the secret service (gnome-keyring or oo7-daemon), unlocked with the login password by +# its PAM module, registers org.freedesktop.secrets. A fresh dbus-run-session bus would hide it, and apps would then # activate a second, locked keyring daemon there (unlock prompts, "default keyring" dialogs). if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && [ -S "${XDG_RUNTIME_DIR:-/nonexistent}/bus" ]; then export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus" @@ -87,8 +87,9 @@ if command -v systemctl >/dev/null 2>&1; then systemctl --user try-restart xdg-desktop-portal.service >>"$log" 2>&1 || true fi -# Hand the PAM-started keyring daemon (already unlocked by the login password) its session -# components, so it owns org.freedesktop.secrets on our bus. Harmless if it isn't installed, +# Hand the PAM-started gnome-keyring daemon (already unlocked by the login password) its session +# components, so it owns org.freedesktop.secrets on our bus. (oo7-daemon needs none of this: it +# is started by systemd and unlocked over its PAM socket; see docs/keyring.md.) Harmless if it isn't installed, # already running under systemd's socket units, or not unlocked by PAM (it then prompts once). if command -v gnome-keyring-daemon >/dev/null 2>&1; then eval "$(gnome-keyring-daemon --start --components=secrets 2>>"$log")"