fix: complete PTY terminal modes and Shift key input support#41
Merged
fix: complete PTY terminal modes and Shift key input support#41
Conversation
This commit fixes two critical issues preventing sudo password input
from working correctly in interactive PTY sessions:
1. Incomplete Terminal Modes Configuration
- Added all OpenSSH-compatible terminal mode settings (RFC 4254)
- Control characters: VEOL, VEOL2, VSTART, VSTOP, VREPRINT, VWERASE, VLNEXT, VDISCARD
- Input modes: IGNPAR, PARMRK, INPCK, ISTRIP, INLCR, IGNCR
- Local modes: NOFLSH, TOSTOP, PENDIN
- Output modes: OCRNL, ONOCR, ONLRET
- Control modes: PARENB, PARODD
- These settings ensure proper terminal behavior for interactive programs
2. Shift Key Input Bug
- Fixed key_event_to_bytes() to accept SHIFT modifier
- Previously only accepted KeyModifiers::NONE, blocking uppercase letters
and special characters that require Shift key
- Now accepts characters with no modifiers or SHIFT modifier only
- Rejects CONTROL, ALT, META combinations (handled separately)
Impact:
- Passwords with uppercase letters and special characters now work correctly
- Fixes issue where Linux remote hosts rejected password input
- macOS localhost previously worked due to simpler password requirements
Fixes #40
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
This PR fixes critical issues preventing sudo password input from working correctly in interactive PTY sessions by completing terminal mode configuration and fixing Shift key input handling.
Changes
1. Complete Terminal Modes Configuration (RFC 4254)
Added all OpenSSH-compatible terminal mode settings for proper PTY behavior:
Control Characters:
Input Modes:
Local Modes:
Output Modes:
Control Modes:
2. Shift Key Input Bug Fix
Fixed
key_event_to_bytes()function insrc/pty/session.rs:KeyModifiers::NONE, blocking uppercase letters and special charactersRoot Cause Analysis
The issue occurred because:
Impact
Before
After
Testing
Tested with:
sudo -swith complex passwords (uppercase + special characters)passwdcommand for password changesRelated Issues
Closes #40
Files Changed
src/pty/session.rs: Terminal modes configuration and Shift key input handling