From c0b975a8e3efacd965ec5166af4d572253f51143 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 1 Sep 2012 16:11:54 -0400 Subject: mkinitcpio: refuse to run if image path isn't writeable Signed-off-by: Dave Reisner --- mkinitcpio | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mkinitcpio b/mkinitcpio index 5fec347..5bed94e 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -323,6 +323,13 @@ fi if [[ -z $GENIMG ]]; then msg "Starting dry run: %s" "$KERNELVERSION" else + # check for permissions. if the image doesn't already exist, + # then check the directory + if [[ ( -e $GENIMG && ! -w $GENIMG ) || + ( ! -d ${GENIMG%/*} || ! -w ${GENIMG%/*} ) ]]; then + die 'Unable to write to %s' "$GENIMG" + fi + COMPRESSION=${optcompress:-$COMPRESSION} if ! type -P "$COMPRESSION" >/dev/null; then die "Unable to locate compression method: %s" "$COMPRESSION" -- cgit v1.2.3-24-g4f1b