#!/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.
#
#################################################################################
#
# 
#
#################################################################################
#


#
#################################################################################
#
# Read profile/template
#
#################################################################################
#

#YYY Enable check when profile files are complete
# Check if default profile is used
if [ "${PROFILE}" = "defaultXXX.prf" ]; then
    echo ""
    echo "      ==============================================================================="
    echo "        ${WARNING}Warning${NORMAL}: ${WHITE}Default profile is used.${NORMAL}"
    echo "          Default profile contains only a small amount of options and settings."
    echo "          Consult the documentation to create a custom profile!"
    echo ""
    echo "      [ ${WHITE}Press [ENTER] to continue with the default profile or [CTRL] + C to stop${NORMAL} ]"
    echo "      ==============================================================================="
    wait_for_keypress
fi

echo "      - Checking profile file (${PROFILE})... "
echo -n "        Options: "

logtext "Reading profile/configuration ${PROFILE}"

FIND=`cat ${PROFILE} | grep '^config:' | sed 's/ /!space!/g'`
for I in ${FIND}
  do
    OPTION=`echo ${I} | cut -d ':' -f2`
    VALUE=`echo ${I} | cut -d ':' -f3`    

#YYY do something useful with configuration options
#    logtext "Found configuration option ${OPTION} (with value ${VALUE})"

    echo -n "${OPTION} "

    case ${OPTION} in

	debian_skip_security_repository)
	OPTION_DEBIAN_SKIP_SECURITY_REPOSITORY="${VALUE}"
	;;

	freebsd_skip_portaudit)
	logtext "Option set: Skip FreeBSD portaudit"
	OPTION_FREEBSD_SKIP_PORTAUDIT="${VALUE}"
	;;
	
	profile_name)
	# YYY dummy 
	;;
	
	# Catch all bad options and bail out
	*)
	logtext "Unknown option ${OPTION} (with value: ${VALUE})"
	echo "Fatal error: found errors in profile"
	echo "Unknown option ${OPTION} found (with value: ${VALUE})"
	RemovePIDFile    
	exit 1
	;;

    esac
  done
echo ""

logtextbreak


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