[Twisted-Python] More Conch Questions
![](https://secure.gravatar.com/avatar/125edaeb93ed639010b71693593f47f4.jpg?s=120&d=mm&r=g)
I'm continuing to wrestle with conch, this time around authentication and notifying deferred of auth failure. It seems like the SSH factory has a deferred to be notified of auth failures here: https://github.com/twisted/twisted/blob/trunk/src/twisted/conch/client/direc... Unfortunately, this deferred is cleared because prior to auth, it receives this on successful connect: https://github.com/twisted/twisted/blob/trunk/src/twisted/conch/client/direc... As you can see this clears the deferred so it is no longer available to get an errback. This also prevents the SSHClientTransport from getting a sendDisconnect. To try it change the user to something invalid here: https://gist.github.com/radifalco/5a5cca4bf8d49d5c61113e36f9be7553#file-sftp... This will never get a callback to errback. I guess I would have expected this to get the error but it actually succeeds with None. As a result there is no deferred to get the auth failure and my app waits forever for a notification. There is one ting I *think* I know how to do, add a timeout with a callback later on the sftpClient deferred. But that seems lame. What I'd like to do is to get this ConchError as it has the actual reason for the connection failure. Thoughts? https://github.com/twisted/twisted/blob/trunk/src/twisted/conch/client/direc...
![](https://secure.gravatar.com/avatar/125edaeb93ed639010b71693593f47f4.jpg?s=120&d=mm&r=g)
Ok, my solution is to re-write the connect function like this. Any issues with this approach? def connect(options, userAuthObject): d_connect = Deferred() d_authorized = Deferred() factory = SFTPClientFactory(d_connect, options, userAuthObject) def _connect_failed(*args, **kwargs): d_authorized.errback(args[0]) def _connected(*args, **kwargs): # Reset the factory's deferred factory.d = d_authorized d_connect.addErrback(_connect_failed).addCallback(_connected) reactor.connectTCP(options["host"], options["port"], factory) return d_authorized.addCallback(lambda ignore: factory) On Sun, Nov 29, 2020 at 9:41 AM Robert DiFalco <robert.difalco@gmail.com> wrote:
![](https://secure.gravatar.com/avatar/125edaeb93ed639010b71693593f47f4.jpg?s=120&d=mm&r=g)
Alright, it's a but in twisted. How do I report twisted bugs? Under python3 service.name is bytes and not a string. https://github.com/twisted/twisted/blob/trunk/src/twisted/conch/client/direc... On Mon, Nov 30, 2020 at 4:00 PM Robert DiFalco <robert.difalco@gmail.com> wrote:
![](https://secure.gravatar.com/avatar/e589db6c27c54b03de756cae2843dba5.jpg?s=120&d=mm&r=g)
On Mon, Nov 30, 2020 at 10:21 PM Robert DiFalco <robert.difalco@gmail.com> wrote:
https://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#TheresabuginTwi... If that's the case, that comparison should throw a TypeError. Does it?
![](https://secure.gravatar.com/avatar/125edaeb93ed639010b71693593f47f4.jpg?s=120&d=mm&r=g)
Ok, my solution is to re-write the connect function like this. Any issues with this approach? def connect(options, userAuthObject): d_connect = Deferred() d_authorized = Deferred() factory = SFTPClientFactory(d_connect, options, userAuthObject) def _connect_failed(*args, **kwargs): d_authorized.errback(args[0]) def _connected(*args, **kwargs): # Reset the factory's deferred factory.d = d_authorized d_connect.addErrback(_connect_failed).addCallback(_connected) reactor.connectTCP(options["host"], options["port"], factory) return d_authorized.addCallback(lambda ignore: factory) On Sun, Nov 29, 2020 at 9:41 AM Robert DiFalco <robert.difalco@gmail.com> wrote:
![](https://secure.gravatar.com/avatar/125edaeb93ed639010b71693593f47f4.jpg?s=120&d=mm&r=g)
Alright, it's a but in twisted. How do I report twisted bugs? Under python3 service.name is bytes and not a string. https://github.com/twisted/twisted/blob/trunk/src/twisted/conch/client/direc... On Mon, Nov 30, 2020 at 4:00 PM Robert DiFalco <robert.difalco@gmail.com> wrote:
![](https://secure.gravatar.com/avatar/e589db6c27c54b03de756cae2843dba5.jpg?s=120&d=mm&r=g)
On Mon, Nov 30, 2020 at 10:21 PM Robert DiFalco <robert.difalco@gmail.com> wrote:
https://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#TheresabuginTwi... If that's the case, that comparison should throw a TypeError. Does it?
participants (2)
-
Colin Dunklau
-
Robert DiFalco