exception in exception handling of unknown ssh channel

[email protected] Tue, 24 Nov 2009 14:49:51 -0000
Newsgroups gmane.comp.python.twisted.bugs
Message-ID <[email protected]>
New submission from yvesf <None>:

{{{
2009-11-21 20:42:28+0100 [SSHService ssh-connection on SSHServerTransport,1,91.XXX231] Unhandled Error
        Traceback (most recent call last):
        Failure: twisted.conch.error.ConchError: (3, 'unknown channel')
 
2009-11-21 20:42:28+0100 [SSHService ssh-connection on SSHServerTransport,1,XXX231] Unhandled Error
        Traceback (most recent call last):
          File "/usr/lib/python2.5/site-packages/twisted/internet/selectreactor.py", line 146, in _doReadOrWrite
            why = getattr(selectable, method)()
          File "/usr/lib/python2.5/site-packages/twisted/internet/tcp.py", line 362, in doRead
            return self.protocol.dataReceived(data)
          File "/usr/lib/python2.5/site-packages/twisted/conch/ssh/transport.py", line 314, in dataReceived
            self.dispatchMessage(messageNum, packet[1:])
          File "/usr/lib/python2.5/site-packages/twisted/conch/ssh/transport.py", line 336, in dispatchMessage
            messageNum, payload)
        --- <exception caught here> ---
          File "/usr/lib/python2.5/site-packages/twisted/python/log.py", line 51, in callWithLogger
            return callWithContext({"system": lp}, func, *args, **kw)
          File "/usr/lib/python2.5/site-packages/twisted/python/log.py", line 36, in callWithContext
            return context.call({ILogContext: newCtx}, func, *args, **kw)
          File "/usr/lib/python2.5/site-packages/twisted/python/context.py", line 59, in callWithContext
            return self.currentContext().callWithContext(ctx, func, *args, **kw)
          File "/usr/lib/python2.5/site-packages/twisted/python/context.py", line 37, in callWithContext
            return func(*args,**kw)
          File "/usr/lib/python2.5/site-packages/twisted/conch/ssh/service.py", line 44, in packetReceived
            return f(packet)
          File "/usr/lib/python2.5/site-packages/twisted/conch/ssh/connection.py", line 140, in ssh_CHANNEL_OPEN
            common.NS(textualInfo) + common.NS(''))
          File "/usr/lib/python2.5/struct.py", line 63, in pack
            return o.pack(*args)
        exceptions.TypeError: unsupported operand type(s) for &: 'str' and 'long'
}}}
 
##################

{{{
#see line 134 - i am not sure, maybe thats the other way round
http://twistedmatrix.com/trac/browser/trunk/twisted/conch/ssh/connection.py#L139:
130	        except Exception, e:
131	            log.msg('channel open failed')
132	            log.err(e)
133	            if isinstance(e, error.ConchError):
134	                textualInfo, reason = e.args
135	            else:
136	                reason = OPEN_CONNECT_FAILED
137	                textualInfo = "unknown failure"
138	            self.transport.sendPacket(MSG_CHANNEL_OPEN_FAILURE,
139	                                struct.pack('>2L', senderChannel, reason) +
140	                               common.NS(textualInfo) + common.NS('')) 
}}}
after changing line 134 the traceback looks more friendly like this:
{{{
2009-11-24 15:42:28+0100 [SSHService ssh-connection on SSHServerTransport,0,127.0.0.1] got channel direct-tcpip request
2009-11-24 15:42:28+0100 [SSHService ssh-connection on SSHServerTransport,0,127.0.0.1] channel open failed
2009-11-24 15:42:28+0100 [SSHService ssh-connection on SSHServerTransport,0,127.0.0.1] Unhandled Error
        Traceback (most recent call last):
        Failure: twisted.conch.error.ConchError: (3, 'unknown channel')
}}}

I suggest someone who have better undestanding of twisted internals should review this change.

----------
Type     : defect
Component: conch
Keywords : 
Priority : normal
Nosy     : 
----------
http://twistedmatrix.com/trac/ticket/4132