diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-09-21 15:59:53 +0200 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2015-09-24 12:09:32 -0400 |
commit | 4a090d6e405415607f9c811a7961f8dc0cdd2af0 (patch) | |
tree | c27d0ffd265b63600f1712449b9e2c5f6504bd59 /src/leap/keymanager/__init__.py | |
parent | 4e82d6ef4dc5e3bb311bf5b80b1e92d67cb0f346 (diff) |
[bug] keep combined file longer in scope
In previous commit 9546348c, the combined bundle ca
was not long enough in scope and was therefore deleted
when it actually was used.
Adopted test to check whether file is deleted.
Diffstat (limited to 'src/leap/keymanager/__init__.py')
-rw-r--r-- | src/leap/keymanager/__init__.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/leap/keymanager/__init__.py b/src/leap/keymanager/__init__.py index 22fb725..f00e049 100644 --- a/src/leap/keymanager/__init__.py +++ b/src/leap/keymanager/__init__.py @@ -19,6 +19,7 @@ Key Manager is a Nicknym agent for LEAP client. """ # let's do a little sanity check to see if we're using the wrong gnupg import fileinput +import os import sys import tempfile from leap.common import ca_bundle @@ -140,6 +141,18 @@ class KeyManager(object): self._combined_ca_bundle = self._create_combined_bundle_file() # + # destructor + # + + def __del__(self): + try: + created_tmp_combined_ca_bundle = self._combined_ca_bundle not in [ca_bundle.where(), self._ca_cert_path] + if created_tmp_combined_ca_bundle: + os.remove(self._combined_ca_bundle) + except OSError: + pass + + # # utilities # @@ -151,8 +164,7 @@ class KeyManager(object): elif not self._ca_cert_path: return leap_ca_bundle - # file is auto deleted when python process ends - tmp_file = tempfile.NamedTemporaryFile(delete=True) + tmp_file = tempfile.NamedTemporaryFile(delete=False) # delete when keymanager expires with open(tmp_file.name, 'w') as fout: fin = fileinput.input(files=(leap_ca_bundle, self._ca_cert_path)) |