cruxpot
2016-02-24 20:01:37 UTC
I'm having an issue getting run and sudo to separate the streams which is
causing issues particularly where sudo presents a first time "lecture"
banner or an error before it runs the command and produces expected output.
In this case, the sudo error is a resolution error on a debian 7 host
running 'whoami'. I have set env.combine_stderr globally (env set at
beginning), "with settings" and as a kwargs argument for sudo(). Same
result, everything goes to stdout no matter I do.
combine_stderr: 'False'
[***@debian7_x64:22] sudo: busybox whoami
[***@debian7_x64:22] out: sudo: unable to resolve host debian7_x64
[***@debian7_x64:22] out: sudo password:
[***@debian7_x64:22] out: root
[***@debian7_x64:22] out:
cmd: 'sudo -S -p 'sudo password:' bash -l -c "cd /tmp/tmpdir2 >/dev/null
&& export PATH=\"\".:/tmp/tmpdir2:/bin:/usr/bin\"\" && whoami"' SUCCEEDED
with return code: '0', output:
sudo: unable to resolve host debian7_x64
Return values (result.stdout and result.stderr) are:
stdout: 'sudo: unable to resolve host debian7_x64
root'
stderr: ''
The "unable to resolve host" should go into stderr and I have confirmed
this manually on a shell that it is in fact stderr. Why is this not
working? It causes parsing issues as I want to discard the error output. I
know the box is misconfigured but that is on purpose (simply remove its
host definition in /etc/hosts).
Code:
with settings(combine_stderr=False):
logger.debug("combine_stderr: '%s'" % env.combine_stderr)
result = sudo(cmd, combine_stderr=False)
causing issues particularly where sudo presents a first time "lecture"
banner or an error before it runs the command and produces expected output.
In this case, the sudo error is a resolution error on a debian 7 host
running 'whoami'. I have set env.combine_stderr globally (env set at
beginning), "with settings" and as a kwargs argument for sudo(). Same
result, everything goes to stdout no matter I do.
combine_stderr: 'False'
[***@debian7_x64:22] sudo: busybox whoami
[***@debian7_x64:22] out: sudo: unable to resolve host debian7_x64
[***@debian7_x64:22] out: sudo password:
[***@debian7_x64:22] out: root
[***@debian7_x64:22] out:
cmd: 'sudo -S -p 'sudo password:' bash -l -c "cd /tmp/tmpdir2 >/dev/null
&& export PATH=\"\".:/tmp/tmpdir2:/bin:/usr/bin\"\" && whoami"' SUCCEEDED
with return code: '0', output:
sudo: unable to resolve host debian7_x64
Return values (result.stdout and result.stderr) are:
stdout: 'sudo: unable to resolve host debian7_x64
root'
stderr: ''
The "unable to resolve host" should go into stderr and I have confirmed
this manually on a shell that it is in fact stderr. Why is this not
working? It causes parsing issues as I want to discard the error output. I
know the box is misconfigured but that is on purpose (simply remove its
host definition in /etc/hosts).
Code:
with settings(combine_stderr=False):
logger.debug("combine_stderr: '%s'" % env.combine_stderr)
result = sudo(cmd, combine_stderr=False)