Debian Codegraph @

examples/integrit_check

raw
1 #! /bin/sh
2 # integrit - file integrity verification system
3 # Copyright (C) 2006 Ed L. Cashin
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 #
19 # $Header: /cvsroot/integrit/integrit/examples/integrit_check,v 1.11 2006/04/07 09:41:13 wavexx Exp $
20
21 host=`hostname`
22 securedir=/mnt/secdb
23 config=$1 # should be in read-only location
24 recipient=$2
25 arch=`uname`
26
27 if [ "`whoami`" != "root" ]; then
28 echo Error: you must be root to run $0 1>&2
29 exit 1
30 fi
31
32 if [ "$recipient" = "" -o "$config" = "" ]; then
33 echo usage: $0 config_file email_recipient 1>&2
34 exit 1
35 fi
36
37 #------------integrit binary compiled for this architecture
38 integrit=$securedir/bin/integrit-$arch
39
40 # do update (-u) and check (-c)
41 # ... with configuration $conf (-C) and human-readable output
42 # ... piping output to sendmail; or exit with an error message
43 # to standard output.
44
45 (printf "To: $recipient\nSubject: integrit $host report\n\n";
46 $integrit -C $config -u -c) | /usr/lib/sendmail -t || {
47 echo $0 error 1>&2
48 exit 1
49 }
50
51
52