]> code.ossystems Code Review - openembedded-core.git/commitdiff
image.bbclass: add rootfs_check_host_user_contaminated
authorChristopher Larson <chris_larson@mentor.com>
Tue, 1 Sep 2015 22:23:04 +0000 (15:23 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 3 Sep 2015 12:32:11 +0000 (13:32 +0100)
This function is intended to be used in ROOTFS_POSTPROCESS_COMMAND, and checks
for any paths outside of /home which are owned by the user running bitbake.

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/image.bbclass

index 4e66535407e8633834aaba89c6fa4f9388fc6be2..fc7d64d7e56e00acdb7459d28f9ea5048d62d7cf 100644 (file)
@@ -460,6 +460,20 @@ rootfs_trim_schemas () {
        done
 }
 
+rootfs_check_host_user_contaminated () {
+       contaminated="${WORKDIR}/host-user-contaminated.txt"
+       HOST_USER_UID="$(PSEUDO_UNLOAD=1 id -u)"
+       HOST_USER_GID="$(PSEUDO_UNLOAD=1 id -g)"
+
+       find "${IMAGE_ROOTFS}" -wholename "${IMAGE_ROOTFS}/home" -prune \
+           -user "$HOST_USER_UID" -o -group "$HOST_USER_GID" >"$contaminated"
+
+       if [ -s "$contaminated" ]; then
+               echo "WARNING: Paths in the rootfs are owned by the same user or group as the user running bitbake. See the logfile for the specific paths."
+               cat "$contaminated" | sed "s,^,  ,"
+       fi
+}
+
 # Make any absolute links in a sysroot relative
 rootfs_sysroot_relativelinks () {
        sysroot-relativelinks.py ${SDK_OUTPUT}/${SDKTARGETSYSROOT}