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