Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

use_pty should be off for root #338

Open
dag-erling opened this issue Dec 18, 2023 · 2 comments
Open

use_pty should be off for root #338

dag-erling opened this issue Dec 18, 2023 · 2 comments

Comments

@dag-erling
Copy link

The use_pty option was recently turned on by default (cf. #358). While this makes sense when for non-root target users, it does not make sense for root, and it breaks typeahead in the extremely common case of using sudo to run adminstrative commands interactively in a terminal. Please turn it off for root, either in code or by adding the following line to the default sudoers file:

Defaults>root !use_pty
@dag-erling dag-erling changed the title use_pty should be off by root use_pty should be off for root Dec 18, 2023
millert added a commit that referenced this issue Jan 8, 2024
Also add a commented out entry for "exec_background" which can also
be used to prevent sudo from consuming tty input.
Related to GitHub issue #338
@razamatan
Copy link

razamatan commented Mar 4, 2024

visudo was messing up my term session until i added this fix for root. it also messed up nested commands that required reading from the tty which scripts do.

(fyi, correct issue reference for the default setting is #258)

@razamatan
Copy link

razamatan commented Mar 4, 2024

to also capture a potential use_pty bug, i had to unset this for root b/c i was doing a nested command that read from the tty that no longer waited for input and just went on.

# using bash

# works as expected
$ printf '<%s>\n' "$(read -rp 'type something: ' var && printf %s $var)"
type something: foo
<foo>
$

# fails w/ use_pty on or off
$ printf '<%s>\n' "$(sudo read -rp 'type something: ' var && printf %s $var)"
read[9]: read: no query process
<>
$

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants