Repository navigation
--pkexec with a multi-leaf privileged plan skips the TUI prompt; dialogs show only /usr/bin/env per leaf - #94
Open
cuihtlauac wants to merge 5 commits into
Open
cuihtlauac wants to merge 5 commits into
cuihtlauac wants to merge 5 commits into
Conversation
cuihtlauac
commented
Nov 20, 2026
cuihtlauac
left a comment
Member
Author
There was a problem hiding this comment.
🤖 Code review (Fable) — round 1
Verdict: approve-with-nits
Reviewed the whole diff of PR #94 against the "Approved plan (Claude) — final" comment on #88. The predicate, its call site, the three new tests and the doc edits match the plan. No blocker.
What I checked myself, on the branch in a separate worktree:
cargo clippy --all-targets --all-features -- -D warnings(the CI invocation): clean.cargo test --no-fail-fast(debug): every suite passes, includingconcurrency::burst_connections_above_cap_get_busy_response, which the PR description reports as flaky-only.- The three new tests pass. With the old gate (
pkexec_only && mode == Mode::Local && req.privileged) restored temporarily,tests/plan_exec.rspkexec_mode_prompts_for_multi_leaf_privileged_plansfails at the firstcall_countassertion (run: the TUI prompt was skipped) andtests/pty_e2e.rspkexec_flag_multi_step_plan_gets_the_tui_promptfails waiting for a prompt that never comes. No polkit dialog appeared (the argv is a nonexistent program, sobuild_commandfails first, as the plan's safety argument says). Both tests are therefore the regression tests the issue asks for, not vacuous ones. delegate_to_pkexecreads theplan_displayviews computed before theno_shellcheck, so the decision and the prompt see the same leaves; a flat single-stagepipeline, and a singlechdir/setenv-wrapped leaf, still delegate, as the plan intends.with-stdin-fromcompiles to< pathinsummarize_redirects, so it is covered by the "no redirection" conjunct, and> /dev/null/2>&1likewise route to the TUI.- Audit:
Outcome::Pkexecis tied touse_pkexec, so the routed shapes recordapproved/denied/timeout; the integration test checks the per-request record and that none ispkexec. docs/assurance-case.mdG5.1: the TLC-pinned sentence is byte-identical; the exception is a separate sentence pointing to G5.4 (P6 followed).- Kani: not run, and correctly not claimed.
src/proofs.rsand the functions it proves are untouched. - Goldens: unchanged, consistent with no rendering change.
Deviations from plan (all accepted):
- Extra unit-table cases (
2>&1, mixed-privilege pair, explicitDirect): additions only; they tighten the table. - The pty test asserts
mode: local (TUI + pkexec)in the daemon log: this is the non-vacuity check the plan asked for, made explicit. Good. docs/pkexec.mdnameswith-stdin-from: accurate (it is a<redirection on the leaf).- New backlog item numbered 7 after item 6, nothing renumbered: fine.
Nits handling: P3–P7 and P9 applied or followed as reported; P8 dropped with a valid reason (plan-text line references only).
should-fix
- C1 —
src/server.rs:1136-1138— The doc comment/// --log-json prints request bytes before validation … must come out inert.belongs toescape_for_terminal_neutralises_control_and_bidi, but the newleaf_viewhelper anddelegate_to_pkexec_only_for_a_single_plain_leafwere inserted between that comment and its test. The helper now carries a doc comment about--log-json, and the escape test has none. Move the two new items above that comment (or below the escape test). - C2 —
backlog.md:155— The Phase 0 paragraph was edited in place and reflowed into one 128-column line (… · ~~#88 \--pkexec` multi-leaf plans~~ (done) · #87 …). The batch instruction asks for minimal, append-only edits tobacklog.md/changelog.md/docs/assurance-case.mdso the four PRs rebase cleanly in the order #86, #85, #88, #87. PR #93 (#85, merged before this one) leaves that paragraph untouched and appends aDone: #85.line right after it; this hunk is adjacent to that insertion and will conflict on rebase. Keep the two original lines unwrapped and either strike#88 …in place without reflowing, or follow #93's convention and append (Done: #88.`). The item-6 replacement in the Priority #1 list is what the plan prescribes and is fine.
follow-up
None.
nit
- C3 —
tests/plan_exec.rs:400and:456,tests/pty_e2e.rs:190-208— rustfmt would reshape these new lines (set_responsechain, twoassert!, thePlan::Exec/Plan::Runliterals). The PR description says the new lines follow rustfmt except inpty_e2e.rs; the twoplan_exec.rsspots do not. CI does not runcargo fmt --checkandmainalready drifts, so cosmetic only. Apply if you touch those lines for C1/C2, otherwise drop. - C4 —
tests/common/pty.rs:17— The module doc now reads "noDISPLAY/WAYLAND_DISPLAYunlessPtyOpts::envsets one (soMode::Remote: TUI prompt + sudo)", which attaches theMode::Remoteconsequence to the "unless" clause, and the line is now over 100 columns. Suggest: "noDISPLAY/WAYLAND_DISPLAY(soMode::Remote: TUI prompt + sudo) unlessPtyOpts::envsets one". - C5 —
changelog.md:19— "backlog items 6 and 7" pins backlog numbering that the plan itself says may shift (this PR already renumbered item 6's content). Naming them ("the/usr/bin/envdialog item and thesetenv-under-pkexec item") would survive a reshuffle.
Manual test: the PR's three-step manual test (multi-step → TUI + sudo; redirected single step → TUI; single plain step → pkexec dialog) matches the plan's, with P9's note on where sudo's password prompt appears. Nothing to add.
#88) pkexec's dialog shows one argv (as `env -C DIR -- BIN args`) and never the files the daemon opens for a redirection. Delegating a multi-step plan meant no dialog showed the whole plan, and under `pkexec-cache` later steps ran with no dialog at all. New pure predicate `delegate_to_pkexec`: delegate only a `privileged: true` request whose `plan_display` views are exactly one escalated leaf with no redirection. Every other privileged request takes the TUI prompt and sudo, as `run-as`-only plans already did. Unit table covers each conjunct. `--pkexec` help text updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
…pkexec (#88) tests/plan_exec.rs: run/seq/alt/pipe of two leaves, a redirected leaf and a with-stdin-from leaf each prompt once, are denied, and leave one `denied` audit record; no record is `pkexec` and the redirect target is never created. Every argv[0] is a nonexistent program, so a regressed gate fails at build_command and never raises a polkit dialog. tests/pty_e2e.rs: the same through the real CLI (`--pkexec`, DISPLAY set so Mode::detect is Local), with a new `PtyOpts::env`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
…log (#88) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
…backlog edit) Move the --log-json doc comment back onto its escape test (the new leaf_view helper had been inserted under it), and restore the Phase 0 backlog paragraph, appending 'Done: #88.' instead of reflowing it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
rustfmt the new pkexec test in tests/plan_exec.rs, reorder the tests/common/pty.rs module doc so the Mode::Remote consequence sits on the no-DISPLAY clause, and name the backlog items in the changelog instead of pinning their numbers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
cuihtlauac
force-pushed
the
fix/88-pkexec-multileaf
branch
from
November 22, 2026 05:35
f55bd77 to
acfe99e
Compare
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
Under
--pkexec, everyprivileged: truerequest went to pkexec, one dialog per escalated step. A pkexec dialog shows a single argv (named/usr/bin/env, since steps run aspkexec env -C DIR -- argv) and never the files the daemon opens for a redirection. So no dialog showed the whole plan, and withpkexec-cachethe later steps ran with no dialog at all.This PR implements the approved plan (issue #88, comment "Approved plan (Claude) — final"):
delegate_to_pkexecinsrc/server.rs: approval is delegated to pkexec only for aprivileged: truerequest whoseplan_displayviews are exactly one escalated leaf with no redirection. It reads the same views the prompt renders.with-stdin-from, or escalating only throughrun-as) takes the TUI prompt and runs through sudo, the existing pathrun-as-only plans already used.--pkexechelp text updated.docs/pkexec.mdrouting paragraph; assurance case G5.4 / Sn5.4 and a separate--pkexecexception sentence on G5.1; threat-model leaf 4.5 and its residual bullet; changelog entry; backlog item 6 replaced (pkexec dialog names/usr/bin/env), new item 7 (does a single-leafsetenvreach the program under pkexec?), and aDone: #88.line appended after the Phase 0 paragraph (append-only, in the style of Approval prompt: bound Steps: lines (and every prompt line) so a long argument cannot push [y/N] off-screen #93).Behaviour change for
--pkexecusers: privileged multi-step plans and redirected single steps now show the TUI prompt and run through sudo. A user without sudo rights gets a sudo failure after approving, as forrun-asplans already. With no usable/dev/tty, these requests fail closed withprompt error. They are audited asapproved/denied/timeoutinstead ofpkexec.Fixes #88
Part of #89
Test evidence
cargo clippy --all-targets: no warnings.cargo fmt --check: reports drift, all pre-existing (it lists files this PR does not touch, e.g.src/audit.rs,src/executor.rs,src/gui.rs). The newtests/plan_exec.rstest now followsrustfmt(review nit C3); the newpty_e2e.rstest keeps that file's existing one-line style.cargo test --no-fail-fast(debug), after the review fixes: first full run, every suite passes exceptconcurrency::burst_connections_above_cap_get_busy_response, the known flaky burst test (other worktrees were building in parallel on the same machine). Second full run: 263 passed, 0 failed.cargo test --test concurrencyalone: 13 passed. The burst test sends plaintruerequests to a server withoutpkexec_only, so it does not reach the changed code.server::tests::delegate_to_pkexec_only_for_a_single_plain_leaf: unit table (one Root / oneUser("nobody")leaf → true; 0 or 2 leaves,>,<,2>&1, aDirectleaf,pkexec_only = false,Mode::Remote,privileged = false→ false).tests/plan_exec.rspkexec_mode_prompts_for_multi_leaf_privileged_plans: run / seq / alt / pipe of two leaves, a stdout-redirected leaf, awith-stdin-fromleaf. For each request: the prompt count goes up by exactly 1, the status isDenied, the record for that request id (audit_for) has outcomedenied, and the record count equals the number of requests sent so far. At the end: no record ispkexec, and the redirect target was never created.tests/pty_e2e.rspkexec_flag_multi_step_plan_gets_the_tui_prompt: real binary with--pkexecandDISPLAY=:99(newPtyOpts::env); asserts that the daemon log saysmode: local (TUI + pkexec)(so the test is not vacuous), the prompt saysExecute as root?and shows both steps, the response isDenied, and the sudo shim log is empty.pkexec_only && mode == Mode::Local && req.privileged) restored temporarily, the integration test fails withrun: the TUI prompt was skipped.sudo-proxy-test-88-no-such-cmd). If the gate regresses,check_pkexec_leavesruns its harmlessenv -C / -- trueprobe (plainenv, not pkexec) once, thenbuild_commandfails withcommand not foundbefore any pkexec spawn. The response is an error, the audit outcome ispkexecand the prompt count does not move, so the test fails and no polkit dialog ever names the test program.src/proofs.rsand the functions it proves are unchanged. As the plan says, the predicate is covered by the exhaustive unit table.Deviations from plan
2>&1, two leaves with different privileges, and an explicitDirectleaf. These are additions, not changes.mode: local (TUI + pkexec)in the daemon log. That makes the plan's "not vacuous" requirement explicit.docs/pkexec.mdalso listswith-stdin-fromamong the routed shapes. It compiles to a<redirection, which the plan already covers.Nits
Plan review:
src/bin/sudo-proxy.rs).req_privileged, and its doc comment says it is the raw flag, noteffective_privileged().--pkexecexception is a separate sentence pointing to G5.4.--pkexecin the changelog heading): applied.Code review:
tests/plan_exec.rs(theset_responsechain and the finalassert!). Thetests/pty_e2e.rspart is dropped: that file is not rustfmt-formatted, and the new test keeps its one-line style.tests/common/pty.rsmodule doc clause order and width): applied.Follow-ups
None opened. The code review raised no follow-up items, and none of #90, #91, #92 concerns this issue. The plan's residuals are recorded as backlog items ("pkexec dialog names
/usr/bin/env" and "Does a single-leaf plan'ssetenvreach the program under--pkexec?") rather than as issues, as the plan specifies.Review
escape_for_terminal_neutralises_control_and_bidihad ended up on the newleaf_viewhelper): fixed; the comment is back on its test.backlog.mdreflowed in place, conflicting with Approval prompt: bound Steps: lines (and every prompt line) so a long argument cannot push [y/N] off-screen #93): fixed; the paragraph is restored byte-for-byte andDone: #88.is appended after it, in Approval prompt: bound Steps: lines (and every prompt line) so a long argument cannot push [y/N] off-screen #93's style. When rebasing after Approval prompt: bound Steps: lines (and every prompt line) so a long argument cannot push [y/N] off-screen #93, keep bothDone:lines.Manual test before merge
Run from a graphical terminal, so that
DISPLAYorWAYLAND_DISPLAYis set. Build withcargo build --releaseon this branch.Terminal A (the daemon; the TUI prompt and sudo's password prompt appear here):
./target/release/sudo-proxy -v --pkexec --socket "$XDG_RUNTIME_DIR/sp-test-88.sock"Check that the startup lines include
mode: local (TUI + pkexec).Terminal B (the requester):
Execute as root?with both steps. No polkit dialog appears.y. If sudo has no cached credentials, its password prompt appears in terminal A. Terminal B printsrootand0.n. Terminal B printsRequest denied.; the audit line in terminal A saysdenied, notpkexec.> /dev/null, and no polkit dialog appears. Answern; expectRequest denied../target/release/sudo-request --socket "$XDG_RUNTIME_DIR/sp-test-88.sock" --print id -un/usr/bin/env). After authentication, terminal B printsroot, and the audit line sayspkexec.Stop the daemon with Ctrl-C in terminal A.
🤖 Generated with Claude Code