Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Sudo Prompt is present in process stdout with pty=True #2034

Open
hrehfeld opened this issue Nov 3, 2019 · 0 comments
Open

Sudo Prompt is present in process stdout with pty=True #2034

hrehfeld opened this issue Nov 3, 2019 · 0 comments

Comments

@hrehfeld
Copy link

hrehfeld commented Nov 3, 2019

As mentioned in #1322 , pty=True implies that stdout and stderr are merged.

However, if using sudo, I would strongly classify it as a bug to not remove the sudo prompt:

import fabric
import getpass
with fabric.Connection(host='localhost') as c:
    c.config.sudo.password = getpass.getpass()
    r = c.sudo('cat /etc/passwd', pty=True)
    print('stdout=')
    print(r.stdout)

results in:

stdout=
[sudo] password: 
</etc/passwd file>

I would expect sudo() to remove the sudo prompt, e.g. something like this:

assert r.stdout.startswith(sudo_prompt)
r.stdout = r.stdout[len(sudo_prompt):]
return r
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

No branches or pull requests

1 participant