]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut.sh: only set the owner of files to 0:0, if generated as non-root
authorHarald Hoyer <harald@redhat.com>
Thu, 30 Jan 2014 15:11:40 +0000 (16:11 +0100)
committerHarald Hoyer <harald@redhat.com>
Thu, 30 Jan 2014 15:18:04 +0000 (16:18 +0100)
If the root user generates the initramfs image, preserve the ownership
of the files. This of course cannot be done for non-root users
generating an initramfs image.

dracut.sh

index 9b715abfbbe4c017006683369b1ae12c65fbbc89..ccff358adef8b9f1499fdff88c28c9398b3ed0e9 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -1462,13 +1462,16 @@ fi
 
 rm -f -- "$outfile"
 dinfo "*** Creating image file ***"
+
+[[ "$UID" != 0 ]] && cpio_owner_root="-R 0:0"
+
 if [[ $create_early_cpio = yes ]]; then
     echo 1 > "$early_cpio_dir/d/early_cpio"
     # The microcode blob is _before_ the initramfs blob, not after
-    (cd "$early_cpio_dir/d";     find . -print0 | cpio --null -R 0:0 -H newc -o --quiet >../early.cpio)
+    (cd "$early_cpio_dir/d";     find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet >../early.cpio)
     mv $early_cpio_dir/early.cpio $outfile.$$
 fi
-if ! ( umask 077; cd "$initdir"; find . -print0 | cpio --null -R 0:0 -H newc -o --quiet | \
+if ! ( umask 077; cd "$initdir"; find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet | \
     $compress >> "$outfile.$$"; ); then
     dfatal "dracut: creation of $outfile.$$ failed"
     exit 1