Mon, 18 Feb 2013 19:47:24 +0100
Fixed check mailq on ssmtp systems
5 | 1 | #!/bin/bash |
2 | # | |
3 | ############################################################################# | |
14
59e07bba67cc
Fixed spelling error, updated address
Michiel Broek <mbse@mbse.eu>
parents:
8
diff
changeset
|
4 | # Copyright (C) 2005-2012 |
5 | 5 | # |
8
5209729bbbac
Fix for symliked home directories
Michiel Broek <mbroek@mbse.eu>
parents:
5
diff
changeset
|
6 | # Michiel Broek <mbse@mbse.eu> |
5 | 7 | # the Netherlands |
8 | # | |
14
59e07bba67cc
Fixed spelling error, updated address
Michiel Broek <mbse@mbse.eu>
parents:
8
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:
8
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 | MP=/etc/passwd | |
32 | LANG=C; export LANG | |
33 | ||
34 | SECUREDIR=`mktemp -d /tmp/_securedir.XXXXXX` || exit 1 | |
35 | ||
36 | trap "/bin/rm -rf $SECUREDIR ; exit 0" EXIT INT QUIT PIPE | |
37 | ||
38 | if ! cd "$SECUREDIR"; then | |
39 | echo "Can not cd to $SECUREDIR". | |
40 | exit 1 | |
41 | fi | |
42 | ||
43 | MPBYPATH=secure1.$$ | |
44 | OUTPUT=secure2.$$ | |
45 | ||
46 | ||
47 | # These are used several times. | |
48 | # | |
49 | awk -F: '{ print $1 " " $6 }' $MP | sort -k2 > $MPBYPATH | |
50 | ||
51 | ||
52 | # Check home directories. Directories should not be owned by someone else | |
53 | # or writeable. | |
54 | # | |
55 | while read uid homedir; do | |
56 | if [ -d ${homedir}/ ] ; then | |
8
5209729bbbac
Fix for symliked home directories
Michiel Broek <mbroek@mbse.eu>
parents:
5
diff
changeset
|
57 | file=`/bin/ls -ld ${homedir}/` |
5 | 58 | printf -- "$uid $file\n" |
59 | fi | |
60 | done < $MPBYPATH | | |
61 | awk '$1 != $4 && $4 != "root" { printf "\tuser %s home directory is owned by %s.\n", $1, $4 } | |
62 | $2 ~ /^.....w/ { printf "\tuser %s home directory %s is group writeable.\n", $1, $10 } | |
63 | $2 ~ /^........w/ { printf "\tuser %s home directory %s is other writeable.\n", $1, $10 }' \ | |
64 | > $OUTPUT | |
65 | if [ -s $OUTPUT ] ; then | |
66 | printf "\nChecking home directories.\n" | |
67 | cat $OUTPUT | |
68 | fi | |
69 | ||
70 | # Files that should not be owned by someone else or readable. | |
71 | list=".Xauthority .netrc .ssh/id_dsa .ssh/id_rsa .ssh/identity" | |
72 | while read uid homedir; do | |
73 | for f in $list ; do | |
74 | file=${homedir}/${f} | |
75 | if [ -f $file ] ; then | |
76 | printf -- "$uid $f `/bin/ls -ld $file`\n" | |
77 | fi | |
78 | done | |
79 | done < $MPBYPATH | | |
80 | awk '$1 != $5 && $5 != "root" { printf "\tuser %s %s file is owned by %s.\n", $1, $2, $5 } | |
81 | $3 ~ /^....r/ { printf "\tuser %s %s file is group readable.\n", $1, $2 } | |
82 | $3 ~ /^.......r/ { printf "\tuser %s %s file is other readable.\n", $1, $2 } | |
83 | $3 ~ /^.....w/ { printf "\tuser %s %s file is group writeable.\n", $1, $2 } | |
84 | $3 ~ /^........w/ { printf "\tuser %s %s file is other writeable.\n", $1, $2 }' \ | |
85 | > $OUTPUT | |
86 | # Files that should not be owned by someone else or writeable. | |
87 | list=".bash_history .bash_login .bash_logout .bash_profile .bashrc \ | |
88 | .cshrc .emacs .exrc .forward .history .klogin .login .logout \ | |
89 | .profile .qmail .rc_history .rhosts .shosts ssh .tcshrc .twmrc \ | |
90 | .xinitrc .xsession .ssh/authorized_keys .ssh/authorized_keys2 \ | |
91 | .ssh/config .ssh/id_dsa.pub .ssh/id_rsa.pub .ssh/identity.pub \ | |
92 | .ssh/known_hosts .ssh/known_hosts2" | |
93 | while read uid homedir; do | |
94 | for f in $list ; do | |
95 | file=${homedir}/${f} | |
96 | if [ -f $file ] ; then | |
97 | printf -- "$uid $f `/bin/ls -ld $file`\n" | |
98 | fi | |
99 | done | |
100 | done < $MPBYPATH | | |
101 | awk '$1 != $5 && $5 != "root" { printf "\tuser %s %s file is owned by %s.\n", $1, $2, $5 } | |
102 | $3 ~ /^.....w/ { printf "\tuser %s %s file is group writeable.\n", $1, $2 } | |
103 | $3 ~ /^........w/ { printf "\tuser %s %s file is other writeable.\n", $1, $2 }' \ | |
104 | >> $OUTPUT | |
105 | if [ -s $OUTPUT ] ; then | |
106 | printf "\nChecking dot files.\n" | |
107 | cat $OUTPUT | |
108 | fi | |
109 | ||
110 |