Skip to content

server: Wait briefly for the login helper socket - #615

Merged
bilelmoussaoui merged 1 commit into
linux-credentials:mainfrom
kitten-lily:fix/login-helper-connect-retry
Oct 24, 2026
Merged

bilelmoussaoui merged 1 commit into
linux-credentials:mainfrom
kitten-lily:fix/login-helper-connect-retry

Conversation

@kitten-lily

Copy link
Copy Markdown
Contributor

On a fresh-boot login through greetd, the login collection sometimes stays locked for the whole session, even though pam_oo7 reports that it sent the secret.

pam_oo7.so auto_start runs one module after pam_systemd.so, and pam_systemd.so is what gets oo7-daemon.service started. When pam_oo7 finds no daemon socket yet, it forks oo7-daemon-login, which binds oo7-daemon-login.sock and waits up to 120 s for the daemon to collect the secret. The daemon reads that socket once, in read_secret_from_login_helper(), before Service::run. If the connect fails, it returns None without logging anything. On my machine the daemon's connect landed about 37 ms before the helper had bound the socket. The secret was dropped and no error appeared on either side.

This PR replaces the single connect with a retry every 10 ms for up to 500 ms. On the login path the helper appears within tens of milliseconds. When no helper is coming, such as a manual systemctl --user restart oo7-daemon, startup takes 500 ms longer.

Testing

  • I added two unit tests for connect_to_login_helper:
    • A listener that binds 150 ms late is reached. This test fails when the wait is set to 0, which is the old single-attempt behaviour.
    • With no listener at all, the function gives up after the wait.
  • cargo test --manifest-path ./server/Cargo.toml passes (107 tests), as do cargo clippy --workspace --all-targets -- -D warnings and cargo +nightly fmt --all --check. I didn't run the openssl_crypto variant because this machine has no OpenSSL headers. The change doesn't touch crypto.
  • My distro has shipped this change downstream since 2026-09-10. A test there starts the daemon first and the helper 150 ms later, then checks that the daemon logs "Received login secret from helper" and that the login collection comes up unlocked.

I wrote this with AI assistance (Claude Opus 5.5) and reviewed and tested it before opening the PR.

@github-actions

Copy link
Copy Markdown

📊 Code Coverage Report

Metric Value
Current PR Coverage 83.34%
Main Branch Coverage 83.37%
Coverage Change 📉 -0.03%

Coverage report generated by cargo-tarpaulin

Comment thread server/src/main.rs Outdated
pam_oo7's auto_start fallback forks oo7-daemon-login from the same PAM
session stack whose pam_systemd.so starts oo7-daemon.service, so the
daemon can try to connect to oo7-daemon-login.sock before the helper
has bound it. read_secret_from_login_helper() made a single connect
attempt and returned None on failure. The login secret was then
dropped, the login collection stayed locked for the whole session, and
nothing was logged on either side.

On a greetd login the daemon's connect landed about 37 ms before the
helper bound its socket.

Retry the connect every 10 ms for up to 500 ms. On the login path the
helper shows up within tens of milliseconds. When no helper is coming,
such as a manual restart of the service, startup is 500 ms slower.

Assisted-by: Claude Opus 5.5
@kitten-lily
kitten-lily force-pushed the fix/login-helper-connect-retry branch from 626ed0a to 7257cdf Compare October 24, 2026 18:22
@bilelmoussaoui
bilelmoussaoui merged commit b54f8e7 into linux-credentials:main Oct 24, 2026
8 of 9 checks passed
@bilelmoussaoui

Copy link
Copy Markdown
Collaborator

thanks

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants