diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2006-04-03 18:19:54 +0000 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2006-04-03 18:19:54 +0000 |
| commit | 0970be2e2a798ed5140227394b2c53c51af98393 (patch) | |
| tree | 7a0821fa89c653b9b5c8d1928e8fdd7d20f92c42 | |
| parent | d1b84c6621800ba4959564a7d800e885634583c9 (diff) | |
Much more error handling. Not tested yet.
| -rwxr-xr-x | ezjail-admin | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/ezjail-admin b/ezjail-admin index f82f9ea..04c6266 100755 --- a/ezjail-admin +++ b/ezjail-admin | |||
| @@ -32,9 +32,10 @@ exerr () { echo -e "$*"; exit 1; } | |||
| 32 | detach_images () { | 32 | detach_images () { |
| 33 | # unmount and detach memory disc | 33 | # unmount and detach memory disc |
| 34 | if [ "${newjail_img_device}" ]; then | 34 | if [ "${newjail_img_device}" ]; then |
| 35 | umount ${newjail_root} | 35 | umount ${newjail_root} > /dev/null |
| 36 | [ "${newjail_image}" = "crypto" ] && gbde detach /dev/${newjail_img_device} | 36 | [ "${newjail_image}" = "crypto" ] && gbde detach /dev/${newjail_img_device} > /dev/null |
| 37 | mdconfig -d -u ${newjail_img_device} | 37 | mdconfig -d -u ${newjail_img_device} > /dev/null |
| 38 | [ "$1" == "success" ] || rm -f ${newjail_img} | ||
| 38 | fi | 39 | fi |
| 39 | } | 40 | } |
| 40 | 41 | ||
| @@ -142,26 +143,25 @@ create) | |||
| 142 | 143 | ||
| 143 | # And attach device | 144 | # And attach device |
| 144 | newjail_img_device=`mdconfig -a -t vnode -f ${newjail_img}` | 145 | newjail_img_device=`mdconfig -a -t vnode -f ${newjail_img}` |
| 146 | [ $? = 0 ] || detach_images || exerr "Error: Could not attach image device. (Command failed was 'mdconfig -a -t vnode -f ${newjail_img}')" | ||
| 145 | 147 | ||
| 146 | if [ "${newjail_image}" = "crypto" ]; then | 148 | if [ "${newjail_image}" = "crypto" ]; then |
| 147 | # Initialise crypto image | 149 | # Initialise crypto image |
| 148 | # XXX TODO: catch error and detach memory disc | ||
| 149 | echo "Initialising crypto device. Enter a new passphrase twice..." | 150 | echo "Initialising crypto device. Enter a new passphrase twice..." |
| 150 | gbde init /dev/${newjail_img_device} -L ${newjail_lock} | 151 | gbde init /dev/${newjail_img_device} -L ${newjail_lock} || detach_images || exerr "Error: Could not initialise crypto image." |
| 151 | 152 | ||
| 152 | # XXX TODO: catch error and detach memory disc | ||
| 153 | echo "Attaching crypto device. Enter the passphrase..." | 153 | echo "Attaching crypto device. Enter the passphrase..." |
| 154 | gbde attach /dev/${newjail_img_device} -l ${newjail_lock} | 154 | gbde attach /dev/${newjail_img_device} -l ${newjail_lock} || detach_images || exerr "Error: Could not attach crypto image." |
| 155 | newjail_device=${newjail_img_device}.bde | 155 | newjail_device=${newjail_img_device}.bde |
| 156 | else | 156 | else |
| 157 | newjail_device=${newjail_img_device} | 157 | newjail_device=${newjail_img_device} |
| 158 | fi | 158 | fi |
| 159 | 159 | ||
| 160 | # Format memory image | 160 | # Format memory image |
| 161 | newfs /dev/${newjail_device} | 161 | newfs /dev/${newjail_device} || detach_images || exerr "Error: Could not newfs ${newjail_img_device}." |
| 162 | # Create mount point and mount | 162 | # Create mount point and mount |
| 163 | mkdir -p ${newjail_root} | 163 | mkdir -p ${newjail_root} || detach_images || exerr "Error: Could not create jail root mount point ${newjail_root}." |
| 164 | mount /dev/${newjail_device} ${newjail_root} | 164 | mount /dev/${newjail_device} ${newjail_root} || detach_images || exerr "Error: Could not mount ${newjail_device} to ${newjail_root}." |
| 165 | else | 165 | else |
| 166 | [ -e ${newjail_root} -a ! -d ${newjail_root} ] && exerr "Error: Could not create mount point for your jail image. A file exists at its location. (For existing image jails, call this tool without the .img suffix when specifying jail root.)" | 166 | [ -e ${newjail_root} -a ! -d ${newjail_root} ] && exerr "Error: Could not create mount point for your jail image. A file exists at its location. (For existing image jails, call this tool without the .img suffix when specifying jail root.)" |
| 167 | [ -d ${newjail_root} ] || mkdir -p ${newjail_root} | 167 | [ -d ${newjail_root} ] || mkdir -p ${newjail_root} |
| @@ -219,7 +219,7 @@ create) | |||
| 219 | fi | 219 | fi |
| 220 | 220 | ||
| 221 | # Detach (crypto and) memory discs | 221 | # Detach (crypto and) memory discs |
| 222 | detach_images | 222 | detach_images success |
| 223 | 223 | ||
| 224 | # | 224 | # |
| 225 | # For user convenience some scenarios commonly causing headaches are checked | 225 | # For user convenience some scenarios commonly causing headaches are checked |
