Skip to contentSkip to conversation

selftest/signing: Ensure build path relocation is safe

PATCH New Richard Purdie 1 participant 2 messages Sep 8, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 selftest/signing: Ensure build path relocation is safe

Similarly to 04ee0e8b95cd8ed890374e0007f976684206b630, ensure only full build paths are replaced in the environment to avoid breaking buildtools.

---
 meta/lib/oeqa/selftest/cases/signing.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/lib/oeqa/selftest/cases/signing.py +3 -1
index 202d54994b6..a28c7eb19a1 100644
@@ -44,7 +44,9 @@ class Signing(OESelftestTestCase):
         origenv = os.environ.copy()
 
         for e in os.environ:
-            if builddir in os.environ[e]:
+            if builddir + "/" in os.environ[e]:
+                os.environ[e] = os.environ[e].replace(builddir + "/", newbuilddir + "/")
+            if os.environ[e].endswith(builddir):
                 os.environ[e] = os.environ[e].replace(builddir, newbuilddir)
 
         os.chdir(newbuilddir)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 oeqa/concurrencytest: Improve builddir path manipulations

Its possible some patterns may cause problems with the current path manipulations, make a small tweak to try and avoid potential pathname overlap issues.

---
 meta/lib/oeqa/selftest/context.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/lib/oeqa/selftest/context.py +3 -1
index 23f7d71bdbc..dd3609c1d6f 100644
@@ -82,7 +82,9 @@ class OESelftestTestContext(OETestContext):
         oe.path.copytree(selftestdir, newselftestdir)
 
         for e in os.environ:
-            if builddir + "/" in os.environ[e] or os.environ[e].endswith(builddir):
+            if builddir + "/" in os.environ[e]:
+                os.environ[e] = os.environ[e].replace(builddir + "/", newbuilddir + "/")
+            if os.environ[e].endswith(builddir):
                 os.environ[e] = os.environ[e].replace(builddir, newbuilddir)
 
         subprocess.check_output("git init; git add *; git commit -a -m 'initial'", cwd=newselftestdir, shell=True)
Signature · 1 line
2.25.1