Bug 1008 - New santiy check for userspace packages
Summary: New santiy check for userspace packages
Status: RESOLVED FIXED
Alias: None
Product: Meta-yocto
Classification: Build System, Metadata & Runtime
Component: meta-yocto (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Low enhancement
Target Milestone: 1.2 M1
Assignee: Scott Garman
QA Contact:
URL:
Whiteboard: (P2)(QA Testing Completed) (Done)
Depends on:
Blocks:
 
Reported: 2011-04-26 09:35 UTC by Mark Hatle
Modified: 2012-02-06 10:24 UTC (History)
6 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.