Skip to content

Keep terminal in a sane state when sudo use_pty is used.#923

Merged
brianmay merged 1 commit intosshuttle:masterfrom
skuhl:dont-break-terminal
Jan 5, 2024
Merged

Keep terminal in a sane state when sudo use_pty is used.#923
brianmay merged 1 commit intosshuttle:masterfrom
skuhl:dont-break-terminal

Conversation

@skuhl
Copy link
Contributor

@skuhl skuhl commented Jan 4, 2024

This fixes #909 and is an alternative to the #922 pull request. When sudo's use_pty is used with sshuttle, it causes issues with the terminal. Pull request #712 contains some fixes for this problem. However, when sshuttle is run with the --daemon option, it left the user's terminal in a non-sane state. The problem appears to be related to a socketpair that the firewall uses for communication. By setting it up slightly differently (see changes to client.py and firewall.py), the terminal state is no longer disrupted. This commit also changes line endings of the printed messages from \r\n to \n. This undoes a change introduced by pull request #712 and is no longer needed.

This fixes sshuttle#909 and is an alternative to the sshuttle#922 pull request. When
sudo's use_pty is used with sshuttle, it causes issues with the
terminal. Pull request sshuttle#712 contains some fixes for this problem.
However, when sshuttle is run with the --daemon option, it left the
user's terminal in a non-sane state. The problem appears to be related
to a socketpair that the firewall uses for communication. By setting
it up slightly differently (see changes to client.py and firewall.py),
the terminal state is no longer disrupted. This commit also changes
line endings of the printed messages from \r\n to \n. This undoes a
change introduced by pull request sshuttle#712 and is no longer needed.
# with \r\n endings fixes that problem and does not appear
# to cause problems elsewhere.
sys.stderr.write(prefix + line + "\r\n")
sys.stderr.write(prefix + line + "\n")

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information

This expression logs [sensitive data (password)](1) as clear text. This expression logs [sensitive data (password)](2) as clear text.
@skuhl
Copy link
Contributor Author

skuhl commented Jan 4, 2024

@dancek, does this fix the problem for you? Any thoughts? I very much appreciate your pull request. It helped me more quickly figure out this solution---which seems to get at the root of the problem.

@dancek
Copy link

dancek commented Jan 5, 2024

Yes, this seems to work for me. Looks like a good fix for the root cause, good job!

@brianmay brianmay merged commit a604d10 into sshuttle:master Jan 5, 2024
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.

Terminal broken with python3.12

3 participants