Skip to content

Commit

Permalink
scripts/package: tar-pkg: use tar --owner=root
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michal Marek committed Dec 12, 2009
1 parent 8723eae commit 91d1618
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scripts/package/buildtar
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ esac
#
(
cd "${tmpdir}"
tar cf - . | ${compress} > "${tarball}${file_ext}"
opts=
if tar --owner=root --group=root --help >/dev/null 2>&1; then
opts="--owner=root --group=root"
fi
tar cf - . $opts | ${compress} > "${tarball}${file_ext}"
)

echo "Tarball successfully created in ${tarball}${file_ext}"
Expand Down

0 comments on commit 91d1618

Please sign in to comment.