From f2c3f8eb0db188caac6991632c4453c39b42e84c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Billeter?= Date: Thu, 29 Aug 2019 16:22:40 +0200 Subject: _context.py: Ensure paths in user configuration are absolute Relative paths don't make sense in user configuration. The exception is workspacedir where `.` is useful as it will be combined with the name specified on the command line. --- src/buildstream/_context.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py index c6cde4003..b70f80d73 100644 --- a/src/buildstream/_context.py +++ b/src/buildstream/_context.py @@ -242,6 +242,12 @@ class Context(): path = os.path.normpath(path) setattr(self, directory, path) + # Relative paths don't make sense in user configuration. The exception is + # workspacedir where `.` is useful as it will be combined with the name + # specified on the command line. + if not os.path.isabs(path) and not (directory == 'workspacedir' and path == '.'): + raise LoadError("{} must be an absolute path".format(directory), LoadErrorReason.INVALID_DATA) + # add directories not set by users self.tmpdir = os.path.join(self.cachedir, 'tmp') self.casdir = os.path.join(self.cachedir, 'cas') -- cgit v1.2.1