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

if [ "${OS}" = "FreeBSD" ]; then
    counttests
    logtext "Test: Checking console TTYs..."
    FIND=`cat /etc/ttys | egrep '^console' | grep -v 'insecure'`
    if [ "${FIND}" = "" ]; then
	Display --indent 2 --text "- Checking console TTYs... " --result OK --color GREEN
	logtext "Result: console is secured against single user mode without password."
      else
	Display --indent 2 --text "- Checking console TTYs... " --result WARNING --color RED
        logtext "Warning: Found insecure console in /etc/ttys. Single user mode login without password allowed!"
	logtext "Suggestion: change the console line from 'secure' to 'insecure'."
        logtext "Output /etc/ttys:"	
        logtext "${FIND}"
	report "warning[]=Found unprotected console in /etc/ttys"
    fi
    logtextbreak
fi

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

# Check which shells are available according /etc/shells

    logtext "Test: Searching for /etc/shells..."
    if [ -f /etc/shells ]; then
        counttests
        logtext "Result: Found /etc/shells file"
        logtext "Test: Reading available shells from /etc/shells"
        SSHELLS=`cat /etc/shells | grep "^/"`
        CSSHELLS=0
        CSSHELLS_PRESENT=0
        Display --indent 2 --text "- Checking shells from /etc/shells..."
        for I in ${SSHELLS}; do
            CSSHELLS=`expr ${CSSHELLS} + 1`
            report "available_shell[]=${I}"
            if [ -f ${I} ]; then
                logtext "Found installed shell: ${I}"
                CSSHELLS_PRESENT=`expr ${CSSHELLS_PRESENT} + 1`
              else
                logtext "Shell ${I} not installed. Probably a dummy or non existing shell."
            fi
         done
        Display --indent 4 --text "Result: found ${CSSHELLS_PRESENT} shells installed (valid shells: ${CSSHELLS})."
        logtextbreak
      else
        Display --indent 4 --text "Result: test skipped, could not find /etc/shells"
        logtextbreak
    fi

wait_for_keypress


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