Sun, 17 Feb 2013 19:49:24 +0100
Logs check's only yesterdays events, better mailbox check
5 | 1 | #!/bin/bash |
2 | # | |
3 | ############################################################################# | |
14
59e07bba67cc
Fixed spelling error, updated address
Michiel Broek <mbse@mbse.eu>
parents:
5
diff
changeset
|
4 | # Copyright (C) 2005-2012 |
5 | 5 | # |
6 | # Michiel Broek <mbse@mbse.dds.nl> | |
7 | # the Netherlands | |
8 | # | |
14
59e07bba67cc
Fixed spelling error, updated address
Michiel Broek <mbse@mbse.eu>
parents:
5
diff
changeset
|
9 | # This file is part of SlackSecCheckScripts. |
5 | 10 | # |
11 | # This package is free software; you can redistribute it and/or modify it | |
12 | # under the terms of the GNU General Public License as published by the | |
13 | # Free Software Foundation; either version 2, or (at your option) any | |
14 | # later version. | |
15 | # | |
14
59e07bba67cc
Fixed spelling error, updated address
Michiel Broek <mbse@mbse.eu>
parents:
5
diff
changeset
|
16 | # SlackSecCheckScripts is distributed in the hope that it will be useful, but |
5 | 17 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 | # General Public License for more details. | |
20 | # | |
21 | # You should have received a copy of the GNU General Public License | |
22 | # along with MBSE BBS; see the file COPYING. If not, write to the Free | |
23 | # Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
24 | ############################################################################# | |
25 | ||
26 | ||
27 | PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
28 | ||
29 | umask 077 | |
30 | TZ=UTC; export TZ | |
31 | LANG=C; export LANG | |
32 | ||
33 | MP=/etc/passwd | |
34 | SP=/etc/shadow | |
35 | ||
36 | SECUREDIR=`mktemp -d /tmp/_securedir.XXXXXX` || exit 1 | |
37 | ||
38 | trap "/bin/rm -rf $SECUREDIR ; exit 0" EXIT INT QUIT PIPE | |
39 | ||
40 | if ! cd "$SECUREDIR"; then | |
41 | echo "Can not cd to $SECUREDIR". | |
42 | exit 1 | |
43 | fi | |
44 | ||
45 | MPBYPATH=secure1.$$ | |
46 | OUTPUT=secure2.$$ | |
47 | ||
48 | # These are used several times. | |
49 | # | |
50 | awk -F: '{ print $1 " " $6 }' $MP | sort -k2 > $MPBYPATH | |
51 | ||
52 | ||
53 | # Files that should not have + signs. | |
54 | # | |
55 | list="/etc/hosts.equiv /etc/hosts.lpd" | |
56 | for f in $list ; do | |
57 | if [ -f $f ] && egrep '\+' $f > /dev/null ; then | |
58 | printf "\nPlus sign in $f file.\n" | |
59 | fi | |
60 | done | |
61 | ||
62 | # Check for special users with .rhosts files. Only root and toor should | |
63 | # have .rhosts files. Also, .rhosts files should not have plus signs. | |
64 | awk -F: '$1 != "root" && $1 != "toor" && ($3 < 100 || $1 == "ftp" || $1 == "uucp") \ | |
65 | { print $1 " " $6 }' $MP | | |
66 | sort -k2 | | |
67 | while read uid homedir; do | |
68 | if [ -f ${homedir}/.rhosts ] ; then | |
69 | rhost=`/bin/ls -ldg ${homedir}/.rhosts` | |
70 | printf -- "$uid: $rhost\n" | |
71 | fi | |
72 | done > $OUTPUT | |
73 | if [ -s $OUTPUT ] ; then | |
74 | printf "\nChecking for special users with .rhosts files.\n" | |
75 | cat $OUTPUT | |
76 | fi | |
77 | while read uid homedir; do | |
78 | if [ -f ${homedir}/.rhosts -a -r ${homedir}/.rhosts ] && \ | |
79 | cat ${homedir}/.rhosts | egrep '\+' > /dev/null ; then | |
80 | printf -- "$uid: + in .rhosts file.\n" | |
81 | fi | |
82 | done < $MPBYPATH > $OUTPUT | |
83 | if [ -s $OUTPUT ] ; then | |
84 | printf "\nChecking .rhosts files syntax.\n" | |
85 | cat $OUTPUT | |
86 | fi | |
87 | ||
88 |