source: trunk/test/testrun_1b.sh@ 131

Last change on this file since 131 was 100, checked in by rainer, 18 years ago

Release 2.3.3; minor testscript and typo fixes.

File size: 8.3 KB
Line 
1#! /bin/sh
2
3#
4# Copyright Rainer Wichmann (2006)
5#
6# License Information:
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20#
21
22MAXTEST=3; export MAXTEST
23LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
24RCFILE="$PW_DIR/testrc_1.dyn"; export RCFILE
25
26testrun1b_internal ()
27{
28 BUILDOPTS="$1"
29 #
30 # test standalone compilation
31 #
32 [ -z "$verbose" ] || { echo; echo "${S}Building standalone agent${E}"; echo; }
33 #
34 if test -r "Makefile"; then
35 $MAKE distclean >/dev/null >&1
36 fi
37 #
38 #
39 ${TOP_SRCDIR}/configure ${BUILDOPTS} >/dev/null 2>/dev/null
40 #
41 #
42 if test x$? = x0; then
43 [ -z "$verbose" ] || log_msg_ok "configure...";
44 $MAKE > /dev/null 2>&1
45 if test x$? = x0; then
46 [ -z "$verbose" ] || log_msg_ok "make...";
47 else
48 [ -z "$quiet" ] && log_msg_fail "make...";
49 return 1
50 fi
51
52 else
53 [ -z "$quiet" ] && log_msg_fail "configure...";
54 return 1
55 fi
56
57 SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ { print NR + 1; exit 0; }' ${SCRIPTDIR}/test.sh`
58
59 tail -n "+$SKIP" ${SCRIPTDIR}/test.sh >/dev/null 2>&1
60 if [ $? -eq 0 ]; then
61 tail -n "+$SKIP" ${SCRIPTDIR}/test.sh | gunzip -c - | tar xf - && \
62 mv "./testrc.gpg.asc" "$RCFILE"
63 else
64 tail "+$SKIP" ${SCRIPTDIR}/test.sh | gunzip -c - | tar xf - && \
65 mv "./testrc.gpg.asc" "$RCFILE"
66 fi
67 if test x$? = x0; then
68 [ -z "$verbose" ] || log_msg_ok "extract gpg signed files...";
69 else
70 [ -z "$quiet" ] && log_msg_fail "extract gpg signed files...";
71 return 1
72 fi
73
74 if test "x$2" = "x"; then
75 :
76 else
77 CONVERT="$2"
78 if test -f "${TOP_SRCDIR}/stealth_template.jpg"; then
79 [ -z "$verbose" ] || log_msg_ok "convert..."
80 "${CONVERT}" +compress "${TOP_SRCDIR}/stealth_template.jpg" stealth_template.ps >/dev/null
81 else
82 [ -z "$quiet" ] && log_msg_fail "cannot find file stealth_template.jpg"
83 return 1
84 fi
85 if [ $? -ne 0 ]; then
86 [ -z "$quiet" ] && log_msg_fail "${CONVERT} +compress ${TOP_SRCDIR}/stealth_template.jpg stealth_template.ps";
87 return 1
88 fi
89
90 [ -z "$verbose" ] || log_msg_ok "hide..."
91 ./samhain_stealth -s stealth_template.ps "$RCFILE" >/dev/null
92 if [ $? -ne 0 ]; then
93 [ -z "$quiet" ] && log_msg_fail "${CONVERT} +compress ${TOP_SRCDIR}/stealth_template.jpg stealth_template.ps";
94 return 1
95 fi
96
97 mv -f stealth_template.ps "$RCFILE"
98 if [ $? -ne 0 ]; then
99 [ -z "$quiet" ] && log_msg_fail "mv -f stealth_template.ps $RCFILE";
100 return 1
101 fi
102
103 fi
104
105 rm -f ./.samhain_file
106 rm -f ./.samhain_log
107 rm -f ./.samhain_lock
108
109 ./samhain -t init -p none -l info
110
111 if test x$? = x0; then
112 [ -z "$verbose" ] || log_msg_ok "init...";
113 else
114 [ -z "$quiet" ] && log_msg_fail "init...";
115 return 1
116 fi
117
118 mv $PW_DIR/.samhain_file.asc $PW_DIR/.samhain_file
119}
120
121do_test_1b () {
122
123 ./samhain -t check -p none -l info
124
125 if test x$? = x0; then
126 ./samhain -j -L $LOGFILE >"${LOGFILE}.tmp" && mv "${LOGFILE}.tmp" "${LOGFILE}"
127 if [ $? -ne 0 ]; then
128 [ -z "$quiet" ] && log_msg_fail "mv logfile...";
129 return 1
130 fi
131 [ -z "$verbose" ] || log_msg_ok "check...";
132 else
133 [ -z "$quiet" ] && log_msg_fail "check...";
134 return 1
135 fi
136 #
137 tmp=`egrep "Checking.*/etc(>|\")" $LOGFILE 2>/dev/null | wc -l`
138 if [ $tmp -ne 2 ]; then
139 [ -z "$verbose" ] || log_msg_fail "/etc";
140 return 1
141 fi
142 tmp=`egrep "Checking.*(>|\")" $LOGFILE 2>/dev/null | wc -l`
143 if [ $tmp -ne 8 ]; then
144 [ -z "$verbose" ] || log_msg_fail "checking";
145 return 1
146 fi
147 egrep "ADDED" $LOGFILE >/dev/null 2>&1
148 if [ $? -eq 0 ]; then
149 [ -z "$verbose" ] || log_msg_fail "init was incomplete";
150 return 1
151 fi
152 #
153 return 0
154}
155
156do_test_1b_2 () {
157
158 rm -f $PW_DIR/test_log_prelude
159
160 "$PM" --textmod -l $PW_DIR/test_log_prelude --listen 127.0.0.1:5500 >/dev/null 2>&1 &
161 PID=$!
162
163 five_sec_sleep
164
165 ./samhain -t check -p none -l info --set-prelude-severity=info --prelude --server-addr 127.0.0.1:5500 >/dev/null
166
167 if test x$? = x0; then
168 ./samhain -j -L $LOGFILE >"${LOGFILE}.tmp" && mv "${LOGFILE}.tmp" "${LOGFILE}"
169 if [ $? -ne 0 ]; then
170 [ -z "$quiet" ] && log_msg_fail "mv logfile...";
171 kill $PID
172 return 1
173 fi
174 [ -z "$verbose" ] || log_msg_ok "check...";
175 else
176 [ -z "$quiet" ] && log_msg_fail "check...";
177 kill $PID
178 return 1
179 fi
180 #
181 tmp=`egrep 'File original:.*name=etc.*path=/etc' test_log_prelude 2>/dev/null | wc -l`
182 if [ $tmp -lt 1 ]; then
183 [ -z "$verbose" ] || log_msg_fail "/etc";
184 fi
185 tmp=`egrep 'Classification text: Checking' test_log_prelude 2>/dev/null | wc -l`
186 if [ $tmp -lt 1 ]; then
187 [ -z "$verbose" ] || log_msg_fail "checking";
188 fi
189 tmp=`egrep 'Classification text: Checking' test_log_prelude 2>/dev/null | wc -l`
190 if [ $tmp -lt 1 ]; then
191 [ -z "$verbose" ] || log_msg_fail "checking";
192 fi
193 #
194 kill $PID
195 return 0
196}
197
198testrun1b ()
199{
200 log_start "RUN STANDALONE W/STEALTH W/GPG"
201 GPG=`find_path gpg`
202 if [ -z "$GPG" ]; then
203 log_skip 1 $MAXTEST 'gpg not found in $PATH'
204 log_skip 2 $MAXTEST 'gpg not found in $PATH'
205 log_skip 3 $MAXTEST 'gpg not found in $PATH'
206 else
207 eval "$GPG" --list-keys 0F571F6C >/dev/null 2>/dev/null
208 if [ $? -ne 0 ]; then
209 log_skip 1 $MAXTEST 'public PGP key 0x0F571F6C not present'
210 log_skip 2 $MAXTEST 'public PGP key 0x0F571F6C not present'
211 log_skip 3 $MAXTEST 'public PGP key 0x0F571F6C not present'
212 else
213 #
214 # ------------- first test -------------
215 #
216 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"
217 testrun1b_internal "${BUILDOPTS}"
218 do_test_1b
219 if [ $? -eq 0 ]; then
220 log_ok 1 $MAXTEST 'gpg signed config/database files'
221 else
222 log_fail 1 $MAXTEST 'gpg signed config/database files'
223 fi
224
225
226 #
227 # ------------- second test -------------
228 #
229 PRECONV=`find_path convert`
230 "${PRECONV}" --help | grep ImageMagick >/dev/null 2>&1 && \
231 CONVERT="${PRECONV}"
232
233 if [ -z "$CONVERT" ]; then
234 log_skip 2 $MAXTEST 'ImageMagick convert not found in $PATH'
235 else
236 BUILDOPTS="--quiet $TRUST --enable-debug --with-gpg=${GPG} --with-checksum=no --enable-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"
237 testrun1b_internal "${BUILDOPTS}" "$CONVERT"
238 do_test_1b
239 if [ $? -eq 0 ]; then
240 log_ok 2 $MAXTEST 'gpg signed config/database files'
241 else
242 log_fail 2 $MAXTEST 'gpg signed config/database files'
243 fi
244 fi
245
246
247 #
248 # ------------- third test -------------
249 #
250 if test -f /usr/local/lib/libprelude.so
251 then
252 LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
253 export LD_LIBRARY_PATH
254 fi
255 #
256 PM=`find_path prelude-manager`
257 if [ -z "$PM" ]; then
258 log_skip 3 $MAXTEST 'prelude-manager not found in $PATH'
259 elif [ -z "$doall" ]; then
260 log_skip 3 $MAXTEST 'logging to prelude (or use --really-all)'
261 else
262 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"
263 testrun1b_internal "${BUILDOPTS} CFLAGS=-DSH_NOFAILOVER=1"
264 do_test_1b_2
265 if [ $? -eq 0 ]; then
266 log_ok 3 $MAXTEST 'logging to prelude'
267 else
268 log_fail 3 $MAXTEST 'logging to prelude'
269 fi
270 fi
271 fi
272 fi
273 log_end "RUN STANDALONE W/STEALTH W/GPG"
274 return 0
275}
276
Note: See TracBrowser for help on using the repository browser.