[oe-commits] org.oe.dev classes/insanity.bbclass: Check for possible insecure RPATH, make it work with the funy BitBake scope
freyther commit
openembedded-commits at lists.openembedded.org
Tue Sep 12 09:04:34 UTC 2006
classes/insanity.bbclass: Check for possible insecure RPATH, make it work with the funy BitBake scope
The def methods are in a different scope that the PACKAGEFUNC and the
result is only the packagefunc is able to use 'd' so we need to make
this a parameter for the other methods.
Use the installed scanelf to check for the RPATH of the files
Author: freyther at openembedded.org
Branch: org.openembedded.dev
Revision: c2682ec1dd418a696aa5cec3d278f7cfd4386443
ViewMTN: http://monotone.openembedded.org/revision.psp?id=c2682ec1dd418a696aa5cec3d278f7cfd4386443
Files:
1
classes/insane.bbclass
Diffs:
#
# mt diff -re42d2cb1d37c1a04409ce68c6045427d07f609cb -rc2682ec1dd418a696aa5cec3d278f7cfd4386443
#
#
#
# patch "classes/insane.bbclass"
# from [1beaa5113861a2ad1554d156f391c37888cb8d66]
# to [0d4b0b4f274544e7878a0821f87ffb900e01b3d0]
#
============================================================
--- classes/insane.bbclass 1beaa5113861a2ad1554d156f391c37888cb8d66
+++ classes/insane.bbclass 0d4b0b4f274544e7878a0821f87ffb900e01b3d0
@@ -22,17 +22,32 @@ PACKAGEFUNCS += " do_package_qa "
PACKAGE_DEPENDS += "pax-utils-native"
PACKAGEFUNCS += " do_package_qa "
-def package_qa_check_rpath(file,name):
+def package_qa_check_rpath(file,name,d):
"""
Check for dangerous RPATHs
"""
+ import bb, os
+ scanelf = os.path.join(bb.data.getVar('STAGING_BINDIR',d,True),'scanelf')
+ bad_dir = bb.data.getVar('TMPDIR', d, True) + "/work"
+ if not os.path.exists(scanelf):
+ bb.note("Can not check RPATH scanelf not found")
+ if not bad_dir in bb.data.getVar('WORKDIR', d, True):
+ bb.error("This class assumed that WORKDIR is ${TMPDIR}/work... Not doing any check")
+
+ output = os.popen("%s -Byr %s" % (scanelf,file))
+ txt = output.readline().rsplit()
+ if bad_dir in txt:
+ bb.error("QA Issue package %s contains bad RPATH %s in file %s" % (name, txt, file))
+
pass
-def package_qa_check_devdbg(path, name):
+def package_qa_check_devdbg(path, name,d):
"""
Check for debug remains inside the binary or
non dev packages containing
"""
+
+ import bb
if not "-dev" in name:
if path[-3:] == ".so":
bb.error("QA Issue: non dev package contains .so")
@@ -41,24 +56,24 @@ def package_qa_check_devdbg(path, name):
if path[-4:] == ".dbg":
bb.error("QA Issue: non debug package contains .dbg file")
-def package_qa_check_perm(path,name):
+def package_qa_check_perm(path,name,d):
"""
Check the permission of files
"""
pass
-def package_qa_check_arch(path,name):
+def package_qa_check_arch(path,name,d):
"""
Check if archs are compatible
"""
pass
-def package_qa_check_pcla(path,name):
+def package_qa_check_pcla(path,name,d):
"""
.pc and .la files should not point
"""
-def package_qa_check_staged(path):
+def package_qa_check_staged(path,d):
"""
Check staged la and pc files for sanity
-e.g. installed being false
@@ -66,13 +81,13 @@ def package_qa_check_staged(path):
pass
# Walk over all files in a directory and call func
-def package_qa_walk(path, funcs, package):
+def package_qa_walk(path, funcs, package,d):
import os
for root, dirs, files in os.walk(path):
for file in files:
path = os.path.join(root,file)
for func in funcs:
- func(path, package)
+ func(path, package,d)
# The PACKAGE FUNC to scan each package
@@ -88,7 +103,7 @@ python do_package_qa () {
for package in packages.split():
bb.note("Package: %s" % package)
path = "%s/install/%s" % (workdir, package)
- package_qa_walk(path, [package_qa_check_rpath, package_qa_check_devdbg, package_qa_check_perm, package_qa_check_arch], package)
+ package_qa_walk(path, [package_qa_check_rpath, package_qa_check_devdbg, package_qa_check_perm, package_qa_check_arch], package, d)
}
@@ -97,5 +112,5 @@ python do_qa_staging() {
python do_qa_staging() {
bb.note("Staged!")
- package_qa_check_staged(bb.data.getVar('STAGING_DIR',d,True))
+ package_qa_check_staged(bb.data.getVar('STAGING_DIR',d,True), d)
}
More information about the Openembedded-commits
mailing list