Use the --owner= and --group= options to make sure the entries in the built tar file are owned by root. Without this change, a careless sysadmin using the tar-pkg target can easily end up installing a kernel that is writable by the unprivileged user account used to build the kernel. Test that these options are understood before using them so that non-GNU versions of tar can still be used if the operator is appropriately cautious.
Unified · Split
| @@ -101,7 +101,11 @@ esac · 100 unmodified lines | |||
| 101 | # | 101 | # |
| 102 | ( | 102 | ( |
| 103 | cd "${tmpdir}" | 103 | cd "${tmpdir}" |
| 104 | tar cf - . | ${compress} > "${tarball}${file_ext}" | 104 | opts= |
| 105 | if tar --owner=root --group=root --help >/dev/null 2>&1; then | ||
| 106 | opts="--owner=root --group=root" | ||
| 107 | fi | ||
| 108 | tar cf - . $opts | ${compress} > "${tarball}${file_ext}" | ||
| 105 | ) | 109 | ) |
| 106 | 110 | ||
| 107 | echo "Tarball successfully created in ${tarball}${file_ext}" | 111 | echo "Tarball successfully created in ${tarball}${file_ext}" |