1 | #! /bin/sh
|
---|
2 |
|
---|
3 | LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
|
---|
4 | RCFILE="$PW_DIR/testrc_2"; export RCFILE
|
---|
5 | HTML="$PW_DIR/yule.html"; export HTML
|
---|
6 |
|
---|
7 |
|
---|
8 | do_test_1 () {
|
---|
9 |
|
---|
10 | [ -z "$verbose" ] || {
|
---|
11 | echo;
|
---|
12 | echo "${S}Start Server${E}: ./yule -l info -p none &";
|
---|
13 | echo;
|
---|
14 | }
|
---|
15 |
|
---|
16 | rm -f test_log_valgrind
|
---|
17 |
|
---|
18 | ${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind &
|
---|
19 | PROC_Y=$!
|
---|
20 | sleep 5
|
---|
21 |
|
---|
22 | [ -z "$verbose" ] || {
|
---|
23 | echo;
|
---|
24 | echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
|
---|
25 | echo;
|
---|
26 | }
|
---|
27 |
|
---|
28 | ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind
|
---|
29 | if test x$? = x0; then
|
---|
30 | [ -z "$verbose" ] || log_msg_ok "samhain.new -t check";
|
---|
31 | else
|
---|
32 | [ -z "$quiet" ] && log_msg_fail "samhain.new -t check";
|
---|
33 | kill $PROC_Y
|
---|
34 | return 1
|
---|
35 | fi
|
---|
36 |
|
---|
37 | kill $PROC_Y
|
---|
38 | sleep 5
|
---|
39 |
|
---|
40 | egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
|
---|
41 | if [ $? -ne 0 ]; then
|
---|
42 | [ -z "$verbose" ] || log_msg_fail "Server start";
|
---|
43 | return 1
|
---|
44 | fi
|
---|
45 | egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1
|
---|
46 | if [ $? -ne 0 ]; then
|
---|
47 | [ -z "$verbose" ] || log_msg_fail "Client connect";
|
---|
48 | return 1
|
---|
49 | fi
|
---|
50 | egrep "remote_host.*Checking.*/bin" $LOGFILE >/dev/null 2>&1
|
---|
51 | if [ $? -ne 0 ]; then
|
---|
52 | [ -z "$verbose" ] || log_msg_fail "Client file check";
|
---|
53 | return 1
|
---|
54 | fi
|
---|
55 | egrep "remote_host.*EXIT.*Samhain" $LOGFILE >/dev/null 2>&1
|
---|
56 | if [ $? -ne 0 ]; then
|
---|
57 | [ -z "$verbose" ] || log_msg_fail "Client exit";
|
---|
58 | return 1
|
---|
59 | fi
|
---|
60 | egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1
|
---|
61 | if [ $? -ne 0 ]; then
|
---|
62 | [ -z "$verbose" ] || log_msg_fail "Server exit";
|
---|
63 | return 1
|
---|
64 | fi
|
---|
65 |
|
---|
66 | [ -z "$VALGRIND" ] || {
|
---|
67 | tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
|
---|
68 | if [ $tmp -ne 0 ]; then
|
---|
69 | [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
|
---|
70 | cat test_log_valgrind
|
---|
71 | return 1;
|
---|
72 | fi;
|
---|
73 | }
|
---|
74 |
|
---|
75 | return 0
|
---|
76 | }
|
---|
77 |
|
---|
78 | do_test_2 () {
|
---|
79 |
|
---|
80 | ORIGINAL="UseSeparateLogs=no"
|
---|
81 | REPLACEMENT="UseSeparateLogs=yes"
|
---|
82 | ex $RCFILE <<EOF
|
---|
83 | :%s/$ORIGINAL/$REPLACEMENT/g
|
---|
84 | :wq
|
---|
85 | EOF
|
---|
86 | # :%s is the "ex" substitution command.
|
---|
87 | # :wq is write-and-quit.
|
---|
88 | [ -z "$verbose" ] || {
|
---|
89 | echo;
|
---|
90 | echo "${S}Start Server${E}: ./yule -l info -p none &";
|
---|
91 | echo;
|
---|
92 | }
|
---|
93 |
|
---|
94 | rm -f $LOGFILE
|
---|
95 | rm -f test_log_valgrind
|
---|
96 |
|
---|
97 | ${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind &
|
---|
98 | PROC_Y=$!
|
---|
99 | sleep 5
|
---|
100 |
|
---|
101 | [ -z "$verbose" ] || {
|
---|
102 | echo;
|
---|
103 | echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
|
---|
104 | echo;
|
---|
105 | }
|
---|
106 |
|
---|
107 | ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind
|
---|
108 | if test x$? = x0; then
|
---|
109 | [ -z "$verbose" ] || log_msg_ok "samhain.new -t check";
|
---|
110 | else
|
---|
111 | [ -z "$quiet" ] && log_msg_fail "samhain.new -t check";
|
---|
112 | kill $PROC_Y
|
---|
113 | return 1
|
---|
114 | fi
|
---|
115 |
|
---|
116 | kill $PROC_Y
|
---|
117 | sleep 5
|
---|
118 |
|
---|
119 | if [ -f ${LOGFILE}.${SH_LOCALHOST} ]; then
|
---|
120 | remhost=${SH_LOCALHOST}
|
---|
121 | else
|
---|
122 | remhost=`echo $SH_LOCALHOST | sed 's,\..*,,'`
|
---|
123 | fi
|
---|
124 | if [ -f ${LOGFILE}.${remhost} ]; then
|
---|
125 | CLIENTLOG="${LOGFILE}.${remhost}"
|
---|
126 | else
|
---|
127 | CLIENTLOG=`ls -1 ${LOGFILE}.* 2>/dev/null | tail -n 1`
|
---|
128 | fi
|
---|
129 |
|
---|
130 | egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
|
---|
131 | if [ $? -ne 0 ]; then
|
---|
132 | [ -z "$verbose" ] || log_msg_fail "Server start";
|
---|
133 | return 1
|
---|
134 | fi
|
---|
135 | egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1
|
---|
136 | if [ $? -ne 0 ]; then
|
---|
137 | [ -z "$verbose" ] || log_msg_fail "Client connect";
|
---|
138 | return 1
|
---|
139 | fi
|
---|
140 | egrep "remote_host.*Checking.*/bin" ${CLIENTLOG} >/dev/null 2>&1
|
---|
141 | if [ $? -ne 0 ]; then
|
---|
142 | [ -z "$verbose" ] || log_msg_fail "Client file check";
|
---|
143 | return 1
|
---|
144 | fi
|
---|
145 | egrep "remote_host.*EXIT.*Samhain" ${CLIENTLOG} >/dev/null 2>&1
|
---|
146 | if [ $? -ne 0 ]; then
|
---|
147 | [ -z "$verbose" ] || log_msg_fail "Client exit";
|
---|
148 | return 1
|
---|
149 | fi
|
---|
150 | egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1
|
---|
151 | if [ $? -ne 0 ]; then
|
---|
152 | [ -z "$verbose" ] || log_msg_fail "Server exit";
|
---|
153 | return 1
|
---|
154 | fi
|
---|
155 |
|
---|
156 | [ -z "$VALGRIND" ] || {
|
---|
157 | tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
|
---|
158 | if [ $tmp -ne 0 ]; then
|
---|
159 | [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
|
---|
160 | cat test_log_valgrind
|
---|
161 | return 1;
|
---|
162 | fi;
|
---|
163 | }
|
---|
164 |
|
---|
165 | rm -f ${LOGFILE}.${remhost}
|
---|
166 | return 0
|
---|
167 | }
|
---|
168 |
|
---|
169 | do_test_3 () {
|
---|
170 |
|
---|
171 | ORIGINAL_1="ExportSeverity=none"
|
---|
172 | REPLACEMENT_1="ExportSeverity=mark"
|
---|
173 | ORIGINAL_2="UseSeparateLogs=yes"
|
---|
174 | REPLACEMENT_2="UseSeparateLogs=no"
|
---|
175 | ORIGINAL_3="LogSeverity=none"
|
---|
176 | REPLACEMENT_3="LogSeverity=debug"
|
---|
177 | ORIGINAL_4="# SetClientTimeLimit=1800"
|
---|
178 | REPLACEMENT_4="SetClientTimeLimit=20"
|
---|
179 | ex $RCFILE <<EOF
|
---|
180 | :%s/${ORIGINAL_1}/${REPLACEMENT_1}/g
|
---|
181 | :%s/${ORIGINAL_2}/${REPLACEMENT_2}/g
|
---|
182 | :%s/${ORIGINAL_3}/${REPLACEMENT_3}/g
|
---|
183 | :%s/${ORIGINAL_4}/${REPLACEMENT_4}/g
|
---|
184 | :wq
|
---|
185 | EOF
|
---|
186 | # :%s is the "ex" substitution command.
|
---|
187 | # :wq is write-and-quit.
|
---|
188 | [ -z "$verbose" ] || {
|
---|
189 | echo;
|
---|
190 | echo "${S}Start Server${E}: ./yule -p none &";
|
---|
191 | echo;
|
---|
192 | }
|
---|
193 |
|
---|
194 | rm -f $LOGFILE
|
---|
195 | rm -f test_log_valgrind
|
---|
196 |
|
---|
197 | ${VALGRIND} ./yule -p none >/dev/null 2>>test_log_valgrind &
|
---|
198 | PROC_Y=$!
|
---|
199 | sleep 5
|
---|
200 |
|
---|
201 | [ -z "$verbose" ] || {
|
---|
202 | echo;
|
---|
203 | echo "${S}Start Client${E}: ./samhain.new -l none -p none -t check";
|
---|
204 | echo;
|
---|
205 | }
|
---|
206 |
|
---|
207 | ${VALGRIND} ./samhain.new -t check -p none -l none --forever --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind &
|
---|
208 | if test x$? = x0; then
|
---|
209 | PROC_S=$!
|
---|
210 | # echo "PID is ${PROC_S}"
|
---|
211 | [ -z "$verbose" ] || log_msg_ok "samhain.new -t check";
|
---|
212 | sleep 5
|
---|
213 | # Redirect the shells (un-)helpful job monitoring messages.
|
---|
214 | # The 'disown' buildin is not portable.
|
---|
215 | { kill -9 ${PROC_S}; sleep 40; } >/dev/null 2>&1
|
---|
216 | else
|
---|
217 | [ -z "$quiet" ] && log_msg_fail "samhain.new -t check";
|
---|
218 | kill $PROC_Y
|
---|
219 | return 1
|
---|
220 | fi
|
---|
221 |
|
---|
222 | if [ -t 0 ]; then
|
---|
223 | # enable monitor mode again if interactive
|
---|
224 | set -m
|
---|
225 | fi
|
---|
226 |
|
---|
227 |
|
---|
228 | kill $PROC_Y
|
---|
229 | sleep 5
|
---|
230 |
|
---|
231 | egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
|
---|
232 | if [ $? -ne 0 ]; then
|
---|
233 | [ -z "$verbose" ] || log_msg_fail "Server start";
|
---|
234 | return 1
|
---|
235 | fi
|
---|
236 | egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1
|
---|
237 | if [ $? -ne 0 ]; then
|
---|
238 | [ -z "$verbose" ] || log_msg_fail "Client connect";
|
---|
239 | return 1
|
---|
240 | fi
|
---|
241 | egrep "remote_host.*File check completed.*" ${LOGFILE} >/dev/null 2>&1
|
---|
242 | if [ $? -ne 0 ]; then
|
---|
243 | [ -z "$verbose" ] || log_msg_fail "Client file check";
|
---|
244 | return 1
|
---|
245 | fi
|
---|
246 | egrep "Time limit exceeded" ${LOGFILE} >/dev/null 2>&1
|
---|
247 | if [ $? -ne 0 ]; then
|
---|
248 | [ -z "$verbose" ] || log_msg_fail "Client dead detection";
|
---|
249 | return 1
|
---|
250 | fi
|
---|
251 | egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1
|
---|
252 | if [ $? -ne 0 ]; then
|
---|
253 | [ -z "$verbose" ] || log_msg_fail "Server exit";
|
---|
254 | return 1
|
---|
255 | fi
|
---|
256 |
|
---|
257 | [ -z "$VALGRIND" ] || {
|
---|
258 | tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
|
---|
259 | if [ $tmp -ne 0 ]; then
|
---|
260 | [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
|
---|
261 | cat test_log_valgrind
|
---|
262 | return 1;
|
---|
263 | fi;
|
---|
264 | }
|
---|
265 |
|
---|
266 | rm -f ${LOGFILE}
|
---|
267 | return 0
|
---|
268 | }
|
---|
269 |
|
---|
270 | do_test_4 () {
|
---|
271 |
|
---|
272 | # don't know what is supported on the test platform, so
|
---|
273 | # prepare for both (password and socket credential)
|
---|
274 |
|
---|
275 | # 'id -u' is posix
|
---|
276 | me=`id -u`
|
---|
277 |
|
---|
278 | ORIGINAL_1="SetSocketAllowUid=0"
|
---|
279 | REPLACEMENT_1="SetSocketAllowUid=$me"
|
---|
280 | ex $RCFILE <<EOF
|
---|
281 | :%s/${ORIGINAL_1}/${REPLACEMENT_1}/g
|
---|
282 | :wq
|
---|
283 | EOF
|
---|
284 |
|
---|
285 | [ -z "$verbose" ] || {
|
---|
286 | echo;
|
---|
287 | echo "${S}Start Server${E}: ./yule -l info -p none &";
|
---|
288 | echo;
|
---|
289 | }
|
---|
290 |
|
---|
291 | rm -f $LOGFILE
|
---|
292 | rm -f test_log_valgrind
|
---|
293 |
|
---|
294 | ${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind &
|
---|
295 | PROC_Y=$!
|
---|
296 | sleep 5
|
---|
297 |
|
---|
298 | [ -z "$verbose" ] || {
|
---|
299 | echo;
|
---|
300 | echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
|
---|
301 | echo;
|
---|
302 | }
|
---|
303 |
|
---|
304 | $MAKE yulectl >/dev/null
|
---|
305 | if [ $? -ne 0 ]; then
|
---|
306 | [ -z "$verbose" ] || log_msg_fail "make yulectl";
|
---|
307 | kill $PROC_Y
|
---|
308 | return 1
|
---|
309 | fi
|
---|
310 |
|
---|
311 |
|
---|
312 | ./yulectl -v -c RELOAD foobar1 >test_log_yulectl 2>/dev/null
|
---|
313 |
|
---|
314 | if [ $? -ne 0 ]; then
|
---|
315 | YULECTL_PASSWORD=samhain; export YULECTL_PASSWORD
|
---|
316 | ./yulectl -v -c RELOAD foobar1 >test_log_yulectl
|
---|
317 | if [ $? -ne 0 ]; then
|
---|
318 | kill ${PROC_Y}
|
---|
319 | [ -z "$verbose" ] || log_msg_fail "yulectl";
|
---|
320 | return 1
|
---|
321 | fi
|
---|
322 | fi
|
---|
323 |
|
---|
324 | ./yulectl -v -c RELOAD foobar2 >test_yulectl_log
|
---|
325 |
|
---|
326 | if [ $? -ne 0 ]; then
|
---|
327 | kill ${PROC_Y}
|
---|
328 | [ -z "$verbose" ] || log_msg_fail "yulectl";
|
---|
329 | return 1
|
---|
330 | fi
|
---|
331 |
|
---|
332 | ./yulectl -v -c RELOAD foobar3 >test_log_yulectl
|
---|
333 |
|
---|
334 | if [ $? -ne 0 ]; then
|
---|
335 | kill ${PROC_Y}
|
---|
336 | [ -z "$verbose" ] || log_msg_fail "yulectl";
|
---|
337 | return 1
|
---|
338 | fi
|
---|
339 |
|
---|
340 | ./yulectl -v -c LISTALL dummy >test_log_yulectl
|
---|
341 |
|
---|
342 | if [ $? -ne 0 ]; then
|
---|
343 | kill ${PROC_Y}
|
---|
344 | [ -z "$verbose" ] || log_msg_fail "yulectl";
|
---|
345 | return 1
|
---|
346 | fi
|
---|
347 |
|
---|
348 | tmp=`cat test_log_yulectl | grep RELOAD | wc -l`
|
---|
349 | if [ $tmp -ne 3 ]; then
|
---|
350 | kill ${PROC_Y}
|
---|
351 | [ -z "$verbose" ] || log_msg_fail "command confirmation";
|
---|
352 | return 1
|
---|
353 | fi
|
---|
354 |
|
---|
355 | ./yulectl -v -c CANCEL foobar3 >test_log_yulectl
|
---|
356 |
|
---|
357 | if [ $? -ne 0 ]; then
|
---|
358 | kill ${PROC_Y}
|
---|
359 | [ -z "$verbose" ] || log_msg_fail "yulectl";
|
---|
360 | return 1
|
---|
361 | fi
|
---|
362 |
|
---|
363 | ./yulectl -v -c LISTALL dummy >test_log_yulectl
|
---|
364 |
|
---|
365 | if [ $? -ne 0 ]; then
|
---|
366 | kill ${PROC_Y}
|
---|
367 | [ -z "$verbose" ] || log_msg_fail "yulectl";
|
---|
368 | return 1
|
---|
369 | fi
|
---|
370 |
|
---|
371 | tmp=`cat test_log_yulectl | grep RELOAD | wc -l`
|
---|
372 | if [ $tmp -ne 2 ]; then
|
---|
373 | kill ${PROC_Y}
|
---|
374 | [ -z "$verbose" ] || log_msg_fail "command confirmation";
|
---|
375 | return 1
|
---|
376 | fi
|
---|
377 |
|
---|
378 | kill ${PROC_Y}
|
---|
379 |
|
---|
380 | [ -z "$VALGRIND" ] || {
|
---|
381 | tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
|
---|
382 | if [ $tmp -ne 0 ]; then
|
---|
383 | [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
|
---|
384 | cat test_log_valgrind
|
---|
385 | return 1;
|
---|
386 | fi;
|
---|
387 | }
|
---|
388 |
|
---|
389 | return 0
|
---|
390 | }
|
---|
391 |
|
---|
392 | do_test_5 () {
|
---|
393 |
|
---|
394 | [ -z "$verbose" ] || {
|
---|
395 | echo;
|
---|
396 | echo "${S}Start Server${E}: ./yule -l info -p none &";
|
---|
397 | echo;
|
---|
398 | }
|
---|
399 |
|
---|
400 | ( cat <<EOF
|
---|
401 | <!-- head -->
|
---|
402 | <html><head><title>test</title></head>
|
---|
403 | <body>
|
---|
404 | Current time: %T <br>
|
---|
405 | <table>
|
---|
406 | <!-- ehead -->
|
---|
407 | EOF
|
---|
408 | ) >head.html
|
---|
409 |
|
---|
410 | ( cat <<EOF
|
---|
411 | <!-- foot -->
|
---|
412 | </table>
|
---|
413 | </body>
|
---|
414 | <!-- efoot -->
|
---|
415 | EOF
|
---|
416 | ) >foot.html
|
---|
417 |
|
---|
418 | ( cat <<EOF
|
---|
419 | <!-- entry -->
|
---|
420 | <tr>
|
---|
421 | <td>%H</td>
|
---|
422 | <td>%S</td>
|
---|
423 | <td>%T</td>
|
---|
424 | </tr>
|
---|
425 | <!-- eentry -->
|
---|
426 | EOF
|
---|
427 | ) >entry.html
|
---|
428 |
|
---|
429 | ${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind &
|
---|
430 | PROC_Y=$!
|
---|
431 | sleep 5
|
---|
432 |
|
---|
433 | egrep '<!-- head -->' $HTML >/dev/null 2>&1
|
---|
434 | if [ $? -ne 0 ]; then
|
---|
435 | rm -f head.html; rm -f foot.html; rm -f entry.html;
|
---|
436 | kill $PROC_Y
|
---|
437 | [ -z "$verbose" ] || log_msg_fail "head.html";
|
---|
438 | return 1
|
---|
439 | fi
|
---|
440 |
|
---|
441 | egrep '<!-- foot -->' $HTML >/dev/null 2>&1
|
---|
442 | if [ $? -ne 0 ]; then
|
---|
443 | rm -f head.html; rm -f foot.html; rm -f entry.html;
|
---|
444 | kill $PROC_Y
|
---|
445 | [ -z "$verbose" ] || log_msg_fail "foot.html";
|
---|
446 | return 1
|
---|
447 | fi
|
---|
448 |
|
---|
449 | [ -z "$verbose" ] || {
|
---|
450 | echo;
|
---|
451 | echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
|
---|
452 | echo;
|
---|
453 | }
|
---|
454 |
|
---|
455 | ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind
|
---|
456 | if test x$? = x0; then
|
---|
457 | [ -z "$verbose" ] || log_msg_ok "samhain.new -t check";
|
---|
458 | else
|
---|
459 | kill $PROC_Y
|
---|
460 | [ -z "$quiet" ] && log_msg_fail "samhain.new -t check";
|
---|
461 | return 1
|
---|
462 | fi
|
---|
463 |
|
---|
464 | kill $PROC_Y
|
---|
465 | sleep 5
|
---|
466 |
|
---|
467 | # rm -f head.html; rm -f foot.html; rm -f entry.html;
|
---|
468 |
|
---|
469 | egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
|
---|
470 | if [ $? -ne 0 ]; then
|
---|
471 | [ -z "$verbose" ] || log_msg_fail "Server start";
|
---|
472 | return 1
|
---|
473 | fi
|
---|
474 | egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1
|
---|
475 | if [ $? -ne 0 ]; then
|
---|
476 | [ -z "$verbose" ] || log_msg_fail "Client connect";
|
---|
477 | return 1
|
---|
478 | fi
|
---|
479 | egrep "remote_host.*Checking.*/bin" $LOGFILE >/dev/null 2>&1
|
---|
480 | if [ $? -ne 0 ]; then
|
---|
481 | [ -z "$verbose" ] || log_msg_fail "Client file check";
|
---|
482 | return 1
|
---|
483 | fi
|
---|
484 | egrep "remote_host.*EXIT.*Samhain" $LOGFILE >/dev/null 2>&1
|
---|
485 | if [ $? -ne 0 ]; then
|
---|
486 | [ -z "$verbose" ] || log_msg_fail "Client exit";
|
---|
487 | return 1
|
---|
488 | fi
|
---|
489 | egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1
|
---|
490 | if [ $? -ne 0 ]; then
|
---|
491 | [ -z "$verbose" ] || log_msg_fail "Server exit";
|
---|
492 | return 1
|
---|
493 | fi
|
---|
494 |
|
---|
495 | egrep '<!-- head -->' $HTML >/dev/null 2>&1
|
---|
496 | if [ $? -ne 0 ]; then
|
---|
497 | [ -z "$verbose" ] || log_msg_fail "head.html";
|
---|
498 | return 1
|
---|
499 | fi
|
---|
500 | egrep '<!-- ehead -->' $HTML >/dev/null 2>&1
|
---|
501 | if [ $? -ne 0 ]; then
|
---|
502 | [ -z "$verbose" ] || log_msg_fail "head.html";
|
---|
503 | return 1
|
---|
504 | fi
|
---|
505 |
|
---|
506 | egrep '<!-- entry -->' $HTML >/dev/null 2>&1
|
---|
507 | if [ $? -ne 0 ]; then
|
---|
508 | [ -z "$verbose" ] || log_msg_fail "entry.html";
|
---|
509 | return 1
|
---|
510 | fi
|
---|
511 | egrep '<!-- eentry -->' $HTML >/dev/null 2>&1
|
---|
512 | if [ $? -ne 0 ]; then
|
---|
513 | [ -z "$verbose" ] || log_msg_fail "entry.html";
|
---|
514 | return 1
|
---|
515 | fi
|
---|
516 |
|
---|
517 | egrep '<!-- foot -->' $HTML >/dev/null 2>&1
|
---|
518 | if [ $? -ne 0 ]; then
|
---|
519 | [ -z "$verbose" ] || log_msg_fail "foot.html";
|
---|
520 | return 1
|
---|
521 | fi
|
---|
522 | egrep '<!-- efoot -->' $HTML >/dev/null 2>&1
|
---|
523 | if [ $? -ne 0 ]; then
|
---|
524 | [ -z "$verbose" ] || log_msg_fail "foot.html";
|
---|
525 | return 1
|
---|
526 | fi
|
---|
527 |
|
---|
528 | [ -z "$VALGRIND" ] || {
|
---|
529 | tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
|
---|
530 | if [ $tmp -ne 0 ]; then
|
---|
531 | [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
|
---|
532 | cat test_log_valgrind
|
---|
533 | return 1;
|
---|
534 | fi;
|
---|
535 | }
|
---|
536 |
|
---|
537 | return 0
|
---|
538 | }
|
---|
539 |
|
---|
540 |
|
---|
541 | testrun2_internal ()
|
---|
542 | {
|
---|
543 | [ -z "$verbose" ] || {
|
---|
544 | echo;
|
---|
545 | echo Working directory: $PW_DIR; echo MAKE is $MAKE;
|
---|
546 | echo;
|
---|
547 | }
|
---|
548 | #
|
---|
549 | #
|
---|
550 | [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; }
|
---|
551 | #
|
---|
552 | if test -r "Makefile"; then
|
---|
553 | $MAKE distclean
|
---|
554 | fi
|
---|
555 | #
|
---|
556 | ${TOP_SRCDIR}/configure --quiet $TRUST --enable-debug --enable-network=client --enable-xml-log --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file --enable-encrypt=2
|
---|
557 | #
|
---|
558 | if test x$? = x0; then
|
---|
559 | [ -z "$verbose" ] || log_msg_ok "configure...";
|
---|
560 | $MAKE > /dev/null 2>>test_log
|
---|
561 | if test x$? = x0; then
|
---|
562 | [ -z "$verbose" ] || log_msg_ok "make...";
|
---|
563 | else
|
---|
564 | [ -z "$quiet" ] && log_msg_fail "make...";
|
---|
565 | return 1
|
---|
566 | fi
|
---|
567 |
|
---|
568 | else
|
---|
569 | [ -z "$quiet" ] && log_msg_fail "configure...";
|
---|
570 | return 1
|
---|
571 | fi
|
---|
572 |
|
---|
573 | # save binary and build server
|
---|
574 | #
|
---|
575 | cp samhain samhain.build || return 1
|
---|
576 | make clean >/dev/null || return 1
|
---|
577 |
|
---|
578 | ${TOP_SRCDIR}/configure --quiet $TRUST --enable-debug --enable-network=server --enable-xml-log --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file --with-html-file=$HTML --enable-encrypt=2
|
---|
579 | #
|
---|
580 | if test x$? = x0; then
|
---|
581 | [ -z "$verbose" ] || log_msg_ok "configure...";
|
---|
582 | $MAKE > /dev/null 2>>test_log
|
---|
583 | if test x$? = x0; then
|
---|
584 | [ -z "$verbose" ] || log_msg_ok "make...";
|
---|
585 | else
|
---|
586 | [ -z "$quiet" ] && log_msg_fail "make...";
|
---|
587 | return 1
|
---|
588 | fi
|
---|
589 |
|
---|
590 | else
|
---|
591 | [ -z "$quiet" ] && log_msg_fail "configure...";
|
---|
592 | return 1
|
---|
593 | fi
|
---|
594 |
|
---|
595 |
|
---|
596 | #####################################################################
|
---|
597 | #
|
---|
598 | #
|
---|
599 | rm -f ./.samhain_file
|
---|
600 | rm -f ./.samhain_log
|
---|
601 | rm -f ./.samhain_lock
|
---|
602 |
|
---|
603 | cp ${SCRIPTDIR}/testrc_2.in testrc_2
|
---|
604 |
|
---|
605 | ./samhain.build -t init -p none
|
---|
606 |
|
---|
607 | if test x$? = x0; then
|
---|
608 | [ -z "$verbose" ] || log_msg_ok "init...";
|
---|
609 | else
|
---|
610 | [ -z "$quiet" ] && log_msg_fail "init...";
|
---|
611 | return 1
|
---|
612 | fi
|
---|
613 |
|
---|
614 | # Create a password
|
---|
615 |
|
---|
616 | SHPW=`./yule -G`
|
---|
617 | if test x"$SHPW" = x; then
|
---|
618 | [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting"
|
---|
619 | return 1
|
---|
620 | fi
|
---|
621 |
|
---|
622 | # Set in client
|
---|
623 |
|
---|
624 | ./samhain_setpwd samhain.build new $SHPW >/dev/null
|
---|
625 |
|
---|
626 | if test x$? = x0; then
|
---|
627 | [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd samhain.build new $SHPW";
|
---|
628 | else
|
---|
629 | [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd samhain.build new $SHPW";
|
---|
630 | return 1
|
---|
631 | fi
|
---|
632 |
|
---|
633 | mv samhain.build.new samhain.new || return 1
|
---|
634 |
|
---|
635 | rm -f ./.samhain_log.*
|
---|
636 | rm -f ./.samhain_lock
|
---|
637 |
|
---|
638 | SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%`
|
---|
639 |
|
---|
640 | if test x$? = x0; then
|
---|
641 | [ -z "$verbose" ] || log_msg_ok "yule -P $SHPW";
|
---|
642 | else
|
---|
643 | [ -z "$quiet" ] && log_msg_fail "yule -P $SHPW";
|
---|
644 | return 1
|
---|
645 | fi
|
---|
646 |
|
---|
647 | echo $SHCLT >> testrc_2
|
---|
648 |
|
---|
649 | do_test_1
|
---|
650 | if [ $? -eq 0 ]; then
|
---|
651 | [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client logging";
|
---|
652 | else
|
---|
653 | [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client logging";
|
---|
654 | fi
|
---|
655 |
|
---|
656 | do_test_2
|
---|
657 | if [ $? -eq 0 ]; then
|
---|
658 | [ -z "$quiet" ] && log_ok 2 ${MAXTEST} "Client logging, separate logfiles";
|
---|
659 | else
|
---|
660 | [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "Client logging, separate logfiles";
|
---|
661 | fi
|
---|
662 |
|
---|
663 | do_test_3
|
---|
664 | if [ $? -eq 0 ]; then
|
---|
665 | [ -z "$quiet" ] && log_ok 3 ${MAXTEST} "Dead client detection";
|
---|
666 | else
|
---|
667 | [ -z "$quiet" ] && log_fail 3 ${MAXTEST} "Dead client detection";
|
---|
668 | fi
|
---|
669 |
|
---|
670 | do_test_4
|
---|
671 | if [ $? -eq 0 ]; then
|
---|
672 | [ -z "$quiet" ] && log_ok 4 ${MAXTEST} "Server command socket";
|
---|
673 | else
|
---|
674 | [ -z "$quiet" ] && log_fail 4 ${MAXTEST} "Server command socket";
|
---|
675 | fi
|
---|
676 |
|
---|
677 | do_test_5
|
---|
678 | if [ $? -eq 0 ]; then
|
---|
679 | [ -z "$quiet" ] && log_ok 5 ${MAXTEST} "Server status file";
|
---|
680 | else
|
---|
681 | [ -z "$quiet" ] && log_fail 5 ${MAXTEST} "Server status file";
|
---|
682 | fi
|
---|
683 |
|
---|
684 | return $?
|
---|
685 | }
|
---|
686 |
|
---|
687 | MAXTEST=5; export MAXTEST
|
---|
688 |
|
---|
689 | testrun2 ()
|
---|
690 | {
|
---|
691 | log_start "RUN CLIENT/SERVER"
|
---|
692 |
|
---|
693 | if [ x"$1" = x ]; then
|
---|
694 | [ -z "$quiet" ] && log_msg_fail "Missing hostname"
|
---|
695 | fi
|
---|
696 | #
|
---|
697 | SH_LOCALHOST=$1; export SH_LOCALHOST
|
---|
698 | #
|
---|
699 | testrun2_internal
|
---|
700 | #
|
---|
701 | log_end "RUN CLIENT/SERVER"
|
---|
702 |
|
---|
703 | return 0
|
---|
704 | }
|
---|
705 |
|
---|