security.d/chk_exports

changeset 0
8ba6a0e2d2ca
child 14
59e07bba67cc
equal deleted inserted replaced
-1:000000000000 0:8ba6a0e2d2ca
1 #!/bin/bash
2 #
3 # $Id$
4 #
5 #############################################################################
6 # Copyright (C) 2005
7 #
8 # Michiel Broek <mbse@mbse.dds.nl>
9 # Beekmansbos 10
10 # 1971 BV IJmuiden
11 # the Netherlands
12 #
13 # This file is part of SlackSecCheckSripts.
14 #
15 # This package is free software; you can redistribute it and/or modify it
16 # under the terms of the GNU General Public License as published by the
17 # Free Software Foundation; either version 2, or (at your option) any
18 # later version.
19 #
20 # SlackSecCheckSripts is distributed in the hope that it will be useful, but
21 # WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 # General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with MBSE BBS; see the file COPYING. If not, write to the Free
27 # Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28 #############################################################################
29
30
31 PATH=/sbin:/usr/sbin:/bin:/usr/bin
32
33 umask 077
34 TZ=UTC; export TZ
35 LANG=C; export LANG
36
37 SECUREDIR=`mktemp -d /tmp/_securedir.XXXXXX` || exit 1
38
39 trap "/bin/rm -rf $SECUREDIR ; exit 0" EXIT INT QUIT PIPE
40
41 if ! cd "$SECUREDIR"; then
42 echo "Can not cd to $SECUREDIR".
43 exit 1
44 fi
45
46 OUTPUT=secure1.$$
47
48 # NFS exports shouldn't be globally exported
49 #
50 if [ -f /etc/exports ]; then
51 cat /etc/exports | awk '{
52 # ignore comments and blank lines
53 if ($0 ~ /^\#/ || $0 ~ /^$/ )
54 next;
55 readwrite = 0;
56 global = 0;
57 for (i = 2; i <= NF; ++i) {
58 if ($i ~ /*/)
59 global = 1;
60 if ($i ~ /rw/)
61 readwrite = 1;
62 }
63 if (global) {
64 if (readwrite)
65 printf "\tFile system %s globally exported, read-write.\n", $1
66 else
67 printf "\tFile system %s globally exported, read-only.\n", $1
68 }
69 }' > $OUTPUT
70
71 if [ -s $OUTPUT ] ; then
72 printf "\nChecking for globally exported file nfs systems.\n"
73 cat $OUTPUT
74 fi
75 fi
76
77

mercurial