@@ -101,33 +101,18 @@ def check_channel_forward_agent_request(self, channel):
101101
102102 def check_channel_exec_request (self , channel , cmd ):
103103 logger .debug ("Got exec request on channel %s for cmd %s" % (channel , cmd ,))
104- # Remove any 'bash -c' and/or quotes from command
105- # cmd = cmd.replace('bash -c ', "")
106- # cmd = cmd.replace('\"', "")
107- # cmd = cmd.replace('\'', "")
108- # if not cmd in self.cmd_req_response:
109- # return False
110104 self .event .set ()
111105 process = gevent .subprocess .Popen (cmd , stdout = gevent .subprocess .PIPE , shell = True )
112- # Check if response is an iterator in which case we
113- # do not return but read from iterator and send responses.
114- # This is to simulate a long running command that has not
115- # finished executing yet.
116106 gevent .spawn (self ._read_response , channel , process )
117- # gevent.sleep(1)
118- # else:
119- # channel.send(self.cmd_req_response[cmd] + os.linesep)
120- # channel.send_exit_status(0)
121107 return True
122108
123109 def _read_response (self , channel , process ):
124- # import ipdb; ipdb.set_trace()
125110 for line in process .stdout :
126111 channel .send (line )
127- gevent .sleep (0 )
128112 process .communicate ()
129113 channel .send_exit_status (process .returncode )
130- channel .close ()
114+ logger .debug ("Command finished with return code %s" , process .returncode )
115+ gevent .sleep (0 )
131116
132117def make_socket (listen_ip , port = 0 ):
133118 """Make socket on given address and available port chosen by OS"""
0 commit comments