Skip to content

fix(memtrack): prompt sudo on interactive stdin - #459

Merged
not-matthias merged 2 commits into
mainfrom
cod-3153-memtrack-sudo-password-prompt-skipped-when-stdout-is
Jul 27, 2026
Merged

fix(memtrack): prompt sudo on interactive stdin#459
not-matthias merged 2 commits into
mainfrom
cod-3153-memtrack-sudo-password-prompt-skipped-when-stdout-is

Conversation

@not-matthias

@not-matthias not-matthias commented Jul 17, 2026

Copy link
Copy Markdown
Member

validate_sudo_access previously checked stdin/stdout directly, so both redirected output and piped input could skip the password prompt even when the process still had a controlling terminal. The subsequent non-interactive sudo command then failed when credentials were not cached.

Use /dev/tty to detect whether sudo can prompt through the controlling terminal. Add a Linux integration test that launches a real Bash command with piped stdin and redirected stdout, then verifies a fake sudo receives --validate before the non-interactive command.

Fixes COD-3153

@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes sudo prompting for memtrack runs when standard streams are redirected. The main changes are:

  • Detects prompt support through the controlling terminal.
  • Uses that detection before running sudo --validate.
  • Adds a Linux test for piped stdin and redirected stdout.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
src/executor/helpers/run_with_sudo.rs Updates sudo validation to check for a controlling terminal before prompting.
tests/sudo_prompt.rs Adds Linux coverage for sudo validation with piped stdin and redirected output.

Reviews (4): Last reviewed commit: "fix(memtrack): detect sudo prompts via c..." | Re-trigger Greptile

Comment thread src/executor/helpers/run_with_sudo.rs Outdated
@codspeed-hq

codspeed-hq Bot commented Jul 17, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 17 untouched benchmarks


Comparing cod-3153-memtrack-sudo-password-prompt-skipped-when-stdout-is (cecd3f8) with main (8611106)

Open in CodSpeed

@not-matthias
not-matthias force-pushed the cod-3153-memtrack-sudo-password-prompt-skipped-when-stdout-is branch from 50c3e26 to 8c8e200 Compare July 21, 2026 18:21
@not-matthias
not-matthias marked this pull request as ready for review July 21, 2026 18:22
@not-matthias
not-matthias force-pushed the cod-3153-memtrack-sudo-password-prompt-skipped-when-stdout-is branch from 8c8e200 to 2915940 Compare July 21, 2026 18:22
Use the controlling input terminal to decide whether sudo can prompt for a password. Keep the non-interactive wrapper safe after credentials are validated.\n\nFixes COD-3153
Use /dev/tty so piped stdin still prompts when a controlling terminal is available. Add a Bash regression covering piped stdin and redirected stdout.\n\nRefs COD-3153
@not-matthias
not-matthias force-pushed the cod-3153-memtrack-sudo-password-prompt-skipped-when-stdout-is branch from 2915940 to cecd3f8 Compare July 27, 2026 10:43
@not-matthias
not-matthias merged commit 8018219 into main Jul 27, 2026
23 checks passed
@not-matthias
not-matthias deleted the cod-3153-memtrack-sudo-password-prompt-skipped-when-stdout-is branch July 27, 2026 10:50
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