-
-
Notifications
You must be signed in to change notification settings - Fork 502
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
Info pushed to stdout instead of variable when invoked with contirb.sudo #722
Comments
Thanks for the report. I cannot reproduce this, on Ubuntu 20.04. What is the output you see? Also, are you sure the tool is not printing to stderr? You can try redirecting stderr to stdout. |
Hi ecederstrand, |
That redirects stdout to stderr, which is the opposite of what you want. Try Also, does this only happen under sudo context? What happens if you run this without sudo, i.e. just import sh
output = sh.blkid(_err_to_out=True) If your normal user doesn't have permissions to run |
Sure thing, here are the various alterations I tried and how they output to bash when run: Ubuntu 22.04 import sh
output = sh.blkid(_err_to_out=True)
print("Done.") Output:
Ubuntu 22.04 import sh
password = input("Enter password: ")
with sh.contrib.sudo(password=password, _with=True):
output = sh.blkid(_err_to_out=True)
print("Done.") Output:
Ubuntu 20.04 import sh
output = sh.blkid(_err_to_out=True)
print("Done.") Output:
Ubuntu 20.04 import sh
password = input("Enter password: ")
with sh.contrib.sudo(password=password, _with=True):
output = sh.blkid(_err_to_out=True)
print("Done.") Output:
|
I tried this on Ubuntu 22.04, python 3.10.12, sh 2.0.6, and still cannot reproduce. In your non-working case, does |
It is empty, the contents are output to bash instead of to the output variable. I'm not sure if this helps because I haven't used pdb much in large projects using threads before, but I found that when I tried to trace the issue to a specific line in sh if I tried to step past (not into) line 2061 pdb would freeze or crash and I wouldn't be able to continue the debug. If I continued past it handled it fine and then would produce the erroneous behavior shown in example 2. I'll also try to reproduce the bug on different hardware to try and rule that out, this might some how be specific to atom processors or something strange like that. |
Hi there,
I have come across a bug when I have been trying to make a call to blkid using sudo with sh. Instead of pushing the output of stdout in the sh call to a variable it instead sends the output to the user's stdout, and the variable is empty. I have attached a minimum viable test file that has shown to reproduce the issue in my environment.
Environment details:
OS - Ubuntu 22.04
Kernel - 6.5.0-27-generic
blkid version - 2.37.2
Python version - 3.10.12
Sh version - 2.0.6
The text was updated successfully, but these errors were encountered: