New QA tests for unsafe references to exec_prefix [v2]
cover New QA tests for unsafe references to exec_prefix [v2]
Hello,
This is a P2 feature for Yocto 1.2. It adds two new QA tests to check files in base_bindir, base_sbindir, and base_libdir for references to files under exec_prefix (e.g, dynamic linking for binaries and references to exec_prefix in scripts).
The reason for these tests is that exec_prefix (typically /usr) can be kept on a separate partition that may be mounted late in the boot process, or may not be mounted at all during system recovery operations.
It was my original goal to make the dynamic linking test a QA error upon failure, but it turned out the amount of recipe work needed was much larger than I expected. So for the time being they have been changed to generate QA warmings.
The libraries I've moved to base_libdir in this pull request should take care of all binaries in /bin and /sbin for packages we include in core-image-minimal and -sato.
I would like to ask recipe maintainers to look for these QA warnings and fix them ASAP, as I believe we'll be changing this to a QA error before the release of 1.2.
This is a second pull request that is rebased against the latest master with merge conflicts resolved, and only sets BUILD_LDFLAGS in ncurses.inc for virtclass-native.
Scott
The following changes since commit de679a3036ebef1c7d7b8ee23f05590c95e498d9:
pseudo: ensure libs are included in package (2012-01-03 12:10:59 +0000)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib sgarman/per-recipe-sanitychk-final
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=sgarman/per-recipe-sanitychk-final
Scott Garman (7):
ncurses: move libraries to base_libdir
libcap: move library to base_libdir
util-linux: move libraries to base_libdir
e2fsprogs: move libraries to base_libdir
libusb1: move libraries to base_libdir
libusb-compat: move libraries to base_libdir insane.bbclass: add QA tests for unsafe references to exec_prefix
meta/classes/insane.bbclass | 111 +++++++++++++++++++- meta/recipes-core/ncurses/ncurses.inc | 27 +++-- meta/recipes-core/util-linux/util-linux.inc | 20 ++-- meta/recipes-core/util-linux/util-linux_2.20.1.bb | 2 +- .../e2fsprogs/e2fsprogs_1.41.14.bb | 29 +++-- meta/recipes-support/libcap/libcap.inc | 15 +++- meta/recipes-support/libcap/libcap_2.22.bb | 2 +- meta/recipes-support/libusb/libusb-compat_0.1.3.bb | 12 ++- meta/recipes-support/libusb/libusb1_1.0.8.bb | 16 +++- 9 files changed, 196 insertions(+), 38 deletions(-)
Signature · 1 line
1.7.5.4
PATCH 1/7 ncurses: move libraries to base_libdir
Various utilities (including bash and the util-linux programs) located in base_bindir (/bin) or base_sbindir (/sbin) dynamically link against many of the ncurses libraries. So move these libraries from libdir (/usr/lib) to base_libdir (/lib).
--- meta/recipes-core/ncurses/ncurses.inc | 27 ++++++++++++++++++--------- 1 files changed, 18 insertions(+), 9 deletions(-)
meta/recipes-core/ncurses/ncurses.inc +18 -9
@@ -26,6 +26,9 @@ ENABLE_WIDEC ?= "true" # builds. BUILD_CPPFLAGS += "-D_GNU_SOURCE" +# tic from the -native build cannot run without setting this explicitly +BUILD_LDFLAGS_virtclass-native += "-Wl,-rpath,${base_libdir}" + # Helper function for do_configure to allow multiple configurations # $1 the directory to run configure in # $@ the arguments to pass to configure
@@ -41,6 +44,7 @@ ncurses_configure() { --enable-hard-tabs \ --enable-xmc-glitch \ --enable-colorfgbg \ + --libdir=${base_libdir} \ --with-termpath='${sysconfdir}/termcap:${datadir}/misc/termcap' \ --with-terminfo-dirs='${sysconfdir}/terminfo:${datadir}/terminfo' \ --with-shared \
@@ -120,7 +124,6 @@ do_install() { ! ${ENABLE_WIDEC} || \ oe_runmake -C widec ${_install_opts} - cd narrowc # include some basic terminfo files
@@ -155,28 +158,29 @@ do_install() { # else when '-Wl,--no-copy-dt-needed-entries' has been set in # linker flags. for i in libncurses libncursesw; do - f=${D}${libdir}/$i.so + f=${D}${base_libdir}/$i.so test -h $f || continue rm -f $f echo '/* GNU ld script */' >$f echo "INPUT($i.so.5 AS_NEEDED(-ltinfo))" >>$f done - # Make sure that libcurses is linked so that it gets -ltinfo - # also, this should be addressed upstream really. - ln -sf libncurses.so ${D}${libdir}/libcurses.so + + # Make sure that libcurses is linked so that it gets -ltinfo + # also, this should be addressed upstream really. + ln -sf libncurses.so ${D}${base_libdir}/libcurses.so # create libtermcap.so linker script for backward compatibility - f=${D}${libdir}/libtermcap.so + f=${D}${base_libdir}/libtermcap.so echo '/* GNU ld script */' >$f echo 'INPUT(AS_NEEDED(-ltinfo))' >>$f - oe_multilib_header curses.h + oe_multilib_header curses.h } python populate_packages_prepend () { - libdir = bb.data.expand("${libdir}", d) + base_libdir = bb.data.expand("${base_libdir}", d) pnbase = bb.data.expand("${PN}-lib%s", d) - do_split_packages(d, libdir, '^lib(.*)\.so\..*', pnbase, 'ncurses %s library', prepend=True, extra_depends = '', allow_links=True) + do_split_packages(d, base_libdir, '^lib(.*)\.so\..*', pnbase, 'ncurses %s library', prepend=True, extra_depends = '', allow_links=True) }
@@ -210,6 +214,10 @@ FILES_${PN} = "\ ${datadir}/tabset \ " +FILES_${PN}-dev += "\ + ${base_libdir}/*.so \ +" + # This keeps only tput/tset in ncurses # clear/reset are in already busybox FILES_${PN}-tools = "\
@@ -223,6 +231,7 @@ FILES_${PN}-tools = "\ ${bindir}/tack \ ${bindir}/tabs \ " + # 'reset' is a symlink to 'tset' which is in the 'ncurses' package RDEPENDS_${PN}-tools = "${PN}"
Signature · 1 line
1.7.5.4
PATCH 2/7 libcap: move library to base_libdir
In reply to Scott Garmanls from coreutils links to libcap, so move the libcap library from libdir (/usr/lib) to base_libdir (/lib).
--- meta/recipes-support/libcap/libcap.inc | 15 +++++++++++++-- meta/recipes-support/libcap/libcap_2.22.bb | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-)
meta/recipes-support/libcap/libcap.inc +13 -2
@@ -21,6 +21,8 @@ do_configure() { sed -e 's,BUILD_CFLAGS ?=,BUILD_CFLAGS := $(BUILD_CFLAGS),' -i Make.Rules } +BUILD_LDFLAGS_virtclass_native += "-Wl,rpath=${base_libdir}" + EXTRA_OEMAKE = " \ LIBATTR=yes \ PAM_CAP=${@base_contains('DISTRO_FEATURES', 'pam', 'yes', 'no', d)} \
@@ -42,8 +44,17 @@ do_install() { oe_runmake install DESTDIR="${D}" prefix="${prefix}" } +do_install_append() { + # Move the library to base_libdir + install -d ${D}${base_libdir} + mv ${D}${libdir}/* ${D}${base_libdir} + rmdir ${D}${libdir} +} + +FILES_${PN}-dev += "${base_libdir}/*.so" + # pam files -FILES_${PN} += "${libdir}/security/*.so" -FILES_${PN}-dbg += "${libdir}/security/.debug/*.so" +FILES_${PN} += "${base_libdir}/security/*.so" +FILES_${PN}-dbg += "${base_libdir}/security/.debug/*.so" BBCLASSEXTEND = "native"
meta/recipes-support/libcap/libcap_2.22.bb +1 -1
@@ -1,6 +1,6 @@ require libcap.inc -PR = "r2" +PR = "r3" SRC_URI[md5sum] = "ce64058bdb3f086ddbfca8ce6c919845" SRC_URI[sha256sum] = "73ebbd4877b5f69dd28b72098e510c5b318bc480f8201c4061ac98b78c04050f"
Signature · 1 line
1.7.5.4
PATCH 3/7 util-linux: move libraries to base_libdir
In reply to Scott GarmanVarious util-linux programs in base_sbindir (/sbin) linked to libraries located under exec_prefix (/usr). Since this is not safe, move these libraries from libdir (/usr/lib) to base_libdir (/lib).
--- meta/recipes-core/util-linux/util-linux.inc | 20 +++++++++++--------- meta/recipes-core/util-linux/util-linux_2.20.1.bb | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-)
meta/recipes-core/util-linux/util-linux.inc +11 -9
@@ -17,7 +17,6 @@ inherit autotools gettext pkgconfig DEPENDS = "zlib ncurses" DEPENDS_virtclass-native = " lzo-native" - SRC_URI = "ftp://ftp.infradead.org/pub/util-linux/v${MAJOR_VERSION}/util-linux-${PV}.tar.bz2 \ file://MCONFIG \ file://swapargs.h \
@@ -30,11 +29,14 @@ PACKAGES =+ "util-linux-agetty util-linux-fdisk util-linux-cfdisk util-linux-sfd util-linux-mount util-linux-readprofile util-linux-libblkid \ util-linux-libblkid-dev util-linux-libuuid util-linux-libuuid-dev \ util-linux-uuidgen util-linux-lscpu util-linux-fsck util-linux-blkid \ - util-linux-chkdupexe util-linux-mkfs util-linux-mcookie" + util-linux-chkdupexe util-linux-mkfs util-linux-mcookie" -EXTRA_OECONF = "--disable-use-tty-group --disable-makeinstall-chown --enable-elvtune --enable-init --enable-kill --enable-last \ - --enable-mesg --enable-partx --enable-raw --enable-rdev --enable-reset \ - --disable-login-utils --enable-write --enable-arch --enable-mount --with-fsprobe=builtin --enable-libuuid --enable-libblkid --enable-fsck" +EXTRA_OECONF = "--libdir=${base_libdir} --disable-use-tty-group \ + --disable-makeinstall-chown --enable-elvtune --enable-init \ + --enable-kill --enable-last --enable-mesg --enable-partx \ + --enable-raw --enable-rdev --enable-reset --disable-login-utils \ + --enable-write --enable-arch --enable-mount --with-fsprobe=builtin \ + --enable-libuuid --enable-libblkid --enable-fsck" FILES_${PN}-doc += "${datadir}/getopt/getopt-*.*"
@@ -50,10 +52,10 @@ FILES_util-linux-umount = "${base_bindir}/umount.${PN}" FILES_util-linux-readprofile = "${base_sbindir}/readprofile.${PN}" FILES_util-linux-uuidgen = "${bindir}/uuidgen" -FILES_util-linux-libblkid = "${libdir}/libblkid.so.*" -FILES_util-linux-libblkid-dev = "${libdir}/libblkid.so ${libdir}/libblkid.a ${libdir}/libblkid.la ${includedir}/blkid" -FILES_util-linux-libuuid = "${libdir}/libuuid.so.*" -FILES_util-linux-libuuid-dev = "${libdir}/libuuid.so ${libdir}/libuuid.a ${libdir}/libuuid.la ${includedir}/uuid" +FILES_util-linux-libblkid = "${base_libdir}/libblkid.so.*" +FILES_util-linux-libblkid-dev = "${base_libdir}/libblkid.so ${base_libdir}/libblkid.a ${base_libdir}/libblkid.la ${includedir}/blkid" +FILES_util-linux-libuuid = "${base_libdir}/libuuid.so.*" +FILES_util-linux-libuuid-dev = "${base_libdir}/libuuid.so ${base_libdir}/libuuid.a ${base_libdir}/libuuid.la ${includedir}/uuid" FILES_util-linux-lscpu = "${bindir}/lscpu" FILES_util-linux-fsck = "${base_sbindir}/fsck*"
meta/recipes-core/util-linux/util-linux_2.20.1.bb +1 -1
@@ -1,5 +1,5 @@ MAJOR_VERSION = "2.20" -PR = "r0" +PR = "r1" require util-linux.inc # note that `lscpu' is under GPLv3+
Signature · 1 line
1.7.5.4
PATCH 4/7 e2fsprogs: move libraries to base_libdir
In reply to Scott GarmanThe e2fsprogs utilities are installed into base_sbindir (/sbin) and should not link to libraries under exec_prefix (/usr). So move these libraries from libdir (/usr/lib) to base_libdir (/lib).
--- .../e2fsprogs/e2fsprogs_1.41.14.bb | 29 ++++++++++++------- 1 files changed, 18 insertions(+), 11 deletions(-)
meta/recipes-devtools/e2fsprogs/e2fsprogs_1.41.14.bb +18 -11
@@ -1,6 +1,6 @@ require e2fsprogs.inc -PR = "r3" +PR = "r4" SRC_URI += "file://quotefix.patch \ file://acinclude.m4"
@@ -11,9 +11,9 @@ SRC_URI[sha256sum] = "3f8ac1fedd7c4bec480afcbe4acabdd4ac59ec0446a0fd50c8975cd0aa PARALLEL_MAKE = "" -EXTRA_OECONF += " --sbindir=${base_sbindir} --enable-elf-shlibs --disable-libuuid --disable-uuidd" -EXTRA_OECONF_darwin = "--sbindir=${base_sbindir} --enable-bsd-shlibs" -EXTRA_OECONF_darwin8 = "--sbindir=${base_sbindir} --enable-bsd-shlibs" +EXTRA_OECONF += "--libdir=${base_libdir} --sbindir=${base_sbindir} --enable-elf-shlibs --disable-libuuid --disable-uuidd" +EXTRA_OECONF_darwin = "--libdir=${base_libdir} --sbindir=${base_sbindir} --enable-bsd-shlibs" +EXTRA_OECONF_darwin8 = "--libdir=${base_libdir} --sbindir=${base_sbindir} --enable-bsd-shlibs" do_configure_prepend () { cp ${WORKDIR}/acinclude.m4 ${S}/
@@ -28,9 +28,16 @@ do_install () { oe_runmake 'DESTDIR=${D}' install oe_runmake 'DESTDIR=${D}' install-libs # We use blkid from util-linux now so remove from here - rm -f ${D}${libdir}/libblkid* + rm -f ${D}${base_libdir}/libblkid* rm -rf ${D}${includedir}/blkid - rm -f ${D}${libdir}/pkgconfig/blkid.pc + rm -f ${D}${base_libdir}/pkgconfig/blkid.pc +} + +do_install_append () { + # e2initrd_helper and the pkgconfig files belong in libdir + install -d ${D}${libdir} + mv ${D}${base_libdir}/e2initrd_helper ${D}${libdir} + mv ${D}${base_libdir}/pkgconfig ${D}${libdir} } # blkid used to be part of e2fsprogs but is useful outside, add it
@@ -47,10 +54,10 @@ FILES_e2fsprogs-e2fsck = "${base_sbindir}/e2fsck ${base_sbindir}/fsck.ext*" FILES_e2fsprogs-mke2fs = "${base_sbindir}/mke2fs ${base_sbindir}/mkfs.ext* ${sysconfdir}/mke2fs.conf" FILES_e2fsprogs-tune2fs = "${base_sbindir}/tune2fs ${base_sbindir}/e2label ${base_sbindir}/findfs" FILES_e2fsprogs-badblocks = "${base_sbindir}/badblocks" -FILES_libcomerr = "${libdir}/libcom_err.so.*" -FILES_libss = "${libdir}/libss.so.*" -FILES_libe2p = "${libdir}/libe2p.so.*" -FILES_libext2fs = "${libdir}/e2initrd_helper ${libdir}/libext2fs.so.*" -FILES_${PN}-dev += "${datadir}/*/*.awk ${datadir}/*/*.sed" +FILES_libcomerr = "${base_libdir}/libcom_err.so.*" +FILES_libss = "${base_libdir}/libss.so.*" +FILES_libe2p = "${base_libdir}/libe2p.so.*" +FILES_libext2fs = "${base_libdir}/e2initrd_helper ${libdir}/libext2fs.so.*" +FILES_${PN}-dev += "${datadir}/*/*.awk ${datadir}/*/*.sed ${base_libdir}/*.so" BBCLASSEXTEND = "native"
Signature · 1 line
1.7.5.4
PATCH 5/7 libusb1: move libraries to base_libdir
In reply to Scott Garmanudev links to libusb1, and so these libraries need to be in base_libdir (/lib) instead of libdir (/usr/lib).
--- meta/recipes-support/libusb/libusb1_1.0.8.bb | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-)
meta/recipes-support/libusb/libusb1_1.0.8.bb +14 -2
@@ -1,4 +1,4 @@ -DESCRIPTION = "userspace library to access USB (version 1.0)" +DESCRIPTION = "Userspace library to access USB (version 1.0)" HOMEPAGE = "http://libusb.sf.net" BUGTRACKER = "http://www.libusb.org/report" SECTION = "libs"
@@ -6,7 +6,7 @@ SECTION = "libs" LICENSE = "LGPLv2.1+" LIC_FILES_CHKSUM = "file://COPYING;md5=fbc093901857fcd118f065f900982c24" -PR = "r0" +PR = "r1" SRC_URI = "${SOURCEFORGE_MIRROR}/libusb/libusb-${PV}.tar.bz2"
@@ -15,3 +15,15 @@ SRC_URI[sha256sum] = "21d0d3a5710f7f4211c595102c6b9eccb42435a17a4f5bd2c3f4166ab1 S = "${WORKDIR}/libusb-${PV}" inherit autotools pkgconfig + +EXTRA_OECONF = "--libdir=${base_libdir}" + +do_install_append() { + install -d ${D}${libdir} + mv ${D}${base_libdir}/*.la ${D}${libdir} + mv ${D}${base_libdir}/pkgconfig ${D}${libdir} +} + +FILES_${PN} += "${base_libdir}/*.so.*" + +FILES_${PN}-dev += "${base_libdir}/*.so"
Signature · 1 line
1.7.5.4
PATCH 6/7 libusb-compat: move libraries to base_libdir
In reply to Scott Garmanudev links to libusb-compat, and so this library needs to be in base_libdir (/lib) instead of libdir (/usr/lib).
--- meta/recipes-support/libusb/libusb-compat_0.1.3.bb | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-)
meta/recipes-support/libusb/libusb-compat_0.1.3.bb +11 -1
@@ -15,7 +15,7 @@ DEPENDS = "libusb1" PROVIDES = "libusb" PE = "1" -PR = "r0" +PR = "r1" SRC_URI = "${SOURCEFORGE_MIRROR}/libusb/libusb-compat-${PV}.tar.bz2 \ file://0.1.0-beta1-gcc3.4-fix.patch"
@@ -24,3 +24,13 @@ SRC_URI[md5sum] = "570ac2ea085b80d1f74ddc7c6a93c0eb" SRC_URI[sha256sum] = "a590a03b6188030ee1ca1a0af55685fcde005ca807b963970f839be776031d94" inherit autotools pkgconfig binconfig + +EXTRA_OECONF = "--libdir=${base_libdir}" + +do_install_append() { + install -d ${D}${libdir} + mv ${D}${base_libdir}/*.la ${D}${libdir} + mv ${D}${base_libdir}/pkgconfig ${D}${libdir} +} + +FILES_${PN}-dev += "${base_libdir}/*.so"
Signature · 1 line
1.7.5.4
PATCH 7/7 insane.bbclass: add QA tests for unsafe references to exec_prefix
In reply to Scott GarmanFiles under exec_prefix (commonly /usr) may not be available during system recovery. exec_prefix may also be kept on a separate partition that is mounted late in the boot process.
This QA test throws an warning if a binary in base_[bindir|sbindir|libdir] is dynamically linked to a file under exec_prefix. The intention is to turn this into an error in the near future.
It also checks executable non-binaries (e.g, shell scripts) in the above base directories with a simple grep test to look for references to exec_prefix. This test only produces a warning, since false positives are likely.
This fixes [YOCTO #1008]
--- meta/classes/insane.bbclass | 111 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 109 insertions(+), 2 deletions(-)
meta/classes/insane.bbclass +109 -2
@@ -11,6 +11,10 @@ # -Check if packages contains .debug directories or .so files # where they should be in -dev or -dbg # -Check if config.log contains traces to broken autoconf tests +# -Ensure that binaries in base_[bindir|sbindir|libdir] do not link +# into exec_prefix +# -Check that scripts in base_[bindir|sbindir|libdir] do not reference +# files under exec_prefix #
@@ -19,9 +23,14 @@ # The package.bbclass can help us here. # inherit package -PACKAGE_DEPENDS += "pax-utils-native desktop-file-utils-native" +PACKAGE_DEPENDS += "pax-utils-native desktop-file-utils-native ${QADEPENDS}" PACKAGEFUNCS += " do_package_qa " +# unsafe-references-in-binaries requires prelink-rtld from +# prelink-native, but we don't want this DEPENDS for -native builds +QADEPENDS = "prelink-native" +QADEPENDS_virtclass-native = "" +QADEPENDS_virtclass-nativesdk = "" # # dictionary for elf headers
@@ -100,7 +109,7 @@ def package_qa_get_machine_dict(): # Currently not being used by default "desktop" -WARN_QA ?= "ldflags useless-rpaths rpaths" +WARN_QA ?= "ldflags useless-rpaths rpaths unsafe-references-in-binaries unsafe-references-in-scripts" ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch la2 pkgconfig la perms" def package_qa_clean_path(path,d):
@@ -201,6 +210,104 @@ def package_qa_check_perm(path,name,d, elf, messages): """ return +QAPATHTEST[unsafe-references-in-binaries] = "package_qa_check_unsafe_references_in_binaries" +def package_qa_check_unsafe_references_in_binaries(path, name, d, elf, messages): + """ + Ensure binaries in base_[bindir|sbindir|libdir] do not link to files under exec_prefix + """ + if unsafe_references_skippable(path, name, d): + return + + if elf: + import subprocess as sub + pn = d.getVar('PN', True) + + exec_prefix = d.getVar('exec_prefix', True) + sysroot_path = d.getVar('STAGING_DIR_TARGET', True) + sysroot_path_usr = sysroot_path + exec_prefix + + try: + ldd_output = sub.check_output(["prelink-rtld", "--root", sysroot_path, path]) + except sub.CalledProcessError as e: + if e.returncode != 127: + error_msg = pn + ": prelink-rtld aborted when processing %s" % path + package_qa_handle_error("unsafe-references-in-binaries", error_msg, d) + return False + else: + # Sometimes this is done deliberately (e.g, e2fsprogs), so only warn + bb.warn("%s has missing library dependencies" % path) + return + if sysroot_path_usr in ldd_output: + error_msg = pn + ": %s links to something under exec_prefix" % path + package_qa_handle_error("unsafe-references-in-binaries", error_msg, d) + error_msg = "ldd reports: %s" % ldd_output + package_qa_handle_error("unsafe-references-in-binaries", error_msg, d) + return False + +QAPATHTEST[unsafe-references-in-scripts] = "package_qa_check_unsafe_references_in_scripts" +def package_qa_check_unsafe_references_in_scripts(path, name, d, elf, messages): + """ + Warn if scripts in base_[bindir|sbindir|libdir] reference files under exec_prefix + """ + if unsafe_references_skippable(path, name, d): + return + + if not elf: + import stat + pn = d.getVar('PN', True) + + # Ensure we're checking an executable script + statinfo = os.stat(path) + if bool(statinfo.st_mode & stat.S_IXUSR): + # grep shell scripts for possible references to /exec_prefix/ + exec_prefix = d.getVar('exec_prefix', True) + statement = "grep -e '%s/' %s > /dev/null" % (exec_prefix, path) + if os.system(statement) == 0: + error_msg = pn + ": Found a reference to %s/ in %s" % (exec_prefix, path) + package_qa_handle_error("unsafe-references-in-scripts", error_msg, d) + error_msg = "Shell scripts in base_bindir and base_sbindir should not reference anything in exec_prefix" + package_qa_handle_error("unsafe-references-in-scripts", error_msg, d) + +def unsafe_references_skippable(path, name, d): + if bb.data.inherits_class('native', d) or bb.data.inherits_class('nativesdk', d): + return True + + if "-dbg" in name or "-dev" in name: + return True + + # Other package names to skip: + if name.startswith("kernel-module-"): + return True + + # Skip symlinks + if os.path.islink(path): + return True + + # Skip unusual rootfs layouts which make these tests irrelevant + exec_prefix = d.getVar('exec_prefix', True) + if exec_prefix == "": + return True + + pkgdest = d.getVar('PKGDEST', True) + pkgdest = pkgdest + "/" + name + pkgdest = os.path.abspath(pkgdest) + base_bindir = pkgdest + d.getVar('base_bindir', True) + base_sbindir = pkgdest + d.getVar('base_sbindir', True) + base_libdir = pkgdest + d.getVar('base_libdir', True) + bindir = pkgdest + d.getVar('bindir', True) + sbindir = pkgdest + d.getVar('sbindir', True) + libdir = pkgdest + d.getVar('libdir', True) + + if base_bindir == bindir and base_sbindir == sbindir and base_libdir == libdir: + return True + + # Skip files not in base_[bindir|sbindir|libdir] + path = os.path.abspath(path) + if not (base_bindir in path or base_sbindir in path or base_libdir in path): + return True + + return False + QAPATHTEST[arch] = "package_qa_check_arch" def package_qa_check_arch(path,name,d, elf, messages): """
Signature · 1 line
1.7.5.4
Saul Wold
AppliedQuoted 48 lines · Scott Garman
Hello,
This is a P2 feature for Yocto 1.2. It adds two new QA tests to check files in
base_bindir,base_sbindir, andbase_libdirfor references to files underexec_prefix(e.g, dynamic linking for binaries and references toexec_prefixin scripts).The reason for these tests is that
exec_prefix(typically /usr) can be kept on a separate partition that may be mounted late in the boot process, or may not be mounted at all during system recovery operations.It was my original goal to make the dynamic linking test a QA error upon failure, but it turned out the amount of recipe work needed was much larger than I expected. So for the time being they have been changed to generate QA warmings.
The libraries I've moved to
base_libdirin this pull request should take care of all binaries in /bin and /sbin for packages we include in core-image-minimal and -sato.I would like to ask recipe maintainers to look for these QA warnings and fix them ASAP, as I believe we'll be changing this to a QA error before the release of 1.2.
This is a second pull request that is rebased against the latest master with merge conflicts resolved, and only sets
BUILD_LDFLAGSin ncurses.inc for virtclass-native.Scott
The following changes since commit
de679a3036ebef1c7d7b8ee23f05590c95e498d9:pseudo: ensure libs are included in package (2012-01-03 12:10:59 +0000)
are available in the git repository at:
git://git.pokylinux.org/poky-contribsgarman/per-recipe-sanitychk-final
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=sgarman/per-recipe-sanitychk-finalScott Garman (7):
ncurses: move libraries tobase_libdir
libcap: move library tobase_libdir
util-linux: move libraries tobase_libdir
e2fsprogs: move libraries tobase_libdir
libusb1: move libraries tobase_libdir
libusb-compat: move libraries tobase_libdirinsane.bbclass: add QA tests for unsafe references toexec_prefix
Quoted 11 lines
meta/classes/insane.bbclass | 111 +++++++++++++++++++- meta/recipes-core/ncurses/ncurses.inc | 27 +++-- meta/recipes-core/util-linux/util-linux.inc | 20 ++-- meta/recipes-core/util-linux/util-linux_2.20.1.bb | 2 +- .../e2fsprogs/e2fsprogs_1.41.14.bb | 29 +++-- meta/recipes-support/libcap/libcap.inc | 15 +++- meta/recipes-support/libcap/libcap_2.22.bb | 2 +- meta/recipes-support/libusb/libusb-compat_0.1.3.bb | 12 ++- meta/recipes-support/libusb/libusb1_1.0.8.bb | 16 +++- 9 files changed, 196 insertions(+), 38 deletions(-)
Merged into OE-Core
Thanks
Sau!
Quoted 22 lines · Saul Wold
Quoted 21 lines · Scott Garman
Hello,
This is a P2 feature for Yocto 1.2. It adds two new QA tests to check files in
base_bindir,base_sbindir, andbase_libdirfor references to files underexec_prefix(e.g, dynamic linking for binaries and references toexec_prefixin scripts).The reason for these tests is that
exec_prefix(typically /usr) can be kept on a separate partition that may be mounted late in the boot process, or may not be mounted at all during system recovery operations.It was my original goal to make the dynamic linking test a QA error upon failure, but it turned out the amount of recipe work needed was much larger than I expected. So for the time being they have been changed to generate QA warmings.
The libraries I've moved to
base_libdirin this pull request should take care of all binaries in /bin and /sbin for packages we include in core-image-minimal and -sato.
Quoted 8 lines
Quoted 8 lines
I would like to ask recipe maintainers to look for these QA warnings and fix them ASAP, as I believe we'll be changing this to a QA error before the release of 1.2.
This is a second pull request that is rebased against the latest master with merge conflicts resolved, and only sets
BUILD_LDFLAGSin ncurses.inc for virtclass-native.
I missed that and it explains first part of [1]. Wondering how long this will us take...
Andreas
[1] http://lists.linuxtogo.org/pipermail/openembedded-core/2012-
January/015667.html