Sat, 31 Mar 2007 13:32:06 +0200
Initial import
0 | 1 | #!/bin/bash |
2 | # | |
3 | # $Id$ | |
4 | # | |
5 | ############################################################################# | |
6 | # Copyright (C) 2006-2007 | |
7 | # | |
8 | # Michiel Broek <mbse@mbse.eu> | |
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 | PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
31 | ||
32 | umask 077 | |
33 | TZ=UTC; export TZ | |
34 | LANG=C; export LANG | |
35 | ||
36 | SECUREDIR=`mktemp -d /tmp/_securedir.XXXXXX` || exit 1 | |
37 | ||
38 | trap "/bin/rm -rf $SECUREDIR ; exit 0" EXIT INT QUIT PIPE | |
39 | ||
40 | if ! cd "$SECUREDIR"; then | |
41 | echo "Can not cd to $SECUREDIR". | |
42 | exit 1 | |
43 | fi | |
44 | ||
45 | backup_dir=/var/cache/sscs | |
46 | mkdir -p "$backup_dir" | |
47 | ||
48 | CURR=${backup_dir}/dev.current | |
49 | BACK=${backup_dir}/dev.backup | |
50 | TMP1=$SECUREDIR/tmp1 | |
51 | TMP2=$SECUREDIR/tmp2 | |
52 | TMP3=$SECUREDIR/tmp3 | |
53 | ||
54 | if [ ! -f $CURR ]; then | |
55 | # No database, install new database | |
56 | find / \( -type b -o -type c \) -print0 2>/dev/null | xargs -0 /bin/ls -ldq --full-time | sort -k10 | egrep -v ptmx > $CURR | |
57 | exit | |
58 | fi | |
59 | ||
60 | # Database is present, create temp database | |
61 | # | |
62 | find / \( -type b -o -type c \) -print0 2>/dev/null | xargs -0 /bin/ls -ldq --full-time | sort -k10 | egrep -v ptmx > $TMP1 | |
63 | changed=0 | |
64 | ||
65 | diff -b $TMP1 $CURR > $TMP2 | |
66 | if [ -s $TMP2 ]; then | |
67 | egrep '>' $TMP2 > $TMP3 | |
68 | if [ -s $TMP3 ]; then | |
69 | printf "\nOld or updated device files:\n" | |
70 | cat $TMP3 | tr '>' ' ' | |
71 | fi | |
72 | egrep '<' $TMP2 > $TMP3 | |
73 | if [ -s $TMP3 ]; then | |
74 | printf "\nNew or updated device files:\n" | |
75 | cat $TMP3 | tr '<' ' ' | |
76 | fi | |
77 | changed=1 | |
78 | fi | |
79 | ||
80 | ||
81 | # If changes were seen, update the database | |
82 | # | |
83 | if [ "$changed" == "1" ]; then | |
84 | cat $CURR > $BACK | |
85 | cat $TMP1 > $CURR | |
86 | fi | |
87 |