# -*- sh -*-
#
#     tiger - A UN*X security checking system
#     Copyright (C) 1993 Douglas Lee Schales, David K. Hess, David R. Safford
#
#     Please see the file `COPYING' for the complete copyright notice.
#
#     Developed by Advanced Research Corporation (R)
#
# Linux/1/config - 04/20/99
# Linux/2/config - 04/20/99
# Linux/1/config - 09/14/01  Added test for ifconfig
# Linux/2/config - 09/14/01  ditto
# Linux/2/config - 10/09/01  Changed reserved word GROUPS to GROUPSS
#
#-----------------------------------------------------------------------------
findcmd()
{
  CMD=$1

  SRCH=/bin:/usr/bin:/etc:/usr/etc:/usr/ucb:/sbin:/usr/sbin:/usr/bsd:/usr/lib
  TESTEXEC="-x"
  SAVEIFS=$IFS
  IFS=:
  set $SRCH
  IFS=$SAVEIFS
  for dir
  do
    [ $TESTEXEC $dir/$CMD ] && {
      echo $dir/$CMD
echo $dir/$CMD >> /tmp/zap
      return
    }
  done
}      
#
#   UUID=`/usr/bin/id | /usr/bin/sed -e 's/uid=\([0-9][0-9]*\).*$/\1/'`
[ "$UUID" = "" ] &&
  UNAME=`whoami`

export UNAME

[ "$UNAME" != "root" ] && {
  echo " " 1>&2
  echo "This script should be run from a super-user account." 1>&2
  echo " " 1>&2
  exit 1
}

CAT=`findcmd cat`
LS=`findcmd ls`
# -g to show group ownership
LSGROUP="-lg"
# -L to show file instead of symlink
LSLINK="-L"
RM=/bin/rm
AWK=`findcmd awk`
GREP=`findcmd grep`
EGREP=`findcmd egrep`
# Silent grep
SGREP="$EGREP -s"
SED=`findcmd sed`
SORT=`findcmd sort`
COMM=`findcmd comm`
TAIL=`findcmd tail`
TCPD=`findcmd tcpd`
MV=`findcmd mv`
TR=`findcmd tr`
JOIN=`findcmd join`
GROUPSS=`findcmd groups`
FILECMD=`findcmd file`
UNIQ=`findcmd uniq`
BASENAME=`findcmd basename`
CHMOD=`findcmd chmod`
CHOWN=`findcmd chown`
LN=`findcmd ln`
PASTE=`findcmd paste`
DIFF=`findcmd diff`
MAILER=`findcmd mail`
SENDMAILS=`findcmd sendmail`
IFCONFIG=`findcmd ifconfig`
# I'm not sure what a SMAIL config file looks like...
SENDMAILCF=""
export SENDMAILS SENDMAILCF
#
export CAT LS LSGROUP LSLINK RM AWK GREP EGREP SGREP SED
export SORT COMM TAIL MV TR JOIN GROUPSS FILECMD UNIQ BASENAME
export CHMOD CHOWN LN PASTE DIFF MAILER TCPD IFCONFIG
#
UNAME=`findcmd uname`
GETHOSTNAME=`findcmd hostname`
EXPR=`findcmd expr`
STRINGS=`findcmd strings`
FIND=`findcmd find`
FINDXDEV=-xdev
FMT=`findcmd fmt`
GETFS=`findcmd mount`
CC=`findcmd cc`
PS=`findcmd ps`
DATE=`findcmd date`
DATECMD="$DATE +%y%m%d"
TIMECMD="$DATE +%H:%M"
TESTLINK=-L
TESTEXEC=-x
#
#
export UNAME GETHOSTNAME EXPR STRINGS FIND FINDXDEV
export FMT GETFS CC PS DATE DATECMD TIMECMD TESTLINK TESTEXEC
#
# SunOS 4.x.x Bourne Shell has goofy 'wait' in regards to signals
#
WAIT=wait
#WAIT=simple_wait
#
# Using NIS (YP)?
YPCAT=`findcmd ypcat`
#
#YP=
#($PS -auxww | $GREP ypbind | $SGREP -v $GREP) && YP=Y
export YP
#
#
YPSERVER="NO"
#($PS -aux | $GREP ypserv | $SGREP -v $GREP) && YPSERVER="YES"
export WAIT YPCAT YPSERVER
#
MAILSPOOL=/var/spool/mail
#
if [ -d /usr/spool/cron/crontabs ]; then
  CRONSPOOL=/usr/spool/cron/crontabs
elif [ -d /var/spool/cron/crontabs ]; then
  CRONSPOOL=/var/spool/cron/crontabs 
elif [ -d /var/spool/cron ]; then
  CRONSPOOL=/var/spool/cron
else
CRONSPOOL=NULL
fi
#
ETCSHELLS=/etc/shells
#
export MAILSPOOL CRONSPOOL ETCSHELLS
#
FS_WDIRSYS="/tmp/ /var/tmp/ /var/spool/mail/"
export FS_WDIRSYS
#
SYSDEFAULTPATH="/bin:/usr/bin"
export SYSDEFAULTPATH
#
CDIR="$BASEDIR/systems"
eval `
  while read var file
  do
    if [ -f "$CONFIG_DIR/$file" ]; then
      loc="$CONFIG_DIR"
    elif [ -f "$CDIR/$OS/$REL/$REV/$ARCH/$file" ]; then
      loc="$CDIR/$OS/$REL/$REV/$ARCH"
    elif [ -f "$CDIR/$OS/$REL/$REV/$file" ]; then
      loc="$CDIR/$OS/$REL/$REV"
    elif [ -f "$CDIR/$OS/$REL/$file" ]; then
      loc="$CDIR/$OS/$REL"
    elif [ -f "$CDIR/$OS/$file" ]; then
      loc="$CDIR/$OS"
    else
      loc=""
    fi
    if [ "$loc" != "" ]; then
      echo $var="$loc/$file;"
    else
      echo "$var=;"
    fi
    echo "export $var;"
  done << EOL
GEN_PASSWD_SETS gen_passwd_sets
GEN_GROUP_SETS gen_group_sets
GEN_ALIAS_SETS gen_alias_sets
CHECK_CRON check_cron
GEN_BOOTPARAM_SETS gen_bootparam_sets
GEN_EXPORT_SETS gen_export_sets
GEN_SERVICES_SETS gen_services
GET_MOUNTS gen_mounts
SIGNATURE_FILE signatures
SERVICESFILE services
INETDFILE inetd
FILE_ACL file_access_list
SUID_LIST suid_list
REL_FILE_EXCP rel_file_exp_list
GEN_CRON_FILES gen_cron
GETCLIENTDIRS gendlclients
GEN_INETD_SETS gen_inetd
GETDISKS getdisks
EMBEDDEDLIST embedlist
GETUSERHOME getuserhome
EOL
`
