Blame SOURCES/0012-dracut.sh-bail-out-early-if-destination-dir-is-not-w.patch

90b079
From 96cf7270da8f99e3972b18677e7f392a35d6ddd9 Mon Sep 17 00:00:00 2001
90b079
From: Harald Hoyer <harald@redhat.com>
90b079
Date: Wed, 2 Oct 2013 12:48:11 +0200
90b079
Subject: [PATCH] dracut.sh: bail out early, if destination dir is not
90b079
 writeable
90b079
90b079
---
90b079
 dracut.sh | 36 +++++++++++++++++++-----------------
90b079
 1 file changed, 19 insertions(+), 17 deletions(-)
90b079
90b079
diff --git a/dracut.sh b/dracut.sh
90b079
index b4b3e13..e135dfc 100755
90b079
--- a/dracut.sh
90b079
+++ b/dracut.sh
90b079
@@ -824,9 +824,25 @@ if [[ -d $srcmods ]]; then
90b079
     }
90b079
 fi
90b079
 
90b079
-if [[ -f $outfile && ! $force && ! $print_cmdline ]]; then
90b079
-    dfatal "Will not override existing initramfs ($outfile) without --force"
90b079
-    exit 1
90b079
+if [[ ! $print_cmdline ]]; then
90b079
+    if [[ -f $outfile && ! $force ]]; then
90b079
+        dfatal "Will not override existing initramfs ($outfile) without --force"
90b079
+        exit 1
90b079
+    fi
90b079
+
90b079
+    outdir=${outfile%/*}
90b079
+    [[ $outdir ]] || outdir="/"
90b079
+
90b079
+    if [[ ! -d "$outdir" ]]; then
90b079
+        dfatal "Can't write to $outdir: Directory $outdir does not exist or is not accessible."
90b079
+        exit 1
90b079
+    elif [[ ! -w "$outdir" ]]; then
90b079
+        dfatal "No permission to write to $outdir."
90b079
+        exit 1
90b079
+    elif [[ -f "$outfile" && ! -w "$outfile" ]]; then
90b079
+        dfatal "No permission to write $outfile."
90b079
+        exit 1
90b079
+    fi
90b079
 fi
90b079
 
90b079
 # Need to be able to have non-root users read stuff (rpcbind etc)
90b079
@@ -1041,20 +1057,6 @@ if [[ $print_cmdline ]]; then
90b079
     exit 0
90b079
 fi
90b079
 
90b079
-outdir=${outfile%/*}
90b079
-[[ $outdir ]] || outdir="/"
90b079
-
90b079
-if [[ ! -d "$outdir" ]]; then
90b079
-    dfatal "Can't write to $outdir: Directory $outdir does not exist or is not accessible."
90b079
-    exit 1
90b079
-elif [[ ! -w "$outdir" ]]; then
90b079
-    dfatal "No permission to write to $outdir."
90b079
-    exit 1
90b079
-elif [[ -f "$outfile" && ! -w "$outfile" ]]; then
90b079
-    dfatal "No permission to write $outfile."
90b079
-    exit 1
90b079
-fi
90b079
-
90b079
 # Create some directory structure first
90b079
 [[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
90b079