Sat, 17 Jan 2009 12:30:45 +0100
Suppress common device files
5 | 1 | #!/bin/bash |
2 | # | |
3 | ############################################################################# | |
6 | 4 | # Copyright (C) 2006-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}/dev.current | |
47 | BACK=${backup_dir}/dev.backup | |
48 | TMP1=$SECUREDIR/tmp1 | |
49 | TMP2=$SECUREDIR/tmp2 | |
50 | TMP3=$SECUREDIR/tmp3 | |
51 | ||
52 | if [ ! -f $CURR ]; then | |
53 | # No database, install new database | |
6 | 54 | find / \( -type b -o -type c \) -print0 2>/dev/null | xargs -0 /bin/ls -ldq --full-time | sort -k10 | egrep -v ptmx | egrep -v pts | egrep -v usb > $CURR |
5 | 55 | exit |
56 | fi | |
57 | ||
58 | # Database is present, create temp database | |
59 | # | |
6 | 60 | find / \( -type b -o -type c \) -print0 2>/dev/null | xargs -0 /bin/ls -ldq --full-time | sort -k10 | egrep -v ptmx | egrep -v pts | egrep -v usb > $TMP1 |
5 | 61 | changed=0 |
62 | ||
63 | diff -b $TMP1 $CURR > $TMP2 | |
64 | if [ -s $TMP2 ]; then | |
65 | egrep '>' $TMP2 > $TMP3 | |
66 | if [ -s $TMP3 ]; then | |
67 | printf "\nOld or updated device files:\n" | |
68 | cat $TMP3 | tr '>' ' ' | |
69 | fi | |
70 | egrep '<' $TMP2 > $TMP3 | |
71 | if [ -s $TMP3 ]; then | |
72 | printf "\nNew or updated device files:\n" | |
73 | cat $TMP3 | tr '<' ' ' | |
74 | fi | |
75 | changed=1 | |
76 | fi | |
77 | ||
78 | ||
79 | # If changes were seen, update the database | |
80 | # | |
81 | if [ "$changed" == "1" ]; then | |
82 | cat $CURR > $BACK | |
83 | cat $TMP1 > $CURR | |
84 | fi | |
85 |