mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-26 07:49:48 -05:00
Clean up tmpdir storing hidden service info after exit.
This commit is contained in:
parent
60d97cfa5e
commit
91d0bb4fda
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user