diff mbox series

[PATCHv2,5/5] parse: Make include_all raise a parse error for absolute paths

Message ID 20250916211934.253650-5-pkj@axis.com
State New
Headers show
Series [PATCHv2,1/5] tests/parse: Use with statement to avoid ResourceWarning | expand

Commit Message

Peter Kjellerstedt Sept. 16, 2025, 9:19 p.m. UTC
It makes no sense to use an absolute path with include_all.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---

PATCHv2: Raise an error instead if an absolute path is used with
         include_all.

 bitbake/lib/bb/parse/parse_py/ConfHandler.py | 3 +++
 bitbake/lib/bb/tests/parse.py                | 1 +
 2 files changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py
index af3af2ccee..d876f6c1ff 100644
--- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py
+++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py
@@ -68,6 +68,9 @@  def include(parentfn, fns, lineno, data, error_out, all=False):
     # "include" or "require" accept zero to n space-separated file names to include.
     for fn in fns.split():
         if all:
+            if os.path.isabs(fn):
+                raise ParseError("Incorrect use of include_all with an absolute path %s" % fn, parentfn, lineno)
+
             for path in data.getVar("BBPATH").split(":"):
                 include_single_file(parentfn, os.path.join(path, fn), lineno, data, error_out)
         else:
diff --git a/bitbake/lib/bb/tests/parse.py b/bitbake/lib/bb/tests/parse.py
index 2f77c90f60..d6bc5a38bf 100644
--- a/bitbake/lib/bb/tests/parse.py
+++ b/bitbake/lib/bb/tests/parse.py
@@ -500,6 +500,7 @@  EXTRA_OECONF:append = " foobar"
             test_helper("include_all someother.conf", None)
             test_helper("include_all some3.conf", " foobar")
             test_helper("include_all ${@''}", None)
+            test_helper("include_all " + tempdir + "/conf2/some.conf", bb.parse.ParseError)
 
             self.d.setVar("BBPATH", tempdir + "/conf2" + ":" + tempdir + "/conf1")