]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/security
Document the new {auth,ident,tap} service and provide examples in the
[FreeBSD/FreeBSD.git] / etc / security
1 #!/bin/sh -
2 #
3 #       @(#)security    5.3 (Berkeley) 5/28/91
4 #       $Id: security,v 1.29 1999/01/10 11:18:59 danny Exp $
5 #
6 PATH=/sbin:/bin:/usr/bin
7 LC_ALL=C; export LC_ALL
8
9 separator () {
10         echo ""
11         echo ""
12 }
13
14 host=`hostname`
15 echo "Subject: $host security check output"
16
17 LOG=/var/log
18 TMP=/var/run/_secure.$$
19
20 umask 027
21
22 echo "checking setuid files and devices:"
23
24 # don't have ncheck, but this does the equivalent of the commented out block.
25 # note that one of the original problem, the possibility of overrunning
26 # the args to ls, is still here...
27 #
28 MP=`mount -t ufs | grep -v " nosuid" | sed 's;/dev/;&r;' | awk '{ print $3 }'`
29 set $MP
30 while test $# -ge 1; do
31         mount=$1
32         shift
33         find $mount -xdev -type f \
34                 \( -perm -u+x -or -perm -g+x -or -perm -o+x \) \
35                 \( -perm -u+s -or -perm -g+s \)  -print0
36 done | xargs -0 -n 20 ls -lTd | sort +9 > $TMP
37
38 if [ ! -f $LOG/setuid.today ] ; then
39         separator
40         echo "no $LOG/setuid.today"
41         cp $TMP $LOG/setuid.today
42 fi
43 if cmp $LOG/setuid.today $TMP >/dev/null; then :; else
44         separator
45         echo "$host setuid diffs:"
46         diff -b $LOG/setuid.today $TMP
47         mv $LOG/setuid.today $LOG/setuid.yesterday
48         mv $TMP $LOG/setuid.today
49 fi
50
51 separator
52 echo "checking for uids of 0:"
53 awk -F: '$3==0 {print $1,$3}' /etc/master.passwd
54
55 separator
56 echo "checking for passwordless accounts:"
57 awk -F: '$1 !~ /^\+/ && $2=="" {print $0}' /etc/master.passwd
58
59 # show denied packets
60 if ipfw -a l 2>/dev/null | egrep "deny|reset|unreach" > $TMP; then
61         if [ ! -f $LOG/ipfw.today ] ; then
62                 separator
63                 echo "no $LOG/ipfw.today"
64                 cp $TMP $LOG/ipfw.today
65         fi
66         if cmp $LOG/ipfw.today $TMP >/dev/null; then :; else
67                 separator
68                 echo "$host denied packets:"
69                 diff -b $LOG/ipfw.today $TMP | egrep "^>"
70                 mv $LOG/ipfw.today $LOG/ipfw.yesterday
71                 mv $TMP $LOG/ipfw.today
72         fi
73 fi
74
75 # show ipfw rules which have reached the log limit
76 IPFW_LOG_LIMIT=`sysctl -n net.inet.ip.fw.verbose_limit 2> /dev/null`
77 if [ $? -eq 0 ] && [ $IPFW_LOG_LIMIT -ne 0 ]; then
78         ipfw -a l | grep " log " | perl -n -e \
79                 '/^\d+\s+(\d+)/; print if ($1 >= '$IPFW_LOG_LIMIT')' > $TMP
80         if [ -s $TMP ]; then
81                 separator
82                 echo "ipfw log limit reached:"
83                 cat $TMP
84         fi
85 fi
86
87 # show kernel log messages
88 if dmesg 2>/dev/null > $TMP; then
89         if [ ! -f $LOG/dmesg.today ] ; then
90                 separator
91                 echo "no $LOG/dmesg.today"
92                 cp $TMP $LOG/dmesg.today
93         fi
94         if cmp $LOG/dmesg.today $TMP >/dev/null 2>&1; then :; else
95                 separator
96                 echo "$host kernel log messages:"
97                 diff -b $LOG/dmesg.today $TMP | egrep "^>"
98                 mv $LOG/dmesg.today $LOG/dmesg.yesterday
99                 mv $TMP $LOG/dmesg.today
100         fi
101 fi
102
103 # show login failures
104 separator
105 echo "$host login failures:"
106 grep -i "login failure" $LOG/messages
107
108 # show tcp_wrapper warning messages
109 separator
110 echo "$host refused connections:"
111 grep -i "refused connect" $LOG/messages
112
113 rm -f $TMP