[pytorctl/master] Closing connection in case of auth failure

commit 40f7cbc50d460d8e3e11669827108bfb912ab3bf Author: Damian Johnson <atagar@torproject.org> Date: Thu Jun 16 18:15:05 2011 -0700 Closing connection in case of auth failure When authentication failed in TorCtl.connect() the abandoned connection wasn't being closed. --- TorCtl.py | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/TorCtl.py b/TorCtl.py index cb3b53f..2eddabc 100755 --- a/TorCtl.py +++ b/TorCtl.py @@ -109,6 +109,7 @@ def connect(controlAddr="127.0.0.1", controlPort=9051, passphrase=None): than prompting the user) """ + conn = None try: conn, authType, authValue = connectionComp(controlAddr, controlPort) @@ -122,6 +123,8 @@ def connect(controlAddr="127.0.0.1", controlPort=9051, passphrase=None): conn.authenticate(authValue) return conn except Exception, exc: + if conn: conn.close() + if passphrase and str(exc) == "Unable to authenticate: password incorrect": # provide a warning that the provided password didn't work, then try # again prompting for the user to enter it
participants (1)
-
mikeperry@torproject.org