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

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