From 2ecb69968344f65dbbd7f2a15fcb81aa38ac64f3 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Fri, 7 Jun 2013 17:24:33 +0100 Subject: 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 --- sos/archive.py | 2 ++ 1 file changed, 2 insertions(+) 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): -- cgit