diff --git a/owwatcher/file_archiver.py b/owwatcher/file_archiver.py index ddc0536..0fbfdcc 100644 --- a/owwatcher/file_archiver.py +++ b/owwatcher/file_archiver.py @@ -24,7 +24,10 @@ def __init__(self, logger, archive_path, watch_dir, archive_queue, archive_queue # directory. It also prevents the contents of archive_path from being # read by an attacker. If, for some reason, archive_path's permissions # are not strict enough. - os.umask(ARCHIVE_UMASK) + self.orig_umask = os.umask(ARCHIVE_UMASK) + + def __del__(self): + os.umask(self.orig_umask) def run(self): self.try_read_queue = True diff --git a/tests/test_file_archiver.py b/tests/test_file_archiver.py index 93e8842..b3b4dc3 100644 --- a/tests/test_file_archiver.py +++ b/tests/test_file_archiver.py @@ -27,6 +27,7 @@ def __init__(self): # Need to put original functionality back so future tests aren't using the # mocks assigned to shutil and os.path def __del__(self): + super().__del__() shutil.copy2 = self.orig_copy2 os.path.realpath = self.orig_realpath