Do not create target directory in /dev
authorDarshaka Pathirana <dpat@syn-net.org>
Fri, 14 Dec 2018 15:19:25 +0000 (16:19 +0100)
committerDarshaka Pathirana <dpat@syn-net.org>
Fri, 14 Dec 2018 15:19:25 +0000 (16:19 +0100)
grml-debootstrap used to happily create a target directory in /dev if
for instance one forgot to partition sda. To avoid such a mistake it
feels better to abort the installation.

Closes: grml/grml-debootstrap#99

grml-debootstrap

index ab7c577..776825d 100755 (executable)
@@ -1187,6 +1187,12 @@ set_target_directory(){
 if [ -b "$TARGET" ] || [ -n "$VIRTUAL" ] ; then
     PARTITION=1
 else
 if [ -b "$TARGET" ] || [ -n "$VIRTUAL" ] ; then
     PARTITION=1
 else
+    # $TARGET was not detected as block device, but we do not want to create target directory in /dev/
+    if [[ $TARGET == "/dev/"* ]]; then
+      eerror "Error: Will not create target directory $TARGET in /dev."
+      eerror "  Please check the partition(s) of the blockdevice."; eend 1
+      bailout 1
+    fi
     set_target_directory
 fi
 # }}}
     set_target_directory
 fi
 # }}}