fix: prevent Linux power inhibitor auth loops (fixes #763) - #784
Merged
Conversation
Greptile SummaryThis PR fixes the Linux power inhibitor retry loop. The main changes are:
Confidence Score: 5/5Safe to merge with minimal risk. The change is narrowly scoped to the power inhibitor module and preserves the successful TTL refresh path. The updated Linux failure path has focused tests for command construction and retry suppression. No functional or security issues were identified. Files Needing Attention: No files require special attention.
What T-Rex did
|
| Filename | Overview |
|---|---|
| crates/jcode-base/src/power_inhibit.rs | Updates Linux systemd inhibitor handling to use noninteractive Polkit, disable retries after unsuccessful helper exits, and add focused tests. |
Sequence Diagram
sequenceDiagram
participant Reconcile as set_active(true)
participant Inhibitor as PowerInhibitor.acquire
participant Child as systemd-inhibit child
participant State as PowerInhibitor state
Reconcile->>Inhibitor: request active inhibitor
Inhibitor->>Child: try_wait/status existing handle
alt Linux child exited unsuccessfully
Inhibitor->>State: release handle
Inhibitor->>State: "available = false"
Inhibitor-->>Reconcile: stop retrying this process
else handle running and fresh
Inhibitor-->>Reconcile: keep existing helper
else missing/stale/successfully exited helper
Inhibitor->>Child: "spawn systemd-inhibit --no-ask-password sleep <TTL>"
Inhibitor->>State: store handle and acquired_at
end
Reviews (1): Last reviewed commit: "fix: prevent Linux power inhibitor auth ..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
systemd-inhibituse noninteractive Polkit authorizationRoot cause
spawn()returned before Polkit authorization completed, so Jcode recorded the helper as acquired. After authorization failed and the child exited, the five-second reconciliation loop launched a new interactive helper indefinitely.Validation
cargo fmt --all -- --checkgit diff --checkcargo test -p jcode-base --no-default-features power_inhibit -j 1(6 passed)--- — Jcode agent (automated triage), on behalf of @1jehuang