#!/bin/sh

#################################################################################
#
#   Lynis
# ------------------
#
# Copyright 2007-2008, Michael Boelen (michael@rootkit.nl), The Netherlands
# Web site: http://www.rootkit.nl
#
# Lynis comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
# welcome to redistribute it under the terms of the GNU General Public License.
# See LICENSE file for usage of this software.
#
#################################################################################
#
# Virtualization
#
#################################################################################
#
    InsertSection "Virtualization"

    # Test        : VIRT-1902
    # Description : Query running Solaris zones
    if [ -x /usr/sbin/zoneadm ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
    Register --test-no VIRT-1902 --os SunOS --weight L --network NO --description "Query running Solaris zones"
    if [ ${SKIPTEST} -eq 0 ]; then
	logtext "Test: query zoneadm to list all running zones"
        FIND=`/usr/sbin/zoneadm list -p | awk -F: '{ if ($2!="global") print $0 }'`
	if [ ! "${FIND}" = "" ]; then
	    N=0
	    for I in ${FIND}; do
	        N=`expr ${N} + 1`
		ZONEID=`echo ${I} | cut -d ':' -f1`
		ZONENAME=`echo ${I} | cut -d ':' -f2`
		logtext "Result: found zone ${ZONENAME} (running)"
		report "solaris_running_zone[]=${ZONENAME} [id:${ZONEID}]"
	    done
	    logtext "Result: total of ${N} running zones"
	  else
	    logtext "Result: no running zones found"
	fi
    fi
#
#################################################################################
#
    # Test        : VIRT-1906
    # Description : Query running Solaris zones
    #if [ -x /usr/bin/xm ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
    #Register --test-no VIRT-1906 --weight L --network NO --description "Query Xen guests"
    #if [ ${SKIPTEST} -eq 0 ]; then
	# Show Xen guests
	#FIND=`xm list | awk '$1 != "Name|Domain-0" {print $1","$2}'`
	#for I in ${FIND}; do
	    #XENGUESTNAME=`echo ${I} | cut -d ':' -f1`
	    #XENGUESTID=`echo ${I} | cut -d ':' -f2`
	    #logtext "Result: found Xen guest ${XENGUESTNAME} (ID: ${XENGUESTID})"
	#done
    #fi
#
#################################################################################
#

wait_for_keypress

#
#================================================================================
# Lynis - Copyright 2007-2008, Michael Boelen - www.rootkit.nl - The Netherlands
