From 8d2577786cce6fcc915836108e405dbf5025dec8 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Tue, 29 Apr 2014 19:02:43 +0100 Subject: Drop cwd/umask shenanigans from TarFileArchive::finalize() It was necessary to save and restore old_cwd and the umask around calls to an external archive program. This isn't needed when using native python implementations and causes problems in the case that the current working directory no longer exists: Creating compressed archive... going to finalize did finalize exception: [Errno 2] No such file or directory shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory Traceback (most recent call last): File "/sbin/sosreport", line 23, in main(sys.argv[1:]) File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1233, in main sos.execute() File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1222, in execute return self.final_work() File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1159, in final_work raise e OSError: [Errno 2] No such file or directory Signed-off-by: Bryn M. Reeves --- sos/archive.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sos/archive.py b/sos/archive.py index 0f65c747..ea9e744e 100644 --- a/sos/archive.py +++ b/sos/archive.py @@ -259,15 +259,11 @@ class TarFileArchive(FileCacheArchive): return "%s.%s" % (self._name, self._suffix) def _build_archive(self): - old_pwd = os.getcwd() - old_umask = os.umask(0o077) os.chdir(self._tmp_dir) tar = tarfile.open(self._archive_name, mode="w") tar.add(os.path.split(self._name)[1], filter=self.copy_permissions_filter) tar.close() - os.umask(old_umask) - os.chdir(old_pwd) def _compress(self): methods = ['xz', 'bzip2', 'gzip'] -- cgit