Repository navigation
Conversation
'sudo <tool>' was rewritten to 'sudo rtk <tool>', inserting rtk into the elevation: its SQLite history writes, tee files, config parsing and telemetry ping all ran as root, and the target binary was resolved by rtk inside the elevated process instead of by sudo's secure_path (rtk-ai#3412). Commands with a sudo prefix are now passed through unrewritten. Plain env-assignment and 'env' prefixes still rewrite as before.
1958745 to
8f36ad8
Compare
|
Thank you for this, and sorry it took a while to get a decision. Your analysis of the problem is correct and well argued — the comment you wrote ( I'm closing this in favour of #2810, which reaches the same passthrough behaviour but at a different point in the pipeline — and that difference matters for what comes next. Why the location matters. This PR guards inside Behaviourally the two are equivalent today. They diverge on #146 ( That design needs a Nothing you raised is being dropped. All four of your motivating cases — Two follow-ups also came out of this area, both filed: #3756 and #3757. Closing as superseded rather than rejected — the fix is landing, just one layer up. Thanks again for the report and the diagnosis. |
Summary
sudoin front of the rewritten command (sudo iptables -L→sudo rtk iptables -L), inserting rtk into the elevation the user granted to exactly one binary. An elevated rtk then writes the SQLite history db and tee files, parses config and fires the telemetry ping as root (leaving root-owned files in user-owned data directories), and resolves the target binary itself instead of lettingsudo'ssecure_pathdo it.rewrite_segment_innernow returnsNonewhen the stripped env prefix contains asudotoken, so sudo-prefixed commands pass through unrewritten — the same mechanism already used forRTK_DISABLED=. Plainenv/VAR=valprefixes still rewrite as before, and the suppression also covers compositions likesudo noglob git statusandenv FOO=1 sudo ….rtk sudo <tool>(no such passthrough exists today) — sudo-prefixed commands are rare and typically short-output, so the token cost of not filtering them is negligible next to running rtk's side effects as root.Test plan
cargo fmt --all --checkcargo clippy --all-targets(no warnings)cargo test— 2661 passed, 8 ignoredsudo docker ps→ no rewrite,env FOO=1 sudo iptables -L→ no rewrite,sudo noglob git status→ no rewrite,FOO=1 noglob git statusstill rewrites.rtk rewrite "sudo docker ps"exits 1 (no rewrite);rtk rewrite "docker ps"andrtk rewrite "FOO=1 git status"still rewrite (exit 3).Fixes #3412