diff options
Diffstat (limited to 'meta/classes/insane.bbclass')
| -rw-r--r-- | meta/classes/insane.bbclass | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass index 7ea80dc90c..5c8629af1d 100644 --- a/meta/classes/insane.bbclass +++ b/meta/classes/insane.bbclass | |||
| @@ -32,14 +32,14 @@ WARN_QA ?= "ldflags useless-rpaths rpaths staticdev libdir xorg-driver-abi \ | |||
| 32 | installed-vs-shipped compile-host-path install-host-path \ | 32 | installed-vs-shipped compile-host-path install-host-path \ |
| 33 | pn-overrides infodir build-deps file-rdeps \ | 33 | pn-overrides infodir build-deps file-rdeps \ |
| 34 | unknown-configure-option symlink-to-sysroot multilib \ | 34 | unknown-configure-option symlink-to-sysroot multilib \ |
| 35 | invalid-pkgconfig \ | 35 | invalid-pkgconfig host-user-contaminated \ |
| 36 | " | 36 | " |
| 37 | ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \ | 37 | ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \ |
| 38 | perms dep-cmp pkgvarcheck perm-config perm-line perm-link \ | 38 | perms dep-cmp pkgvarcheck perm-config perm-line perm-link \ |
| 39 | split-strip packages-list pkgv-undefined var-undefined \ | 39 | split-strip packages-list pkgv-undefined var-undefined \ |
| 40 | version-going-backwards expanded-d invalid-chars \ | 40 | version-going-backwards expanded-d invalid-chars \ |
| 41 | " | 41 | " |
| 42 | FAKEROOT_QA = "" | 42 | FAKEROOT_QA = "host-user-contaminated" |
| 43 | FAKEROOT_QA[doc] = "QA tests which need to run under fakeroot. If any \ | 43 | FAKEROOT_QA[doc] = "QA tests which need to run under fakeroot. If any \ |
| 44 | enabled tests are listed here, the do_package_qa task will run under fakeroot." | 44 | enabled tests are listed here, the do_package_qa task will run under fakeroot." |
| 45 | 45 | ||
| @@ -969,6 +969,39 @@ def package_qa_check_encoding(keys, encode, d): | |||
| 969 | if not sane: | 969 | if not sane: |
| 970 | break | 970 | break |
| 971 | 971 | ||
| 972 | HOST_USER_UID := "${@os.getuid()}" | ||
| 973 | HOST_USER_GID := "${@os.getgid()}" | ||
| 974 | |||
| 975 | QAPATHTEST[host-user-contaminated] = "package_qa_check_host_user" | ||
| 976 | def package_qa_check_host_user(path, name, d, elf, messages): | ||
| 977 | """Check for paths outside of /home which are owned by the user running bitbake.""" | ||
| 978 | |||
| 979 | if not os.path.lexists(path): | ||
| 980 | return | ||
| 981 | |||
| 982 | dest = d.getVar('PKGDEST', True) | ||
| 983 | home = os.path.join(dest, 'home') | ||
| 984 | if path == home or path.startswith(home + os.sep): | ||
| 985 | return | ||
| 986 | |||
| 987 | try: | ||
| 988 | stat = os.lstat(path) | ||
| 989 | except OSError as exc: | ||
| 990 | import errno | ||
| 991 | if exc.errno != errno.ENOENT: | ||
| 992 | raise | ||
| 993 | else: | ||
| 994 | check_uid = int(d.getVar('HOST_USER_UID', True)) | ||
| 995 | if stat.st_uid == check_uid: | ||
| 996 | 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) | ||
| 997 | return False | ||
| 998 | |||
| 999 | check_gid = int(d.getVar('HOST_USER_GID', True)) | ||
| 1000 | if stat.st_gid == check_gid: | ||
| 1001 | 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) | ||
| 1002 | return False | ||
| 1003 | return True | ||
| 1004 | |||
| 972 | # The PACKAGE FUNC to scan each package | 1005 | # The PACKAGE FUNC to scan each package |
| 973 | python do_package_qa () { | 1006 | python do_package_qa () { |
| 974 | import subprocess | 1007 | import subprocess |
