diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2013-06-07 17:24:33 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2013-06-07 17:26:57 +0100 |
commit | 2ecb69968344f65dbbd7f2a15fcb81aa38ac64f3 (patch) | |
tree | 0ad1dba99d02352d6c8dd8c37033ac24a186ff3f | |
parent | 9ddb154d609af6c57c8c8ede7d7d7fc9932a2ee8 (diff) | |
download | sos-2ecb69968344f65dbbd7f2a15fcb81aa38ac64f3.tar.gz |
Fix make_path for absolute destination paths
Pythons os.path.join behaviour returns only the last path given
when that path is absolute. This means that when make_path() is
given an absolute destination path (e.g. /etc/foo) it will return
an archive path of '/etc/foo' causing an error when copying into
the temporary tree.
Check for absolute paths and use lstrip to remove leading
instances of os.sep from the string.
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/archive.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/sos/archive.py b/sos/archive.py index 3702a91f..3bd3fdbc 100644 --- a/sos/archive.py +++ b/sos/archive.py @@ -48,6 +48,8 @@ class Archive(object): os.makedirs(self._archive_path, 0700) def make_path(self, name): + if os.path.isabs(name): + name = name.lstrip(os.sep) return (os.path.join(self._archive_path, name)) def prepend(self, src): |