security.d/chk_plussigns

Tue, 15 Apr 2014 14:45:38 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 15 Apr 2014 14:45:38 +0200
changeset 20
1d18ebb9e279
parent 17
65656789da08
permissions
-rw-r--r--

Fixed permission errors on .gvfs virtual filesystems. Bumped to version 0.21

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

mercurial