summaryrefslogtreecommitdiff
path: root/ezjail-admin
diff options
context:
space:
mode:
Diffstat (limited to 'ezjail-admin')
-rwxr-xr-xezjail-admin22
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; }
32detach_images () { 32detach_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