From 2e43ae3750164eee688a01dc6f9526707d27bc39 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Wed, 3 May 2006 01:04:45 +0000 Subject: Sanity checks tidied up now. --- ezjail-admin | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'ezjail-admin') diff --git a/ezjail-admin b/ezjail-admin index 429cbb8..71863ef 100755 --- a/ezjail-admin +++ b/ezjail-admin @@ -167,7 +167,7 @@ create) if [ "${ezjail_imagesize}" ]; then _val=`echo "${ezjail_imagesize}"|tr A-Z a-z|sed -Ees:g:km:g -es:m:kk:g -es:k:*2b:g -es:b:*128w:g -es:w:*4\ :g -e"s:(^|[^0-9])0x:\1\0X:g" -ey:x:*:` _val=`echo $(( ${_val} ))` - [ $? -eq 0 -o ${_val} -lt 1 ] || exerr "Error: The image size you specified is somehow incomprehensible (you specified ${ezjail_imagesize}." + [ $? -eq 0 -a ${_val} -gt 0 ] || exerr "Error: The image size you specified is somehow incomprehensible (you specified ${ezjail_imagesize}." ezjail_imageblockcount=$(( ${_val} / 1048576 )) ezjail_imagerestbytes=$(( ${_val} % 1048576 )) fi @@ -233,8 +233,12 @@ create) # Now create jail disc image touch "${ezjail_image}" - [ "${ezjail_imageblockcount}" -gt 0 ] && dd if=/dev/random of="${ezjail_image}" bs=1m count=${ezjail_imageblockcount} || exerr "Error: Could not (or not fully) create the image file. You might want to check (and possibly remove) the file ${ezjail_image}. The image size provided was ${ezjail_imagesize}." - [ "${ezjail_imagerestbytes}" -gt 0 ] && ( dd if=/dev/random bs=${ezjail_imagerestbytes} count=1 >> "${ezjail_image}" ) || exerr "Error: Could not (or not fully) create the image file. You might want to check (and possibly remove) the file ${ezjail_image}. The image size provided was ${ezjail_imagesize}." + if [ "${ezjail_imageblockcount}" -gt 0 ]; then + dd if=/dev/random of="${ezjail_image}" bs=1m count=${ezjail_imageblockcount} || exerr "Error: Could not (or not fully) create the image file. You might want to check (and possibly remove) the file ${ezjail_image}. The image size provided was ${ezjail_imagesize}." + fi + if [ "${ezjail_imagerestbytes}" -gt 0 ]; then + ( dd if=/dev/random bs=${ezjail_imagerestbytes} count=1 >> "${ezjail_image}" ) || exerr "Error: Could not (or not fully) create the image file. You might want to check (and possibly remove) the file ${ezjail_image}. The image size provided was ${ezjail_imagesize}." + fi # And attach device ezjail_imagedevice=`mdconfig -a -t vnode -f ${ezjail_image}` -- cgit v1.2.3