[PC-BSD Commits] r15724 - pcbsd/current/src-qt4/warden/scripts/backend
svn at pcbsd.org
svn at pcbsd.org
Tue Mar 6 13:59:50 PST 2012
Author: kris
Date: 2012-03-06 21:59:49 +0000 (Tue, 06 Mar 2012)
New Revision: 15724
Modified:
pcbsd/current/src-qt4/warden/scripts/backend/checkstatus.sh
pcbsd/current/src-qt4/warden/scripts/backend/chrootjail.sh
pcbsd/current/src-qt4/warden/scripts/backend/createjail.sh
pcbsd/current/src-qt4/warden/scripts/backend/functions.sh
pcbsd/current/src-qt4/warden/scripts/backend/listjails.sh
pcbsd/current/src-qt4/warden/scripts/backend/startjail.sh
pcbsd/current/src-qt4/warden/scripts/backend/stopjail.sh
Log:
Welcome IPv6 support to Warden CLI!
Modified: pcbsd/current/src-qt4/warden/scripts/backend/checkstatus.sh
===================================================================
--- pcbsd/current/src-qt4/warden/scripts/backend/checkstatus.sh 2012-03-06 20:31:04 UTC (rev 15723)
+++ pcbsd/current/src-qt4/warden/scripts/backend/checkstatus.sh 2012-03-06 21:59:49 UTC (rev 15724)
@@ -39,7 +39,7 @@
done
# Check if the jail is active
-jls | grep ${IP} >/dev/null 2>/dev/null
+jls | grep ${JDIR}/${IP} >/dev/null 2>/dev/null
if [ "$?" = "0" -o "$hasmount" = "1" ]; then
exit 0
else
Modified: pcbsd/current/src-qt4/warden/scripts/backend/chrootjail.sh
===================================================================
--- pcbsd/current/src-qt4/warden/scripts/backend/chrootjail.sh 2012-03-06 20:31:04 UTC (rev 15723)
+++ pcbsd/current/src-qt4/warden/scripts/backend/chrootjail.sh 2012-03-06 21:59:49 UTC (rev 15724)
@@ -30,7 +30,7 @@
fi
# Make sure the jail is running
-jls | grep ${IP} >/dev/null 2>/dev/null
+jls | grep ${JDIR}/${IP} >/dev/null 2>/dev/null
if [ "$?" != "0" ]
then
echo "ERROR: Jail is not running!"
@@ -38,7 +38,7 @@
fi
# Get the JailID for this jail
-JID="`jls | grep ${IP} | tr -s " " ":" | cut -d ":" -f 2`"
+JID="`jls | grep ${JDIR}/${IP} | tr -s " " | cut -d " " -f 2`"
# If on an xjail, make display available
if [ -e "${JDIR}/${IP}/etc/.wardenxjail" ] ; then
Modified: pcbsd/current/src-qt4/warden/scripts/backend/createjail.sh
===================================================================
--- pcbsd/current/src-qt4/warden/scripts/backend/createjail.sh 2012-03-06 20:31:04 UTC (rev 15723)
+++ pcbsd/current/src-qt4/warden/scripts/backend/createjail.sh 2012-03-06 21:59:49 UTC (rev 15724)
@@ -91,6 +91,12 @@
# Copy resolv.conf
cp /etc/resolv.conf "${JDIR}/${IP}/etc/resolv.conf"
+# Check if ipv6
+isV6 "${IP}"
+if [ $? -eq 0 ] ; then
+ sed -i '' "s|#ListenAddress ::|ListenAddress ${IP}|g" ${JDIR}/${IP}/etc/ssh/sshd_config
+fi
+
if [ "$STARTUP" = "YES" ]
then
touch "${JDIR}/${IP}/etc/.wardenautostart"
Modified: pcbsd/current/src-qt4/warden/scripts/backend/functions.sh
===================================================================
--- pcbsd/current/src-qt4/warden/scripts/backend/functions.sh 2012-03-06 20:31:04 UTC (rev 15723)
+++ pcbsd/current/src-qt4/warden/scripts/backend/functions.sh 2012-03-06 21:59:49 UTC (rev 15724)
@@ -47,6 +47,11 @@
check_ip()
{
ip="$1"
+
+ # If this is a V6 address, skip validation for now
+ isV6 "${ip}"
+ if [ $? -eq 0 ] ; then return ; fi
+
# Check if we can cut this IP into the right segments
SEG="`echo $ip | cut -d '.' -f 1 2>/dev/null`"
echo $SEG | grep -E "^[0-9]+$" >/dev/null 2>/dev/null
@@ -219,3 +224,8 @@
# Flag this type
touch ${1}/etc/.wardenxjail
}
+
+isV6() {
+ echo ${1} | grep -q ":"
+ return $?
+}
Modified: pcbsd/current/src-qt4/warden/scripts/backend/listjails.sh
===================================================================
--- pcbsd/current/src-qt4/warden/scripts/backend/listjails.sh 2012-03-06 20:31:04 UTC (rev 15723)
+++ pcbsd/current/src-qt4/warden/scripts/backend/listjails.sh 2012-03-06 21:59:49 UTC (rev 15724)
@@ -17,8 +17,8 @@
# Prints a listing of the available jails
-echo "IP HOST AUTOSTART STATUS TYPE
------------------------------------------------------------------------"
+echo "IP HOST AUTOSTART STATUS TYPE
+---------------------------------------------------------------------------------"
cd ${JDIR}
@@ -55,12 +55,13 @@
fi
# Pad the variables a bit
+ IP=`echo "${i} " | cut -c 1-25`
AUTO=`echo "${AUTO} " | cut -c 1-15`
STATUS=`echo "${STATUS} " | cut -c 1-10`
HOST=`echo "${HOST} " | cut -c 1-15`
TYPE=`echo "${TYPE} " | cut -c 1-10`
- echo -e "${i} ${HOST} ${AUTO} ${STATUS} ${TYPE}"
+ echo -e "${IP} ${HOST} ${AUTO} ${STATUS} ${TYPE}"
done
Modified: pcbsd/current/src-qt4/warden/scripts/backend/startjail.sh
===================================================================
--- pcbsd/current/src-qt4/warden/scripts/backend/startjail.sh 2012-03-06 20:31:04 UTC (rev 15723)
+++ pcbsd/current/src-qt4/warden/scripts/backend/startjail.sh 2012-03-06 21:59:49 UTC (rev 15724)
@@ -30,7 +30,7 @@
fi
# Make sure the jail is NOT already running
-jls | grep ${IP} >/dev/null 2>/dev/null
+jls | grep ${JDIR}/${IP} >/dev/null 2>/dev/null
if [ "$?" = "0" ]
then
echo "ERROR: Jail appears to be running already!"
@@ -40,16 +40,22 @@
HOST="`cat ${JDIR}/${IP}/etc/.wardenhost`"
-ifconfig $NIC inet alias ${IP}/32
mount -t devfs devfs "${JDIR}/${IP}/dev"
mount -t procfs proc "${JDIR}/${IP}/proc"
if [ -e "${JDIR}/${IP}/etc/.wardenxjail" ] ; then mountjailxfs ${IP} ; fi
-echo "jail -c name=${HOST} path=${JDIR}/${IP} host.hostname=${HOST} ip4.addr=${IP} persist"
-jail -c name=${HOST} path=${JDIR}/${IP} host.hostname=${HOST} ip4.addr=${IP} persist
+
+isV6 "${IP}"
+if [ $? -eq 0 ] ; then
+ ifconfig $NIC inet6 alias ${IP}
+ jail -c name=${HOST} path=${JDIR}/${IP} host.hostname=${HOST} ip6.addr=${IP} persist
+else
+ ifconfig $NIC inet alias ${IP}/32
+ jail -c name=${HOST} path=${JDIR}/${IP} host.hostname=${HOST} ip4.addr=${IP} persist
+fi
+
jexec ${HOST} /bin/sh /etc/rc 2>&1
-#jail ${JDIR}/${IP} ${HOST} ${IP} /bin/sh /etc/rc 2>&1
# Get the JailID for this new jail
-JID="`jls | grep ${IP} | tr -s " " ":" | cut -d ":" -f 2`"
+JID="`jls | grep ${JDIR}/${IP} | tr -s " " | cut -d " " -f 2`"
echo "$JID" >"${JDIR}/${IP}/var/run/warden.jid"
Modified: pcbsd/current/src-qt4/warden/scripts/backend/stopjail.sh
===================================================================
--- pcbsd/current/src-qt4/warden/scripts/backend/stopjail.sh 2012-03-06 20:31:04 UTC (rev 15723)
+++ pcbsd/current/src-qt4/warden/scripts/backend/stopjail.sh 2012-03-06 21:59:49 UTC (rev 15724)
@@ -37,7 +37,7 @@
HOST="`cat ${JDIR}/${IP}/etc/.wardenhost`"
# Make sure the jail is running
-jls | grep ${IP} >/dev/null 2>/dev/null
+jls | grep ${JDIR}/${IP} >/dev/null 2>/dev/null
if [ "$?" != "0" ]
then
echo "ERROR: Jail is not running!"
@@ -50,7 +50,7 @@
echo -e "Stopping the jail...\c"
# Get the JailID for this jail
-JID="`jls | grep ${IP} | tr -s " " ":" | cut -d ":" -f 2`"
+JID="`jls | grep ${JDIR}/${IP} | tr -s " " | cut -d " " -f 2`"
echo -e ".\c"
@@ -61,7 +61,11 @@
ifconfig $NIC | grep ${IP} >/dev/null 2>/dev/null
if [ "$?" = "0" ]
then
- ifconfig $NIC inet -alias ${IP}
+ if [ $? -eq 0 ] ; then
+ ifconfig $NIC inet6 ${IP} delete
+ else
+ ifconfig $NIC inet -alias ${IP}
+ fi
echo -e ".\c"
fi
More information about the Commits
mailing list