Skip to content

Execute Command doesnt work with dropbear #128

@legraps

Description

@legraps

Environment:
SSHLibrary version: 2.1.1
Paramiko version: 1.15.1
Used interpreter: Python 2.7.6
Operating system: Ubuntu 14.04.1 LTS

Since upgrading dropbear in my embedded target (to 2014.66) Executing Command or rather waiting for the Command Result leads to hanging in an endless loop in read_outputs in paramikos recv_exit_status() function. It seems that upon receiving dropbears EOF we never send a EOF which leads to the connection still being open. SSHLibraries _shell_open() function however makes us think the connection was teared down correctly.

I have tracked down the issue in dropbear to their changeset:

936:d93a6bcf616f
Improve handling lots of concurrent forwarded connections. Increase connection backlog, avoid check_close() for channels that haven't had IO

but I cant actually change that code in our target. (all other ssh connections do work without problems).

So below is a patch that fixes my problem by checking if exit_status_ready() will be successful before actually exexuting recv_exit_status(). In case it's not, the write direction is closed forcefully (which sends out the missing? EOF).

It works for me but I'm not sure if this is ok for everybody...? Any experts on this?

Index: SSHLibrary/src/SSHLibrary/pythonclient.py

--- SSHLibrary.orig/src/SSHLibrary/pythonclient.py 2014-12-15 11:38:59.830379909 +0100
+++ SSHLibrary/src/SSHLibrary/pythonclient.py 2014-12-15 11:40:13.132928618 +0100
@@ -169,6 +169,8 @@

 def read_outputs(self):
     stderr, stdout = self._receive_stdout_and_stderr()
  •    if not self._shell.exit_status_ready():
    
  •        self._shell.shutdown_write()
     rc = self._shell.recv_exit_status()
     self._shell.close()
     return stdout, stderr, rc
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions