summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-09-01 22:11:54 +0200
committerDave Reisner <dreisner@archlinux.org>2012-09-01 22:11:54 +0200
commitc0b975a8e3efacd965ec5166af4d572253f51143 (patch)
tree965b103b2f146583d837f264e7082817e8e0b35f
parent8291fd0f3965fa7ea2790d17d2e53c8b9c252863 (diff)
downloadmkinitcpio-c0b975a8e3efacd965ec5166af4d572253f51143.tar.gz
mkinitcpio-c0b975a8e3efacd965ec5166af4d572253f51143.tar.xz
mkinitcpio: refuse to run if image path isn't writeable
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
-rwxr-xr-xmkinitcpio7
1 files changed, 7 insertions, 0 deletions
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"