#!/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.
#
#################################################################################
#
# Home directories
    # Test        : HOME-5612
    # Description : check for expired SSL certificates
    #if [ -z "${OPENSSLBINARY}" ]; then PREQS_MET="YES" else PREQS_MET="NO"; fi
    #Register --test-no HOME-5612 --preqs-met ${PREQS_MET} --weight L --network NO --description "Check expire date SSL certificates"
    #if [ ${SKIPTEST} -eq 0 ]; then

#
#################################################################################
#
    InsertSection "Home directories"
#
#################################################################################
#

#YYY check home directories

#Display all (unique) home directories
#FIND=`awk -F: '{ if ( $1 !~ "#" ) print $6 }' /etc/passwd | sort | uniq`

#
#################################################################################
#
    # Test        : HOME-9310
    # Description : Check for suspicious shell history files
    Register --test-no HOME-9310 --weight L --network NO --description "Checking for suspicious shell history files"
    if [ ${SKIPTEST} -eq 0 ]; then
	if [ ! "${HOMEDIRS}" = "" ]; then
	    if [ ${OS} = "SunOS" ]; then
	        # Solaris doesn't support -maxdepth
	        FIND=`find ${HOMEDIRS} -name ".*history" -not -type f -print`
	      else
	        FIND=`find ${HOMEDIRS} -maxdepth 1 -name ".*history" -not -type f -print`
	    fi
	    if [ "${FIND}" = "" ]; then
		Display --indent 2 --text "- Checking shell history files... " --result OK --color GREEN
	        logtext "Result: Ok, history files are type 'file'."
	      else
		Display --indent 2 --text "- Checking shell history files... " --result WARNING --color RED
	        logtext "Warning: the following files seem to be of the wrong file type:"
	        logtext "Output: ${FIND}"
		report "warning[]=Found incorrect file type while checking shell history files"
	        fi
	    logtext "Remarks: ${HOME_HISTORY_LOG_TEXT}"
          else
	    Display --indent 2 --text "- Checking shell history files... " --result SKIPPED --color WHITE
	    logtext "Homedirs is empty, test will be skipped"
	fi
    fi

#
#################################################################################
#

#counttests
#
#echo -n "      - Checking PATH variable vulnerabilities... "
#
#FIND=`find ${HOMEDIRS} -name * | grep -r 'PATH=' | egrep '=.:|:.:|:.;' | grep -v 'CDPATH'`
#if [ "${FIND}" = "" ]
#  then
#    ShowResult OK
#    logtext "Result: Ok, no special things found in the PATH variable"
#  else
#    echo "[ ${WARNING}WARNING${NORMAL} ]"
#    logtext "Warning: Probably found \".\" in the PATH. Details: ${FIND}"
#fi
#
#logtextbreak

# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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