Bug 1008

Summary: New santiy check for userspace packages
Product: [Build System, Metadata & Runtime] Meta-yocto Reporter: Mark Hatle <mark.hatle>
Component: meta-yoctoAssignee: Scott Garman <scott.a.garman>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: Low CC: jiajun.xu, poky.bs.watcher, poky.watcher, scott.a.garman, sgw, song.liu
Version: unspecified   
Target Milestone: 1.2 M1   
Hardware: x86   
OS: Multiple   
Whiteboard: (P2)(QA Testing Completed) (Done)
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---

Description Mark Hatle 2011-04-26 09:35:51 UTC
There is a general rule on Linux systems where the items in /bin, /sbin and /lib should never referenced things location under the /usr mount.

This is because /usr may be mounted much later in boot cycle, or perhaps won't be mounted at all in case of a system recovery action.

A sanity check should be added that verify that scripts, and libraries from /bin, /sbin and /lib do not reference other libraries that exist in outside of the /bin, /sbin and /lib directories.

This sanity check may be partially done during package generation, but may also have to be done at the end after the rootfs image has been constructed.
Comment 1 Scott Garman 2011-11-09 14:02:46 UTC
Design I'm starting with:

Iterate through each file in /bin, /sbin, and /lib of the rootfs, and grep the output of the 'file' command to determine which type the file is. Based on my desktop system, the keywords I'd grep for are:

ELF - binary or library
Bourne - shell script
"POSIX shell" - shell script

Then based on this I would grep shell scripts for "usr", and grep the output of ldd of binaries/libraries for "usr". I'd then throw a QA warning.

This would be a function I'd add to the default do_package step.
Comment 2 Mark Hatle 2011-11-09 14:33:46 UTC
I think the general design is correct.  But you'll likely want to break this up into a few steps as some are more useful (and time consuming) then others.

The critical one for me is the library dependencies.. things installed in /bin or /sbin should not reference libraries in /usr/lib.  Similarly libraries in /lib should also not references libraries in /usr/lib.  These to me should be an error.

For the scripts scanning for specific calls to /usr/...  from the items in /bin and /sbin.  This is likely the right approach.  It's far from fool-proof, but it will help...
Comment 3 Saul Wold 2011-11-11 10:40:02 UTC
Design ACK'ed
Comment 5 Jiajun Xu 2012-02-05 21:21:05 UTC
I tested against latest master with commit cb89d43473a91ff4cb2447d642fcd9308d7366e3, the feature could work and improper link would be reported out by bitbake.