diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py index 5c0acde9..6c28cea0 100644 --- a/onionshare/onionshare.py +++ b/onionshare/onionshare.py @@ -21,6 +21,7 @@ import os, sys, subprocess, time, argparse, inspect, shutil, socket, threading, import socks from stem.control import Controller +from stem.connection import MissingPassword, AuthenticationFailure from stem import SocketError import strings, helpers, web @@ -101,7 +102,17 @@ class OnionShare(object): pass if not controller: raise NoTor(strings._("cant_connect_ctrlport").format(tor_control_ports)) - controller.authenticate() + try: + controller.authenticate() + except MissingPassword: # We need a password for control port + from getpass import getpass + authed = False + while not authed: + try: + controller.authenticate(getpass('Tor control password: ')) + authed = True + except AuthenticationFailure: + pass # set up hidden service controller.set_options([