Thu, 06 Dec 2012 15:08:01 +0100
Fixed spelling error, updated address
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 | SECUREDIR=`mktemp -d /tmp/_securedir.XXXXXX` || exit 1 | |
34 | ||
35 | trap "/bin/rm -rf $SECUREDIR ; exit 0" EXIT INT QUIT PIPE | |
36 | ||
37 | if ! cd "$SECUREDIR"; then | |
38 | echo "Can not cd to $SECUREDIR". | |
39 | exit 1 | |
40 | fi | |
41 | ||
42 | TMP1=secure1.$$ | |
43 | OUTPUT=secure2.$$ | |
44 | ||
45 | ||
46 | # Check for root paths, umask values in startup files. | |
47 | # The check for the root paths is problematical -- it's likely to fail | |
48 | # in other environments. Once the shells have been modified to warn | |
49 | # of '.' in the path, the path tests should go away. | |
50 | # | |
51 | rhome=~root | |
52 | umaskset=no | |
53 | ||
54 | if [ -x /bin/tcsh ]; then | |
55 | list="/etc/csh.cshrc /etc/csh.login ${rhome}/.cshrc ${rhome}/.login `/bin/ls /etc/profile.d/*.csh`" | |
56 | ||
57 | for i in $list ; do | |
58 | if [ -f $i ] ; then | |
59 | if egrep '^[^#]*(umask)' $i > /dev/null ; | |
60 | then | |
61 | umaskset=yes | |
62 | fi | |
63 | # Double check the umask value itself; ensure that | |
64 | # both the group and other write bits are set. | |
65 | # | |
66 | egrep '^[^#]*(umask)' $i | | |
67 | awk '{ | |
68 | if ($2 ~ /^.$/ || $2 ~! /[^2367].$/) { | |
69 | print "\tRoot umask is group writeable" | |
70 | } | |
71 | if ($2 ~ /[^2367]$/) { | |
72 | print "\tRoot umask is other writeable" | |
73 | } | |
74 | }' | sort -u | |
75 | SAVE_PATH=$PATH | |
76 | unset PATH | |
77 | /bin/csh -f -s << end-of-csh > /dev/null 2>&1 | |
78 | source $i | |
79 | /bin/ls -ldgT \$path > $TMP1 | |
80 | end-of-csh | |
81 | export PATH=$SAVE_PATH | |
82 | if [ -f $TMP1 ]; then | |
83 | awk '{ | |
84 | if ($10 ~ /^\.$/) { | |
85 | print "\tThe root path includes ."; | |
86 | next; | |
87 | } | |
88 | } | |
89 | $1 ~ /^d....w/ \ | |
90 | { print "\tRoot path directory " $10 " is group writeable." } \ | |
91 | $1 ~ /^d.......w/ \ | |
92 | { print "\tRoot path directory " $10 " is other writeable." }' \ | |
93 | < $TMP1 | |
94 | fi | |
95 | fi | |
96 | done > $OUTPUT | |
97 | ||
98 | if [ $umaskset = "no" -o -s $OUTPUT ] ; then | |
99 | printf "\nChecking root csh paths, umask values:\n$list\n\n" | |
100 | if [ -s $OUTPUT ]; then | |
101 | cat $OUTPUT | |
102 | fi | |
103 | if [ $umaskset = "no" ] ; then | |
104 | printf "\tRoot csh startup files do not set the umask.\n" | |
105 | fi | |
106 | fi | |
107 | fi | |
108 | ||
109 | umaskset=no | |
110 | list="/etc/profile ${rhome}/.profile `/bin/ls /etc/profile.d/*.sh`" | |
111 | for i in $list; do | |
112 | if [ -f $i ] ; then | |
113 | if egrep '^[^#]*(umask)' $i > /dev/null ; then | |
114 | umaskset=yes | |
115 | fi | |
116 | egrep '^[^#]*(umask)' $i | | |
117 | awk '$2 ~ /^.$/ || $2 ~ /[^2367].$/ \ | |
118 | { print "\tRoot umask is group writeable" } \ | |
119 | $2 ~ /[^2367]$/ \ | |
120 | { print "\tRoot umask is other writeable" }' | |
121 | SAVE_PATH=$PATH | |
122 | unset PATH | |
123 | /bin/sh << end-of-sh > /dev/null 2>&1 | |
124 | . $i | |
125 | list=\`echo \$PATH | /usr/bin/sed -e \ | |
126 | 's/^:/.:/;s/:$/:./;s/::/:.:/g;s/:/ /g'\` | |
127 | /bin/ls -ldgT \$list > $TMP1 | |
128 | end-of-sh | |
129 | export PATH=$SAVE_PATH | |
130 | awk '{ | |
131 | if ($10 ~ /^\.$/) { | |
132 | print "\tThe root path includes ."; | |
133 | next; | |
134 | } | |
135 | } | |
136 | $1 ~ /^d....w/ \ | |
137 | { print "\tRoot path directory " $10 " is group writeable." } \ | |
138 | $1 ~ /^d.......w/ \ | |
139 | { print "\tRoot path directory " $10 " is other writeable." }' \ | |
140 | < $TMP1 | |
141 | fi | |
142 | done > $OUTPUT | |
143 | ||
144 | if [ $umaskset = "no" -o -s $OUTPUT ] ; then | |
145 | printf "\nChecking root sh paths, umask values:\n$list\n" | |
146 | if [ -s $OUTPUT ]; then | |
147 | cat $OUTPUT | |
148 | fi | |
149 | if [ $umaskset = "no" ] ; then | |
150 | printf "\tRoot sh startup files do not set the umask.\n" | |
151 | fi | |
152 | fi | |
153 |