1 #!/bin/bash |
1 #!/bin/bash |
2 # |
2 # |
3 # $Id$ |
|
4 # |
|
5 ############################################################################# |
3 ############################################################################# |
6 # Copyright (C) 2005 |
4 # Copyright (C) 2005-2012 |
7 # |
5 # |
8 # Michiel Broek <mbse@mbse.dds.nl> |
6 # Michiel Broek <mbse@mbse.dds.nl> |
9 # Beekmansbos 10 |
7 # Beekmansbos 10 |
10 # 1971 BV IJmuiden |
8 # 1971 BV IJmuiden |
11 # the Netherlands |
9 # the Netherlands |
12 # |
10 # |
13 # This file is part of SlackSecCheckSripts. |
11 # This file is part of SlackSecCheckScripts. |
14 # |
12 # |
15 # This package is free software; you can redistribute it and/or modify it |
13 # 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 |
14 # 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 |
15 # Free Software Foundation; either version 2, or (at your option) any |
18 # later version. |
16 # later version. |
19 # |
17 # |
20 # SlackSecCheckSripts is distributed in the hope that it will be useful, but |
18 # SlackSecCheckScripts is distributed in the hope that it will be useful, but |
21 # WITHOUT ANY WARRANTY; without even the implied warranty of |
19 # WITHOUT ANY WARRANTY; without even the implied warranty of |
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
23 # General Public License for more details. |
21 # General Public License for more details. |
24 # |
22 # |
25 # You should have received a copy of the GNU General Public License |
23 # You should have received a copy of the GNU General Public License |
46 max_grouplen=${max_grouplen:-16} |
44 max_grouplen=${max_grouplen:-16} |
47 OUTPUT=secure1.$$ |
45 OUTPUT=secure1.$$ |
48 |
46 |
49 # Check group file |
47 # Check group file |
50 # |
48 # |
51 GRP=/etc/group |
49 grpck -r > $OUTPUT |
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 |
50 if [ -s $OUTPUT ] ; then |
71 printf "\nChecking the $GRP file:\n" |
51 printf "\nChecking the $GRP file:\n" |
72 cat $OUTPUT |
52 cat $OUTPUT |
73 fi |
53 fi |
74 |
54 |
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 |
|