Skip to content

Commit 91d1618

Browse files
committed
scripts/package: tar-pkg: use tar --owner=root
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. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
1 parent 8723eae commit 91d1618

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎scripts/package/buildtar‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ esac
101101
#
102102
(
103103
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}"
105109
)
106110

107111
echo "Tarball successfully created in ${tarball}${file_ext}"

0 commit comments

Comments
 (0)