]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut: check more return codes, check for permissions and use derror
authorHarald Hoyer <harald@redhat.com>
Thu, 19 Nov 2009 14:46:09 +0000 (15:46 +0100)
committerHarald Hoyer <harald@redhat.com>
Thu, 19 Nov 2009 14:46:09 +0000 (15:46 +0100)
dracut

diff --git a/dracut b/dracut
index 7227f8c739d3e5383c0d8bdb5b59f769738c9094..96b03533394381b47d2a0f368ce0137b87b3c156 100755 (executable)
--- a/dracut
+++ b/dracut
@@ -174,9 +174,16 @@ if [[ -f $outfile && ! $force ]]; then
     exit 1
 fi
 
+if ! [[ -w $(dirname $outfile) ]]; then
+    echo "No permission to write $outfile."
+    exit 1
+fi
+
 hookdirs="cmdline pre-udev pre-trigger netroot pre-mount pre-pivot mount emergency"
 
+[[ -n "$TMPDIR" ]] && ! [[ -w "$TMPDIR" ]] && unset TMPDIR
 readonly initdir=$(mktemp -d -t initramfs.XXXXXX)
+
 trap 'ret=$?;rm -rf "$initdir";exit $ret;' EXIT # clean up after ourselves no matter how we die.
 trap 'exit 1;' SIGINT # clean up after ourselves no matter how we die.
 
@@ -220,7 +227,7 @@ unset moddir
 # generate module dependencies for the initrd
 if [[ -d $initdir/lib/modules/$kernel ]]; then
     if ! depmod -a -b "$initdir" $kernel; then
-        echo "\"depmod -a $kernel\" failed."
+        derror "\"depmod -a $kernel\" failed."
         exit 1
     fi
 fi
@@ -269,7 +276,11 @@ if [[ $do_strip = yes ]] ; then
     done
 fi
 
-( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet |gzip -9 > "$outfile"; )
+( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet |gzip -9 > "$outfile"; ) 
+if [ $? -ne 0 ]; then
+    derror "dracut: creation of $outfile failed"
+    exit 1
+fi 
 
 [[ $beverbose = yes ]] && ls -lh "$outfile"