Sat, 15 Aug 2009 15:29:33 +0200
Include tmpfs filesystems
5 | 1 | #!/bin/bash |
2 | # | |
3 | ############################################################################# | |
11 | 4 | # Copyright (C) 2005-2009 |
5 | 5 | # |
6 | # Michiel Broek <mbse@mbse.eu> | |
7 | # Beekmansbos 10 | |
8 | # 1971 BV IJmuiden | |
9 | # the Netherlands | |
10 | # | |
11 | # This file is part of SlackSecCheckSripts. | |
12 | # | |
13 | # This package is free software; you can redistribute it and/or modify it | |
14 | # under the terms of the GNU General Public License as published by the | |
15 | # Free Software Foundation; either version 2, or (at your option) any | |
16 | # later version. | |
17 | # | |
18 | # SlackSecCheckSripts is distributed in the hope that it will be useful, but | |
19 | # WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 | # General Public License for more details. | |
22 | # | |
23 | # You should have received a copy of the GNU General Public License | |
24 | # along with MBSE BBS; see the file COPYING. If not, write to the Free | |
25 | # Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
26 | ############################################################################# | |
27 | ||
28 | PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
29 | ||
30 | umask 077 | |
31 | TZ=UTC; export TZ | |
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 | backup_dir=/var/cache/sscs | |
44 | mkdir -p "$backup_dir" | |
45 | ||
46 | CURR=${backup_dir}/setid.current | |
47 | BACK=${backup_dir}/setid.backup | |
48 | TMP1=$SECUREDIR/tmp1 | |
49 | TMP2=$SECUREDIR/tmp2 | |
50 | TMP3=$SECUREDIR/tmp3 | |
11 | 51 | FSS=$( egrep "^\/dev\/| tmpfs" /etc/mtab | awk '{ print $2 }' ) |
5 | 52 | |
53 | ||
54 | if [ ! -f $CURR ]; then | |
55 | # No database, install new database | |
56 | find $FSS \( -mount \( -perm -u+s -a ! -type d \) -o \( -perm -g+s -a ! -type d \) \) -print0 | \ | |
57 | xargs -0 /bin/ls -ld --full-time | sort -k9 > $CURR | |
58 | exit | |
59 | fi | |
60 | ||
61 | # Database is present, create temp database | |
62 | # | |
63 | find $FSS \( -mount \( -perm -u+s -a ! -type d \) -o \( -perm -g+s -a ! -type d \) \) -print0 | \ | |
64 | xargs -0 /bin/ls -ld --full-time | sort -k9 > $TMP1 | |
65 | changed=0 | |
66 | ||
67 | diff $TMP1 $CURR > $TMP2 | |
68 | if [ -s $TMP2 ]; then | |
69 | egrep '>' $TMP2 > $TMP3 | |
70 | if [ -s $TMP3 ]; then | |
71 | printf "\nOld or updated setuid or setgid files:\n" | |
72 | cat $TMP3 | tr '>' ' ' | |
73 | fi | |
74 | egrep '<' $TMP2 > $TMP3 | |
75 | if [ -s $TMP3 ]; then | |
76 | printf "\nNew or updated setuid or setgid files:\n" | |
77 | cat $TMP3 | tr '<' ' ' | |
78 | fi | |
79 | changed=1 | |
80 | fi | |
81 | ||
82 | ||
83 | # If changes were seen, update the database | |
84 | # | |
85 | if [ "$changed" == "1" ]; then | |
86 | cat $CURR > $BACK | |
87 | cat $TMP1 > $CURR | |
88 | fi | |
89 |