aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2019-07-09 13:23:37 +0200
committerPavel Moravec <pmoravec@redhat.com>2019-07-09 13:23:37 +0200
commitba77701624dccf3ba98fee6e9cdb9b9d804068c2 (patch)
tree72e1c98345ec4cab034cbc17adfc517e6140220b
parentb3d9fdf568e25997eb006e575d26fb301b91414b (diff)
downloadsos-ba77701624dccf3ba98fee6e9cdb9b9d804068c2.tar.gz
[archive] convert absolute symlink targets to relative
Calling _make_leading_paths for a symlink with absolute symlink target must create the symlink relative to the source. This will prevent creating symlinks outside sosreport build dir. Resolves: #1710 Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-rw-r--r--sos/archive.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/sos/archive.py b/sos/archive.py
index 9e19426c..dcd6908d 100644
--- a/sos/archive.py
+++ b/sos/archive.py
@@ -232,6 +232,11 @@ class FileCacheArchive(Archive):
dest = self._make_leading_paths(target_src, mode=mode)
dest = os.path.normpath(dest)
+ # In case symlink target is an absolute path, make it
+ # relative to the directory with symlink source
+ if os.path.isabs(target):
+ target = os.path.relpath(target, target_dir)
+
self.log_debug("Making symlink '%s' -> '%s'" %
(abs_path, target))
os.symlink(target, abs_path)