From 91d0bb4fdafc24384c37a66cf2b1e239c99f09f1 Mon Sep 17 00:00:00 2001 From: Mason Donahue Date: Sat, 23 Aug 2014 18:03:36 -0500 Subject: [PATCH 1/2] Clean up tmpdir storing hidden service info after exit. --- onionshare/onionshare.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py index 71e198a9..8e82604e 100644 --- a/onionshare/onionshare.py +++ b/onionshare/onionshare.py @@ -245,6 +245,8 @@ def start_hidden_service(port): else: hidserv_dir = "/tmp/onionshare_{0}".format(hidserv_dir_rand) + register_cleanup_handler(hidserv_dir) + # connect to the tor controlport controlports = [9051, 9151] controller = False @@ -302,6 +304,15 @@ def tails_root(): while True: 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(): load_strings() tails_root() From 0e5b182a5497d1b8b19a3d3a538e8e80a410e96e Mon Sep 17 00:00:00 2001 From: Mason Donahue Date: Sun, 24 Aug 2014 01:19:10 -0500 Subject: [PATCH 2/2] Just realized Windows is a supported OS. This should be more portable. --- onionshare/onionshare.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py index 8e82604e..816e844a 100644 --- a/onionshare/onionshare.py +++ b/onionshare/onionshare.py @@ -306,8 +306,9 @@ def tails_root(): def register_cleanup_handler(directory): import signal + import shutil def handler(signum = None, frame = None): - subprocess.call(['rm','-r',directory]) + shutil.rmtree(directory) sys.exit() for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]: signal.signal(sig, handler)