Initial add of defaria.com
[clearscm.git] / defaria.com / Computers / code / adm / bin / check_security
1 #! /bin/ksh
2 USAGE='USAGE:   check_security
3
4         This script checks for some security problems.  It does
5         not fix anything.  It only prints messages about possible
6         problems.
7
8    Author: Michael Coulter
9 '
10
11 # Set parameters
12
13    PASSWD_FILE=/etc/passwd
14
15 # Check for execution by root
16
17    WHOAMI=$(whoami)
18    if [ "$WHOAMI" != "root" ]
19    then
20       echo "It is recommended that you run this script as root"
21    fi
22
23 # Parse all the lines in $PASSWD_FILE
24
25    OLD_IFS="$IFS"
26    IFS=":"
27    cat "$PASSWD_FILE" | while read USER PASSWORD UID GID COMMENT HOME SHELL REST
28    do
29       # Checks for users who shouldn't log-in, i.e. PASSWORD is "*"
30
31       if [ "$PASSWORD" = '*' ]
32       then
33          # If the PASSWORD is "*", there should not be a .rhosts or hosts.equiv
34          # in the home directory or .forward
35          if [ -f "${HOME}/.rhosts" ]
36          then
37             echo "$USER has a .rhosts file in $HOME"
38          fi
39          if [ -f "${HOME}/.forward" ]
40          then
41             echo "$USER has a .forward file in $HOME"
42          fi
43
44
45
46          # There should not be a crontab or atjob for the user
47
48          if [ -f "/usr/spool/cron/crontabs/${USER}" ]
49          then
50             echo "$USER has a crontab file in /usr/spool/cron/crontabs"
51          fi
52          if [ -f "/usr/spool/cron/atjobs/${USER}" ]
53          then
54             echo "$USER has a crontab file in /usr/spool/cron/atjobs"
55          fi
56
57       fi # End of * password checks
58
59       if [ "$PASSWORD" = "" ]
60       then
61          echo "$USER has a NULL password."
62       fi
63
64       # No wildcards in $HOME/.rhosts or /etc/host.equiv
65       LINES="$(sed -e "/^#/d"  $HOME/.rhosts | grep "+" 2> /dev/null | wc -l)"
66       if [ "$LINES" -ne 0 ]
67       then
68          echo "$USER has + in $HOME/.rhosts"
69       fi
70       
71    done
72    #  read USER PASSWORD UID GID COMMENT HOME SHELL REST
73
74 # Checks that are only done once
75
76 # Check no wildcards in /etc/host.equiv
77
78    LINES="$(grep -- "+" /etc/host.equiv 2> /dev/null | wc -l)"
79    if [ "$LINES" -ne 0 ]
80    then
81       echo "System has + in /etc/host.equiv" 
82    fi
83
84    if [ ! -f "/usr/adm/inetd.sec" ]
85    then
86       echo "No /usr/adm/inetd.sec file. "
87    fi
88
89    if [ -f "/etc/hosts.equiv" ]
90    then
91       echo "System has a /etc/hosts.equiv file"
92    fi
93