From: Harald Hoyer Date: Thu, 18 Feb 2010 17:27:39 +0000 (+0100) Subject: dracut: add check, if we can write to the output image file X-Git-Tag: 005~36 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=454771cd86558bac6dcce99294a9aaaa8f10dc8f;p=thirdparty%2Fdracut.git dracut: add check, if we can write to the output image file --- diff --git a/dracut b/dracut index 47908c469..7e2b95482 100755 --- a/dracut +++ b/dracut @@ -177,7 +177,8 @@ case $dracutmodules in esac [[ $2 ]] && kernel=$2 || kernel=$(uname -r) -[[ $1 ]] && outfile=$(readlink -f $1) || outfile="/boot/initramfs-$kernel.img" +[[ $1 ]] && outfile=$1 || outfile="/boot/initramfs-$kernel.img" +abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile" srcmods="/lib/modules/$kernel/" [[ $drivers_dir ]] && srcmods="$drivers_dir" @@ -188,7 +189,18 @@ if [[ -f $outfile && ! $force ]]; then exit 1 fi -if ! [[ -w $(dirname $outfile) ]]; then +outdir=$(dirname "$outfile") +if ! [[ -d "$outdir" ]]; then + echo "Can't write $outfile: Directory $outdir does not exist." + exit 1 +fi + +if ! [[ -w "$outdir" ]]; then + echo "No permission to write $outdir." + exit 1 +fi + +if [[ -f "$outfile" ]] && ! [[ -w "$outfile" ]]; then echo "No permission to write $outfile." exit 1 fi