From 312c276483c2277b93ddc79ce51b4b017521e5f1 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Fri, 23 Mar 2007 16:08:43 +0000 Subject: Stale device link detection completed and tested. More testing required. --- ezjail-admin | 7 ++++++- ezjail.sh | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ezjail-admin b/ezjail-admin index aa7b16d..a4e50e1 100755 --- a/ezjail-admin +++ b/ezjail-admin @@ -120,7 +120,12 @@ fetchjailinfo () { if [ -n "${ezjail_image}" -a -L "${ezjail_rootdir}.device" ]; then # Fetch destination of soft link ezjail_device=`stat -f "%Y" ${ezjail_rootdir}.device` - [ -e "${ezjail_device}" ] && ezjail_attached="YES" + + mount -p -v | grep -q -E "^${ezjail_rootdir}.device.${ezjail_rootdir}" && ezjail_attached="YES" + mount -p -v | grep -q -E "^${ezjail_device}.${ezjail_rootdir}" && ezjail_attached="YES" + + # Stale device link detected. Remove and clean. + [ -z "${ezjail_attached}" ] && unset ezjail_device && rm -f ${ezjail_rootdir}.device fi [ -f /var/run/jail_${ezjail_safename}.id ] && ezjail_id=`cat /var/run/jail_${ezjail_safename}.id` || return diff --git a/ezjail.sh b/ezjail.sh index 9f181f2..5394a63 100755 --- a/ezjail.sh +++ b/ezjail.sh @@ -102,8 +102,8 @@ attach_detach_pre () # Fetch destination of soft link ezjail_device=`stat -f "%Y" ${ezjail_rootdir}.device` - mount -p -v | grep -E "^${ezjail_rootdir}.device.${ezjail_rootdir}" && echo "Jail image file ${ezjail} already attached as ${ezjail_device}. 'ezjail-admin config -i detach' it first." && return 1 - mount -p -v | grep -E "^${ezjail_device}.${ezjail_rootdir}" && echo "Jail image file ${ezjail} already attached as ${ezjail_device}. 'ezjail-admin config -i detach' it first." && return 1 + mount -p -v | grep -E "^${ezjail_rootdir}.device.${ezjail_rootdir}" && echo "Warning: Skipping jail. Jail image file ${ezjail} already attached as ${ezjail_device}. 'ezjail-admin config -i detach' it first." && return 1 + mount -p -v | grep -E "^${ezjail_device}.${ezjail_rootdir}" && echo "Warning: Skipping jail. Jail image file ${ezjail} already attached as ${ezjail_device}. 'ezjail-admin config -i detach' it first." && return 1 # Remove stale device link rm -f ${ezjail_rootdir}.device -- cgit v1.2.3