Skip to content

Check for the sudo password prompt and introduce a fallback when the prompt is not detected.#4334

Merged
LiliDeng merged 4 commits intomicrosoft:mainfrom
binojrajan:main
Mar 17, 2026
Merged

Check for the sudo password prompt and introduce a fallback when the prompt is not detected.#4334
LiliDeng merged 4 commits intomicrosoft:mainfrom
binojrajan:main

Conversation

@binojrajan
Copy link
Copy Markdown
Contributor

sudo 1.9.17 flushes the terminal input buffer (tcflush) before reading the password. The old check_and_input_password() sent the password after a blind 0.5-second delay — well before sudo displayed its "Password:" prompt on the slow QEMU (~3 seconds). The password got buffered in the PTY, then sudo flushed it and read nothing, causing it to re-prompt and eventually time out. This is a behavioral change from sudo 1.9.15p5 which read whatever was already buffered.

…prompt is not detected.

sudo 1.9.17 flushes the terminal input buffer (tcflush) before reading the password. The old check_and_input_password() sent the password after a blind 0.5-second delay — well before sudo displayed its "Password:" prompt on the slow QEMU (~3 seconds). The password got buffered in the PTY, then sudo flushed it and read nothing, causing it to re-prompt and eventually time out. This is a behavioral change from sudo 1.9.15p5 which read whatever was already buffered.
@binojrajan
Copy link
Copy Markdown
Contributor Author

binojrajan commented Mar 13, 2026 via email

@LiliDeng LiliDeng requested a review from lubaihua33 March 13, 2026 01:37
@LiliDeng
Copy link
Copy Markdown
Collaborator

@lubaihua33 @paxue do you have any pipelines/scenario to verify this change?

@LiliDeng LiliDeng closed this Mar 13, 2026
@LiliDeng LiliDeng reopened this Mar 13, 2026
@johnsongeorge-w johnsongeorge-w requested a review from Copilot March 13, 2026 13:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates sudo password handling to wait for an actual password prompt (avoiding sudo 1.9.17+ input flush behavior) and adds a fallback path when prompt detection fails, plus an early prompt probe in sudo availability checks.

Changes:

  • Wait for sudo password prompts before sending the password (with timeout + fallback).
  • Add early detection of sudo password prompts during _check_sudo_available.
  • Add additional prompt detection after command completion to classify “sudo needs password” as “sudo available”.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
lisa/util/process.py Detects sudo prompt before sending password; adds timeout and fallback behavior.
lisa/node.py Probes for sudo password prompt early and checks output for prompts to treat sudo as available.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread lisa/node.py Outdated
Comment thread lisa/node.py
Comment thread lisa/util/process.py
Comment thread lisa/util/process.py Outdated
binojrajan and others added 3 commits March 13, 2026 15:03
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves sudo password handling for remote (SSH) command execution by synchronizing password input with the actual sudo prompt, and centralizes sudo prompt strings so Node and Process stay consistent.

Changes:

  • Centralize sudo password prompt substrings into SUDO_PASSWORD_PROMPTS (shared by Process and Node).
  • Update Process.check_and_input_password() to wait for the sudo password prompt (with a fallback) before sending the password to avoid tcflush-related drops on newer sudo versions.
  • Speed up Node._check_sudo_available() by detecting sudo password prompts early during the probe.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
lisa/util/process.py Adds shared sudo prompt constants and changes sudo password input to be prompt-synchronized with a timeout/fallback.
lisa/node.py Reuses shared sudo prompt constants and adds early prompt detection during sudo availability probing.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread lisa/node.py
Comment thread lisa/node.py
Comment thread lisa/util/process.py
@LiliDeng LiliDeng merged commit 53542e9 into microsoft:main Mar 17, 2026
31 checks passed
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.

3 participants