Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Joshua Lock <joshua.lock@collabora.co.uk>
To: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH 2/3] insane.bbclass: add host-user-contaminated test
Date: Wed, 26 Aug 2015 09:44:56 +0100	[thread overview]
Message-ID: <55DD7C88.4080305@collabora.co.uk> (raw)
In-Reply-To: <3843d76235f7517207f9aa178d70c731f2b2d51e.1440454290.git.chris_larson@mentor.com>

On 24/08/15 23:19, Christopher Larson wrote:
> From: Christopher Larson <chris_larson@mentor.com>
>
> - Add a test which checks for any paths outside of /home which are owned by
>    the user running bitbake.
> - Add the test to WARN_QA by default.

I do all of my builds on a separate partition in a directory hierarchy 
which is owned by my user - if I'm understanding this correctly I'll get 
QA WARNINGS for all of my builds with this change?

It would be nice to be able to bless my build directory and still 
benefit from this check.

Regards,

Joshua

> This test has been in meta-mentor for some time, and in our ERROR_QA for our
> builds, and has caught a number of issues for us.
>
> Signed-off-by: Christopher Larson <chris_larson@mentor.com>
> ---
>   meta/classes/insane.bbclass | 32 ++++++++++++++++++++++++++++++--
>   1 file changed, 30 insertions(+), 2 deletions(-)
>
> diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
> index cd773b7..aec9800 100644
> --- a/meta/classes/insane.bbclass
> +++ b/meta/classes/insane.bbclass
> @@ -31,14 +31,14 @@ WARN_QA ?= "ldflags useless-rpaths rpaths staticdev libdir xorg-driver-abi \
>               installed-vs-shipped compile-host-path install-host-path \
>               pn-overrides infodir build-deps file-rdeps \
>               unknown-configure-option symlink-to-sysroot multilib \
> -            invalid-pkgconfig \
> +            invalid-pkgconfig host-user-contaminated \
>               "
>   ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \
>               perms dep-cmp pkgvarcheck perm-config perm-line perm-link \
>               split-strip packages-list pkgv-undefined var-undefined \
>               version-going-backwards expanded-d \
>               "
> -FAKEROOT_QA = ""
> +FAKEROOT_QA = "host-user-contaminated"
>   FAKEROOT_QA[doc] = "QA tests which need to run under fakeroot. If any \
>   enabled tests are listed here, the do_package_qa task will run under fakeroot."
>
> @@ -950,6 +950,34 @@ def package_qa_check_expanded_d(path,name,d,elf,messages):
>                           sane = False
>       return sane
>
> +HOST_USER_UID := "${@os.getuid()}"
> +HOST_USER_GID := "${@os.getgid()}"
> +
> +QAPATHTEST[host-user-contaminated] = "package_qa_check_host_user"
> +def package_qa_check_host_user(path, name, d, elf, messages):
> +    """Check for paths outside of /home which are owned by the user running bitbake."""
> +
> +    if not os.path.lexists(path):
> +        return
> +
> +    check_uid = int(d.getVar('HOST_USER_UID', True))
> +    check_gid = int(d.getVar('HOST_USER_GID', True))
> +
> +    dest = d.getVar('PKGDEST', True)
> +    home = os.path.join(dest, 'home')
> +    if path == home or path.startswith(home + os.sep):
> +        return
> +
> +    stat = os.lstat(path)
> +    if stat.st_uid == check_uid:
> +        messages["host-user-contaminated"] = "%s is owned by uid %d, which is the same as the user running bitbake. This may be due to host contamination" % (path, check_uid)
> +        return False
> +
> +    if stat.st_gid == check_gid:
> +        messages["host-user-contaminated"] = "%s is owned by gid %d, which is the same as the user running bitbake. This may be due to host contamination" % (path, check_gid)
> +        return False
> +    return True
> +
>   # The PACKAGE FUNC to scan each package
>   python do_package_qa () {
>       import subprocess
>



  reply	other threads:[~2015-08-26  8:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-24 22:19 [PATCH 0/3] Add checks for "host user contamination" Christopher Larson
2015-08-24 22:19 ` [PATCH 1/3] insane.bbclass: handle tests which need fakeroot Christopher Larson
2015-08-24 22:19 ` [PATCH 2/3] insane.bbclass: add host-user-contaminated test Christopher Larson
2015-08-26  8:44   ` Joshua Lock [this message]
2015-08-26 11:01     ` Burton, Ross
2015-08-26 14:19       ` Christopher Larson
2015-08-26 14:20         ` Christopher Larson
2015-08-26 14:24           ` Joshua Lock
2015-08-24 22:19 ` [PATCH 3/3] image.bbclass: add rootfs_check_host_user_contaminated Christopher Larson
2015-09-01  7:50 ` [PATCH 0/3] Add checks for "host user contamination" Richard Purdie
2015-09-01  7:52   ` Richard Purdie
2015-09-01 15:05     ` Christopher Larson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55DD7C88.4080305@collabora.co.uk \
    --to=joshua.lock@collabora.co.uk \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox