Blame 0003-dracut.sh-only-set-the-owner-of-files-to-0-0-if-gene.patch

Harald Hoyer bcb5fa
From c8a9a6b4a7dff76c66e84f65b2717632e1bb4505 Mon Sep 17 00:00:00 2001
Harald Hoyer bcb5fa
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer bcb5fa
Date: Thu, 30 Jan 2014 16:11:40 +0100
Harald Hoyer bcb5fa
Subject: [PATCH] dracut.sh: only set the owner of files to 0:0, if generated
Harald Hoyer bcb5fa
 as non-root
Harald Hoyer bcb5fa
Harald Hoyer bcb5fa
If the root user generates the initramfs image, preserve the ownership
Harald Hoyer bcb5fa
of the files. This of course cannot be done for non-root users
Harald Hoyer bcb5fa
generating an initramfs image.
Harald Hoyer bcb5fa
---
Harald Hoyer bcb5fa
 dracut.sh | 7 +++++--
Harald Hoyer bcb5fa
 1 file changed, 5 insertions(+), 2 deletions(-)
Harald Hoyer bcb5fa
Harald Hoyer bcb5fa
diff --git a/dracut.sh b/dracut.sh
Harald Hoyer bcb5fa
index 9b715ab..ccff358 100755
Harald Hoyer bcb5fa
--- a/dracut.sh
Harald Hoyer bcb5fa
+++ b/dracut.sh
Harald Hoyer bcb5fa
@@ -1462,13 +1462,16 @@ fi
Harald Hoyer bcb5fa
 
Harald Hoyer bcb5fa
 rm -f -- "$outfile"
Harald Hoyer bcb5fa
 dinfo "*** Creating image file ***"
Harald Hoyer bcb5fa
+
Harald Hoyer bcb5fa
+[[ "$UID" != 0 ]] && cpio_owner_root="-R 0:0"
Harald Hoyer bcb5fa
+
Harald Hoyer bcb5fa
 if [[ $create_early_cpio = yes ]]; then
Harald Hoyer bcb5fa
     echo 1 > "$early_cpio_dir/d/early_cpio"
Harald Hoyer bcb5fa
     # The microcode blob is _before_ the initramfs blob, not after
Harald Hoyer bcb5fa
-    (cd "$early_cpio_dir/d";     find . -print0 | cpio --null -R 0:0 -H newc -o --quiet >../early.cpio)
Harald Hoyer bcb5fa
+    (cd "$early_cpio_dir/d";     find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet >../early.cpio)
Harald Hoyer bcb5fa
     mv $early_cpio_dir/early.cpio $outfile.$$
Harald Hoyer bcb5fa
 fi
Harald Hoyer bcb5fa
-if ! ( umask 077; cd "$initdir"; find . -print0 | cpio --null -R 0:0 -H newc -o --quiet | \
Harald Hoyer bcb5fa
+if ! ( umask 077; cd "$initdir"; find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet | \
Harald Hoyer bcb5fa
     $compress >> "$outfile.$$"; ); then
Harald Hoyer bcb5fa
     dfatal "dracut: creation of $outfile.$$ failed"
Harald Hoyer bcb5fa
     exit 1