summaryrefslogtreecommitdiff
path: root/ezjail-admin
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2008-03-14 00:17:22 +0000
committererdgeist <erdgeist@erdgeist.org>2008-03-14 00:17:22 +0000
commit1e2d49ec51993e221b3292c39f63dc8c3c677f38 (patch)
tree689ac802f43fde60a3e418f032ebb53f74a8e6bf /ezjail-admin
parentd8ead98071ed2526d03cd3b84d49edb0b44d55bd (diff)
abstract making absolute paths. use pax instead of tar to extract archives. Also do not report an error, if ezjail.conf is missing.
Diffstat (limited to 'ezjail-admin')
-rwxr-xr-xezjail-admin26
1 files changed, 19 insertions, 7 deletions
diff --git a/ezjail-admin b/ezjail-admin
index 780a1bf..297d74d 100755
--- a/ezjail-admin
+++ b/ezjail-admin
@@ -244,6 +244,12 @@ ezjail_queryftpserver () {
244 return ${_ret} 244 return ${_ret}
245} 245}
246 246
247# Make a path absolute, if it isn't already
248ezjail_makeabsolute ( ) {
249 [ $# -eq 1 ] && path=`pwd -P` || path=$2
250 eval [ \"\${$1%%[!/]*}\" -o "\${$1}" = "-" ] || eval export ${1}="${path}/\${$1}"
251}
252
247parse_geli_attach_args () { 253parse_geli_attach_args () {
248 # create geli(8) attach arguments from geli(8) init arguments: 254 # create geli(8) attach arguments from geli(8) init arguments:
249 # -P becomes -p if present, -K newkeyfile becomes -k newkeyfile if present, 255 # -P becomes -p if present, -K newkeyfile becomes -k newkeyfile if present,
@@ -352,7 +358,7 @@ create)
352 358
353 # if jail root specified on command line is not absolute, make it absolute 359 # if jail root specified on command line is not absolute, make it absolute
354 # inside our jail directory 360 # inside our jail directory
355 [ "${ezjail_rootdir%%[!/]*}" ] || ezjail_rootdir="${ezjail_jaildir}/${ezjail_rootdir}" 361 ezjail_makeabsolute ezjail_rootdir ${ezjail_jaildir}
356 362
357 # if a directory at the specified jail root already exists, refuse to 363 # if a directory at the specified jail root already exists, refuse to
358 # install. Empty root dirs are considered okay, sometimes they are 364 # install. Empty root dirs are considered okay, sometimes they are
@@ -454,7 +460,10 @@ create)
454 fi 460 fi
455 461
456 if [ "${ezjail_fromarchive}" ]; then 462 if [ "${ezjail_fromarchive}" ]; then
457 mkdir -p "${ezjail_rootdir}" && tar xfp "${ezjail_fromarchive}" -C "${ezjail_rootdir}" --strip-components 1 ezjail 463 unset ezjail_archive_opt
464 ezjail_makeabsolute ezjail_fromarchive
465 [ "${ezjail_fromarchive}" = "-" ] && unset ezjail_archive_opt || ezjail_archive_opt="-f ${ezjail_fromarchive}"
466 mkdir -p "${ezjail_rootdir}" && cd "${ezjail_rootdir}" && pax -rz -pe "${ezjail_archive_opt}" -s:^ezjail/:: ezjail/*
458 [ $? -eq 0 ] || detach_images || exerr "Error: Could not extract archive from ${ezjail_fromarchive}." 467 [ $? -eq 0 ] || detach_images || exerr "Error: Could not extract archive from ${ezjail_fromarchive}."
459 elif [ -z "${ezjail_exists}" ]; then 468 elif [ -z "${ezjail_exists}" ]; then
460 # now take a copy of our template jail 469 # now take a copy of our template jail
@@ -670,7 +679,7 @@ install)
670 ezjail_ftphost=${ezjail_ftphost:-"ftp.freebsd.org"} 679 ezjail_ftphost=${ezjail_ftphost:-"ftp.freebsd.org"}
671 ezjail_ftphost=${ezjail_ftphost#ftp://} 680 ezjail_ftphost=${ezjail_ftphost#ftp://}
672 ezjail_dir=${ezjail_ftphost#file://} 681 ezjail_dir=${ezjail_ftphost#file://}
673 [ "${ezjail_dir%%[!/]*}" ] || ezjail_reldir=${PWD} 682 [ "${ezjail_dir%%[!/]*}" ] || ezjail_reldir=`pdw -P`
674 683
675 [ "`sysctl -n kern.securelevel`" -gt 0 ] && exerr "You're running in a secure level higher than 0. ezjail will not run correctly." 684 [ "`sysctl -n kern.securelevel`" -gt 0 ] && exerr "You're running in a secure level higher than 0. ezjail will not run correctly."
676 685
@@ -781,7 +790,7 @@ console)
781######################## ezjail-admin ARCHIVE ######################## 790######################## ezjail-admin ARCHIVE ########################
782archive) 791archive)
783 # Clean variables, prevent polution 792 # Clean variables, prevent polution
784 unset ezjail_archive ezjail_archive_tag ezjail_force ezjail_archivealljails 793 unset ezjail_archive ezjail_archive_tag ezjail_force ezjail_archivealljails ezjail_addfiles
785 794
786 shift; while getopts :Afa:d: arg; do case ${arg} in 795 shift; while getopts :Afa:d: arg; do case ${arg} in
787 f) ezjail_force="YES";; 796 f) ezjail_force="YES";;
@@ -826,7 +835,7 @@ archive)
826 [ "${ezjail_archive}" ] || ezjail_archive="${ezjail_archive_tag}.tar.gz" 835 [ "${ezjail_archive}" ] || ezjail_archive="${ezjail_archive_tag}.tar.gz"
827 836
828 # if archive location is not absolute, prepend archive directory 837 # if archive location is not absolute, prepend archive directory
829 [ "${ezjail_archive%%[!/]*}" -o ${ezjail_archive} = "-" ] || ezjail_archive="${ezjail_archivedir}/${ezjail_archive}" 838 ezjail_makeabsolute ezjail_archive ${ezjail_archivedir}
830 839
831 # It's a tar archive, after all 840 # It's a tar archive, after all
832 case ${ezjail_archive} in 841 case ${ezjail_archive} in
@@ -837,6 +846,9 @@ archive)
837 # For stdout do specify nothing 846 # For stdout do specify nothing
838 [ "${ezjail_archive}" = "-" ] && unset ezjail_archive_opt || ezjail_archive_opt="-f ${ezjail_archive}" 847 [ "${ezjail_archive}" = "-" ] && unset ezjail_archive_opt || ezjail_archive_opt="-f ${ezjail_archive}"
839 848
849 [ -f "${ezjail_etc}/ezjail.conf" ] && ezjail_addfiles="${ezjail_etc}/ezjail.conf"
850 [ -f "/etc/fstab.${ezjail_safename}" ] && ezjail_addfiles="${ezjail_addfiles} /etc/fstab.${ezjail_safename}"
851
840 cd "${ezjail_rootdir}" || exerr "Error: can't cd to ${ezjail_root}." 852 cd "${ezjail_rootdir}" || exerr "Error: can't cd to ${ezjail_root}."
841 pax -wXtz -x ustar ${ezjail_archive_opt} \ 853 pax -wXtz -x ustar ${ezjail_archive_opt} \
842 -s:"^[^\\.].*/ezjail\\.conf\$":ezjail.conf: \ 854 -s:"^[^\\.].*/ezjail\\.conf\$":ezjail.conf: \
@@ -844,7 +856,7 @@ archive)
844 -s:"^[^\\.].*/${ezjail_safename}.norun\$":prop.ezjail-${ezjail_archive_tag}.norun: \ 856 -s:"^[^\\.].*/${ezjail_safename}.norun\$":prop.ezjail-${ezjail_archive_tag}.norun: \
845 -s:"etc/fstab.${ezjail_safename}\$":fstab.ezjail: \ 857 -s:"etc/fstab.${ezjail_safename}\$":fstab.ezjail: \
846 -s:"^\\.":ezjail: \ 858 -s:"^\\.":ezjail: \
847 "/etc/fstab.${ezjail_safename}" "${ezjail_config}" "${ezjail_etc}/ezjail.conf" . 2> /dev/null 859 "${ezjail_config}" ${ezjail_addfiles} .
848 860
849 # An error on a jail not running is bad 861 # An error on a jail not running is bad
850 [ $? -eq 0 -o "${ezjail_force}" ] || exerr "Error: Archiving jail failed. You might want to check ${ezjail_archive}." 862 [ $? -eq 0 -o "${ezjail_force}" ] || exerr "Error: Archiving jail failed. You might want to check ${ezjail_archive}."
@@ -854,7 +866,7 @@ archive)
854 866
855 # To the next jail on command line 867 # To the next jail on command line
856 shift 1 868 shift 1
857 unset ezjail_archive ezjail_archive_opt 869 unset ezjail_archive ezjail_archive_opt ezjail_addfiles
858 done 870 done
859 ;; 871 ;;
860####################### ezjail-admin RESTORE ######################## 872####################### ezjail-admin RESTORE ########################