summaryrefslogtreecommitdiffstats
path: root/lib/bb/fetch2/__init__.py
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2016-09-21 17:31:27 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-21 22:19:55 +0100
commitc3873346c6fa1021a1d63bddd9b898a77c618432 (patch)
treee3b4c5e6bd863f01ea0673b5c721068241d0a280 /lib/bb/fetch2/__init__.py
parent01e331cd0d612013badfb07df91151907f74903d (diff)
downloadbitbake-contrib-c3873346c6fa1021a1d63bddd9b898a77c618432.tar.gz
fetch2: handle absolute paths in subdir
Currently if you use the subdir parameter in a SRC_URI and pass an absolute path then it gets appended to the unpack directory instead of being used directly. This is inconvenient as it may be useful to use ${S} when you want to unpack a file into the source tree. Change this behaviour so that absolute paths are used directly instead of being appended to the root directory. To ensure that recipes cannot write files to an arbitrary location enforce that the subdir starts with the unpack root. Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/fetch2/__init__.py')
-rw-r--r--lib/bb/fetch2/__init__.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index 06f1eb4e8..cd7362c44 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -1420,7 +1420,13 @@ class FetchMethod(object):
# If 'subdir' param exists, create a dir and use it as destination for unpack cmd
if 'subdir' in urldata.parm:
- unpackdir = '%s/%s' % (rootdir, urldata.parm.get('subdir'))
+ subdir = urldata.parm.get('subdir')
+ if os.path.isabs(subdir):
+ if not os.path.realpath(subdir).startswith(os.path.realpath(rootdir)):
+ raise UnpackError("subdir argument isn't a subdirectory of unpack root %s" % rootdir, urldata.url)
+ unpackdir = subdir
+ else:
+ unpackdir = os.path.join(rootdir, subdir)
bb.utils.mkdirhier(unpackdir)
else:
unpackdir = rootdir