Clean up tmpdir storing hidden service info after exit.

This commit is contained in:
Mason Donahue 2014-08-23 18:03:36 -05:00
parent 60d97cfa5e
commit 91d0bb4fda

View File

@ -245,6 +245,8 @@ def start_hidden_service(port):
else: else:
hidserv_dir = "/tmp/onionshare_{0}".format(hidserv_dir_rand) hidserv_dir = "/tmp/onionshare_{0}".format(hidserv_dir_rand)
register_cleanup_handler(hidserv_dir)
# connect to the tor controlport # connect to the tor controlport
controlports = [9051, 9151] controlports = [9051, 9151]
controller = False controller = False
@ -302,6 +304,15 @@ def tails_root():
while True: while True:
time.sleep(1) time.sleep(1)
def register_cleanup_handler(directory):
import signal
def handler(signum = None, frame = None):
subprocess.call(['rm','-r',directory])
sys.exit()
for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]:
signal.signal(sig, handler)
def main(): def main():
load_strings() load_strings()
tails_root() tails_root()