scripts/package: tar-pkg: use tar --owner=root
authorMichal Marek <mmarek@suse.cz>
Tue, 24 Nov 2009 15:11:37 +0000 (09:11 -0600)
committerMichal Marek <mmarek@suse.cz>
Sat, 12 Dec 2009 12:08:15 +0000 (13:08 +0100)
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>
scripts/package/buildtar

index b1fd48d..51b2aa0 100644 (file)
@@ -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}"