Navigation Menu

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

Connection.sudo() sometimes raises ThreadException/OSError instead of AuthFailure #2055

Closed
amezin opened this issue Feb 18, 2020 · 5 comments

Comments

@amezin
Copy link

amezin commented Feb 18, 2020

invoke.exceptions.ThreadException: 
Saw 1 exceptions within threads (OSError):


Thread args: {'kwargs': {'buffer_': ['[sudo] password: '],
            'hide': False,
            'output': <_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>},
 'target': <bound method Runner.handle_stderr of <fabric.runners.Remote object at 0x7f066e63a9e8>>}

Traceback (most recent call last):

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/invoke/util.py", line 233, in run
    super(ExceptionHandlingThread, self).run()

  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/invoke/runners.py", line 750, in handle_stderr
    buffer_, hide, output, reader=self.read_proc_stderr

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/invoke/runners.py", line 717, in _handle_output
    self.respond(buffer_)

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/invoke/runners.py", line 884, in respond
    self.write_proc_stdin(response)

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/invoke/runners.py", line 960, in write_proc_stdin
    self._write_proc_stdin(data.encode(self.encoding))

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/fabric/runners.py", line 67, in _write_proc_stdin
    return self.channel.sendall(data)

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/paramiko/channel.py", line 846, in sendall
    sent = self.send(s)

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/paramiko/channel.py", line 801, in send
    return self._send(s, m)

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/paramiko/channel.py", line 1198, in _send
    raise socket.error("Socket is closed")

OSError: Socket is closed
@matt-hayden
Copy link

matt-hayden commented Apr 9, 2020

I think what you might be seeing is a different error: I don't think it's getting to the sudo auth phase. I'm seeing this on Python 2.7 but only when stdin is redirected from /dev/null. Maybe try again with pty=True?

@luke-goddard
Copy link

@matt-hayden After hours of debugging you just saved me from a mental breakdown. I would also like to add that I only got this error while using multiprocessing.Process even if it's just one process.

@amezin
Copy link
Author

amezin commented May 20, 2020

@matt-hayden I've seen this issue on python 3.6, ssh'ing into local Ubuntu 18.04 container (with openssh sshd running in it). The same 'sudo' command in exactly the same configuration was working correctly 99% of the time (raising AuthFailure) and raising OSError in the remaining 1%.
I can't remember if pty was set to True.

Anyway, I'm not using fabric now, and I don't have time to verify that this issue is still present. So I guess I should close the issue

@amezin amezin closed this as completed May 20, 2020
@luke-goddard
Copy link

The error happened, again and yes I was also using a docker container

@matt-hayden
Copy link

@luke-goddard , if it occurred within paramiko (like the traceback above) then maybe this is more appropriate as an issue in the paramiko project.

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

3 participants