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

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