diff options
Diffstat (limited to 'ezjail-admin')
-rwxr-xr-x | ezjail-admin | 70 |
1 files changed, 46 insertions, 24 deletions
diff --git a/ezjail-admin b/ezjail-admin index 0eec9e7..d0a79ec 100755 --- a/ezjail-admin +++ b/ezjail-admin | |||
@@ -48,6 +48,34 @@ ezjail_usage_list="Usage: ${ezjail_admin} list" | |||
48 | # define our bail out shortcut | 48 | # define our bail out shortcut |
49 | exerr () { echo -e "$*" >&2 ; exit 1; } | 49 | exerr () { echo -e "$*" >&2 ; exit 1; } |
50 | 50 | ||
51 | # generic attach routine for image jails | ||
52 | attach_images () { | ||
53 | # Create a memory disc from jail image | ||
54 | ezjail_imagedevice=`mdconfig -a -t vnode -f ${ezjail_image}` || exerr "Error: Could not attach memory disc." | ||
55 | |||
56 | # If this is a crypto jail, try to mount it, remind user, which jail | ||
57 | # this is. In this case, the device to mount is | ||
58 | case ${ezjail_imagetype} in | ||
59 | crypto|bde) | ||
60 | echo "Attaching bde device for image jail ${ezjail}..." | ||
61 | echo gbde attach /dev/${ezjail_imagedevice} ${ezjail_attachparams} | /bin/sh | ||
62 | [ $? -eq 0 ] || detach_images keep || exerr "Error: Attaching bde device failed." | ||
63 | # Device to mount is not md anymore | ||
64 | ezjail_device=${ezjail_imagedevice}.bde | ||
65 | ;; | ||
66 | eli) | ||
67 | echo "Attaching eli device for image jail ${ezjail}..." | ||
68 | echo geli attach ${ezjail_attachparams} /dev/${ezjail_imagedevice} | /bin/sh | ||
69 | [ $? -eq 0 ] || detach_images keep || exerr "Error: Attaching eli device failed." | ||
70 | # Device to mount is not md anymore | ||
71 | ezjail_device=${ezjail_imagedevice}.eli | ||
72 | ;; | ||
73 | simple) | ||
74 | ezjail_device=${ezjail_imagedevice} | ||
75 | ;; | ||
76 | esac | ||
77 | } | ||
78 | |||
51 | # define detach strategy for image jails | 79 | # define detach strategy for image jails |
52 | detach_images () { | 80 | detach_images () { |
53 | # unmount and detach memory disc | 81 | # unmount and detach memory disc |
@@ -735,30 +763,8 @@ config) | |||
735 | [ -n "${ezjail_attached}" ] && exerr "Error: Jail image file ${ezjail_image} already attached as ${ezjail_device}." | 763 | [ -n "${ezjail_attached}" ] && exerr "Error: Jail image file ${ezjail_image} already attached as ${ezjail_device}." |
736 | rm -f ${ezjail_rootdir}.device | 764 | rm -f ${ezjail_rootdir}.device |
737 | 765 | ||
738 | # Create a memory disc from jail image | 766 | # Attach images by type |
739 | ezjail_imagedevice=`mdconfig -a -t vnode -f ${ezjail_image}` || exerr "Error: Could not attach memory disc." | 767 | attach_images |
740 | |||
741 | # If this is a crypto jail, try to mount it, remind user, which jail | ||
742 | # this is. In this case, the device to mount is | ||
743 | case ${ezjail_imagetype} in | ||
744 | crypto|bde) | ||
745 | echo "Attaching bde device for image jail ${ezjail}..." | ||
746 | echo gbde attach /dev/${ezjail_imagedevice} ${ezjail_attachparams} | /bin/sh | ||
747 | [ $? -eq 0 ] || detach_images keep || exerr "Error: Attaching bde device failed." | ||
748 | # Device to mount is not md anymore | ||
749 | ezjail_device=${ezjail_imagedevice}.bde | ||
750 | ;; | ||
751 | eli) | ||
752 | echo "Attaching eli device for image jail ${ezjail}..." | ||
753 | echo geli attach ${ezjail_attachparams} /dev/${ezjail_imagedevice} | /bin/sh | ||
754 | [ $? -eq 0 ] || detach_images keep || exerr "Error: Attaching eli device failed." | ||
755 | # Device to mount is not md anymore | ||
756 | ezjail_device=${ezjail_imagedevice}.eli | ||
757 | ;; | ||
758 | simple) | ||
759 | ezjail_device=${ezjail_imagedevice} | ||
760 | ;; | ||
761 | esac | ||
762 | 768 | ||
763 | mount /dev/${ezjail_device} ${ezjail_rootdir} || detach_images keep || exerr "Error: Could not mount /dev/${ezjail_device} to ${ezjail_rootdir}." | 769 | mount /dev/${ezjail_device} ${ezjail_rootdir} || detach_images keep || exerr "Error: Could not mount /dev/${ezjail_device} to ${ezjail_rootdir}." |
764 | # relink image device | 770 | # relink image device |
@@ -784,6 +790,22 @@ config) | |||
784 | # Remove soft link (which acts as a lock) | 790 | # Remove soft link (which acts as a lock) |
785 | [ -e /dev/${ezjail_imagedevice} ] || rm -f ${ezjail_rootdir}.device | 791 | [ -e /dev/${ezjail_imagedevice} ] || rm -f ${ezjail_rootdir}.device |
786 | ;; | 792 | ;; |
793 | fsck) | ||
794 | # Check, if image already attached | ||
795 | [ -n "${ezjail_attached}" ] && exerr "Error: Jail image file ${ezjail_image} already attached as ${ezjail_device}." | ||
796 | rm -f ${ezjail_rootdir}.device | ||
797 | |||
798 | # Attach images by type | ||
799 | attach_images | ||
800 | |||
801 | fsck_ufs /dev/${ezjail_device} | ||
802 | |||
803 | # Detach images by type | ||
804 | detach_images keep | ||
805 | |||
806 | # Remove soft link (which acts as a lock) | ||
807 | [ -e /dev/${ezjail_imagedevice} ] || rm -f ${ezjail_rootdir}.device | ||
808 | ;; | ||
787 | esac | 809 | esac |
788 | ;; | 810 | ;; |
789 | 811 | ||