source: trunk/test/testrun_1b.sh@ 25

Last change on this file since 25 was 22, checked in by rainer, 19 years ago

Minor code revisions.

File size: 5.2 KB
Line 
1#! /bin/sh
2
3
4MAXTEST=2; export MAXTEST
5LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
6RCFILE="$PW_DIR/testrc_1.dyn"; export RCFILE
7
8testrun1b_internal ()
9{
10 BUILDOPTS="$1"
11 #
12 # test standalone compilation
13 #
14 [ -z "$verbose" ] || { echo; echo "${S}Building standalone agent${E}"; echo; }
15 #
16 if test -r "Makefile"; then
17 $MAKE distclean >/dev/null >&1
18 fi
19 #
20 #
21 ${TOP_SRCDIR}/configure ${BUILDOPTS} >/dev/null 2>/dev/null
22 #
23 #
24 if test x$? = x0; then
25 [ -z "$verbose" ] || log_msg_ok "configure...";
26 $MAKE > /dev/null 2>&1
27 if test x$? = x0; then
28 [ -z "$verbose" ] || log_msg_ok "make...";
29 else
30 [ -z "$quiet" ] && log_msg_fail "make...";
31 return 1
32 fi
33
34 else
35 [ -z "$quiet" ] && log_msg_fail "configure...";
36 return 1
37 fi
38
39 SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ { print NR + 1; exit 0; }' ${SCRIPTDIR}/test.sh`
40
41 tail -n "+$SKIP" ${SCRIPTDIR}/test.sh >/dev/null 2>&1
42 if [ $? -eq 0 ]; then
43 tail -n "+$SKIP" ${SCRIPTDIR}/test.sh | gunzip -c - | tar xf - && \
44 mv "./testrc.gpg.asc" "$RCFILE"
45 else
46 tail "+$SKIP" ${SCRIPTDIR}/test.sh | gunzip -c - | tar xf - && \
47 mv "./testrc.gpg.asc" "$RCFILE"
48 fi
49 if test x$? = x0; then
50 [ -z "$verbose" ] || log_msg_ok "extract gpg signed files...";
51 else
52 [ -z "$quiet" ] && log_msg_fail "extract gpg signed files...";
53 return 1
54 fi
55
56 rm -f ./.samhain_file
57 rm -f ./.samhain_log
58 rm -f ./.samhain_lock
59
60 ./samhain -t init -p none -l info
61
62 if test x$? = x0; then
63 [ -z "$verbose" ] || log_msg_ok "init...";
64 else
65 [ -z "$quiet" ] && log_msg_fail "init...";
66 return 1
67 fi
68
69 mv $PW_DIR/.samhain_file.asc $PW_DIR/.samhain_file
70}
71
72do_test_1b () {
73
74 ./samhain -t check -p none -l info
75
76 if test x$? = x0; then
77 ./samhain -j -L $LOGFILE >"${LOGFILE}.tmp" && mv "${LOGFILE}.tmp" "${LOGFILE}"
78 if [ $? -ne 0 ]; then
79 [ -z "$quiet" ] && log_msg_fail "mv logfile...";
80 return 1
81 fi
82 [ -z "$verbose" ] || log_msg_ok "check...";
83 else
84 [ -z "$quiet" ] && log_msg_fail "check...";
85 return 1
86 fi
87 #
88 tmp=`egrep "Checking.*/etc(>|\")" $LOGFILE 2>/dev/null | wc -l`
89 if [ $tmp -ne 2 ]; then
90 [ -z "$verbose" ] || log_msg_fail "/etc";
91 fi
92 tmp=`egrep "Checking.*(>|\")" $LOGFILE 2>/dev/null | wc -l`
93 if [ $tmp -ne 2 ]; then
94 [ -z "$verbose" ] || log_msg_fail "checking";
95 fi
96 #
97 return 0
98}
99
100do_test_1b_2 () {
101
102 rm -f $PW_DIR/test_log_prelude
103
104 "$PM" --textmod -l $PW_DIR/test_log_prelude --listen 127.0.0.1:5500 >/dev/null 2>&1 &
105 PID=$!
106
107 sleep 5
108
109 ./samhain -t check -p none -l info --set-prelude-severity=info --prelude --server-addr 127.0.0.1:5500 >/dev/null
110
111 if test x$? = x0; then
112 ./samhain -j -L $LOGFILE >"${LOGFILE}.tmp" && mv "${LOGFILE}.tmp" "${LOGFILE}"
113 if [ $? -ne 0 ]; then
114 [ -z "$quiet" ] && log_msg_fail "mv logfile...";
115 kill $PID
116 return 1
117 fi
118 [ -z "$verbose" ] || log_msg_ok "check...";
119 else
120 [ -z "$quiet" ] && log_msg_fail "check...";
121 kill $PID
122 return 1
123 fi
124 #
125 tmp=`egrep 'File original:.*name=etc.*path=/etc' test_log_prelude 2>/dev/null | wc -l`
126 if [ $tmp -ne 1 ]; then
127 [ -z "$verbose" ] || log_msg_fail "/etc";
128 fi
129 tmp=`egrep 'Classification text: Checking' test_log_prelude 2>/dev/null | wc -l`
130 if [ $tmp -ne 1 ]; then
131 [ -z "$verbose" ] || log_msg_fail "checking";
132 fi
133 tmp=`egrep 'Classification text: Checking' test_log_prelude 2>/dev/null | wc -l`
134 if [ $tmp -ne 1 ]; then
135 [ -z "$verbose" ] || log_msg_fail "checking";
136 fi
137 #
138 kill $PID
139 return 0
140}
141
142testrun1b ()
143{
144 log_start "RUN STANDALONE W/STEALTH W/GPG"
145 GPG=`find_path gpg`
146 if [ -z "$GPG" ]; then
147 log_skip 1 $MAXTEST 'gpg not found in $PATH'
148 log_skip 2 $MAXTEST 'gpg not found in $PATH'
149 else
150 eval "$GPG" --list-keys 0F571F6C >/dev/null 2>/dev/null
151 if [ $? -ne 0 ]; then
152 log_skip 1 $MAXTEST 'public PGP key 0x0F571F6C not present'
153 log_skip 2 $MAXTEST 'public PGP key 0x0F571F6C not present'
154 else
155 BUILDOPTS="--quiet $TRUST --enable-debug --with-gpg=${GPG} --with-checksum=no --enable-micro-stealth=137 --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file"
156 testrun1b_internal "${BUILDOPTS}"
157 do_test_1b
158 if [ $? -eq 0 ]; then
159 log_ok 1 $MAXTEST 'gpg signed config/database files'
160 else
161 log_fail 1 $MAXTEST 'gpg signed config/database files'
162 fi
163 PM=`find_path prelude-manager`
164 if [ -z "$PM" ]; then
165 log_skip 2 $MAXTEST 'prelude-manager not found in $PATH'
166 elif [ -z "$doall" ]; then
167 log_skip 2 $MAXTEST 'logging to prelude (or use --really-all)'
168 else
169 BUILDOPTS="--quiet $TRUST --enable-debug --with-prelude --with-gpg=${GPG} --with-checksum=no --enable-micro-stealth=137 --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file"
170 testrun1b_internal "${BUILDOPTS} CFLAGS=-DSH_NOFAILOVER=1"
171 do_test_1b_2
172 if [ $? -eq 0 ]; then
173 log_ok 2 $MAXTEST 'logging to prelude'
174 else
175 log_fail 2 $MAXTEST 'logging to prelude'
176 fi
177 fi
178 fi
179 fi
180 log_end "RUN STANDALONE W/STEALTH W/GPG"
181 return 0
182}
183
Note: See TracBrowser for help on using the repository browser.