diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2014-04-29 20:41:18 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2014-04-29 20:41:18 +0100 |
commit | f3ec4ae4920a4bca1d0af6e15270e4c874c03ad8 (patch) | |
tree | 7574199b59fd3c0c0fc1f7a0c7717bffa0afa6ef | |
parent | 8d2577786cce6fcc915836108e405dbf5025dec8 (diff) | |
download | sos-f3ec4ae4920a4bca1d0af6e15270e4c874c03ad8.tar.gz |
Make calls to TarFile.add() use absolute path for 'name'
Always use an absolute path when calling TarFile.add() in
TarFileArchive._build_archive() and set arcname explicitly to the
(relative) path name to use in the archive.
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/archive.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sos/archive.py b/sos/archive.py index ea9e744e..9df3782a 100644 --- a/sos/archive.py +++ b/sos/archive.py @@ -259,9 +259,10 @@ class TarFileArchive(FileCacheArchive): return "%s.%s" % (self._name, self._suffix) def _build_archive(self): - os.chdir(self._tmp_dir) tar = tarfile.open(self._archive_name, mode="w") - tar.add(os.path.split(self._name)[1], + # We need to pass the absolute path to the archive root but we + # want the names used in the archive to be relative. + tar.add(self._archive_root, arcname=os.path.split(self._name)[1], filter=self.copy_permissions_filter) tar.close() |