source: trunk/test/testrun_2.sh@ 31

Last change on this file since 31 was 30, checked in by rainer, 19 years ago

Release candidate 3 for version 2.2.0

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