meejah / txtorcon

Twisted-based asynchronous Tor control protocol implementation. Includes unit-tests, examples, state-tracking code and configuration abstraction.
http://fjblvrw2jrxnhtg67qpbzi45r7ofojaoo3orzykesly2j3c2m3htapid.onion/
MIT License
250 stars 72 forks source link

Fallback to password when cookie isn't readable #149

Closed coffeemakr closed 8 years ago

coffeemakr commented 8 years ago

In TorControlProtocol._do_authenticate when COOKIE authentication is enabled it is always tries to read the cookie. If this fails (for example because the running process doesn't have access rights) an uncatched IOError is raised.

Wouldn't it be better to catch the exception and try password authentication before failing?

Regards

meejah commented 8 years ago

Yes, probably that would be better.

Examining the code probably the best behavior is to try cookie/safecookie if they're available, but upon errors try password auth IFF it's available and we have a .password_function.

meejah commented 8 years ago

This is merged in #150; closing. Thanks @coffeemakr!