Sat, 31 Mar 2007 13:32:06 +0200
Initial revision
0 | 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 | max_grouplen=${max_grouplen:-16} | |
47 | OUTPUT=secure1.$$ | |
48 | ||
49 | # Check group file | |
50 | # | |
51 | GRP=/etc/group | |
52 | awk -F: -v "len=$max_grouplen" '{ | |
53 | if ($0 ~ /^[ ]*$/) { | |
54 | printf "\tLine %d is a blank line.\n", NR; | |
55 | next; | |
56 | } | |
57 | if (NF != 4 && ($1 != "+" || NF != 1)) | |
58 | printf "\tLine %d has the wrong number of fields.\n", NR; | |
59 | if ($1 == "+" ) { | |
60 | next; | |
61 | } | |
62 | if ($1 !~ /^[A-Za-z0-9]([-A-Za-z0-9]*[A-Za-z0-9])*$/) | |
63 | printf "\tGroup %s has non-alphanumeric characters.\n", | |
64 | $1; | |
65 | if (length($1) > len) | |
66 | printf "\tGroup %s has more than "len" characters.\n", $1; | |
67 | if ($3 !~ /[0-9]*/) | |
68 | printf "\tLogin %s has a negative group id.\n", $1; | |
69 | }' < $GRP > $OUTPUT | |
70 | if [ -s $OUTPUT ] ; then | |
71 | printf "\nChecking the $GRP file:\n" | |
72 | cat $OUTPUT | |
73 | fi | |
74 | ||
75 | awk -F: '{ print $1 }' $GRP | sort | uniq -d > $OUTPUT | |
76 | if [ -s $OUTPUT ] ; then | |
77 | printf "\n\t$GRP has duplicate group names.\n" | |
78 | column $OUTPUT | |
79 | fi | |
80 | ||
81 |