Patchwork [1/3] insane: check packages for absolute symlinks to the tmpdir

login
register
mail settings
Submitter Ross Burton
Date March 3, 2014, 8:23 p.m.
Message ID <1393878215-27447-1-git-send-email-ross.burton@intel.com>
Download mbox | patch
Permalink /patch/67901/
State New
Headers show

Comments

Ross Burton - March 3, 2014, 8:23 p.m.
Add a sanity test that checks for symlinks in packages that point into the
TMPDIR on the host.

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/classes/insane.bbclass |   13 +++++++++++++
 1 file changed, 13 insertions(+)

Patch

diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index cf00e12..11c1feb 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -574,6 +574,19 @@  def package_qa_check_infodir(path, name, d, elf, messages):
     if infodir in path:
         messages.append("The /usr/share/info/dir file is not meant to be shipped in a particular package.")
 
+QAPATHTEST[symlink-to-sysroot] = "package_qa_check_symlink_to_sysroot"
+def package_qa_check_symlink_to_sysroot(path, name, d, elf, messages):
+    """
+    Check that the package doesn't contain any absolute symlinks to the sysroot.
+    """
+    if os.path.islink(path):
+        target = os.readlink(path)
+        if os.path.isabs(target):
+            tmpdir = d.getVar('TMPDIR', True)
+            if target.startswith(tmpdir):
+                trimmed = path.replace(os.path.join (d.getVar("PKGDEST", True), name), "")
+                messages.append("Symlink %s in %s points to TMPDIR" % (trimmed, name))
+
 def package_qa_check_license(workdir, d):
     """
     Check for changes in the license files