source: branches/samhain_3_1/test/testrun_2.sh@ 574

Last change on this file since 574 was 415, checked in by katerina, 12 years ago

Fixes for tickets #314, #315, #316, #317, #318, #319, #320, and #321.

File size: 20.0 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 five_sec_sleep
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 five_sec_sleep
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 five_sec_sleep
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 -s $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 five_sec_sleep
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 five_sec_sleep
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 # takes too much time if we leave that in
242 ORIGINAL_5="dir=1"
243 REPLACEMENT_5="#dir=1"
244 ex -s $RCFILE <<EOF
245%s/${ORIGINAL_1}/${REPLACEMENT_1}/g
246%s/${ORIGINAL_2}/${REPLACEMENT_2}/g
247%s/${ORIGINAL_3}/${REPLACEMENT_3}/g
248%s/${ORIGINAL_4}/${REPLACEMENT_4}/g
249%s/${ORIGINAL_5}/${REPLACEMENT_5}/g
250wq
251EOF
252# :%s is the "ex" substitution command.
253# :wq is write-and-quit.
254 [ -z "$verbose" ] || {
255 echo;
256 echo "${S}Start Server${E}: ./yule -p none -e none &";
257 echo;
258 }
259
260 rm -f $LOGFILE
261 rm -f test_log_valgrind
262
263 ${VALGRIND} ./yule -p none -e none >/dev/null 2>>test_log_valgrind &
264 PROC_Y=$!
265 five_sec_sleep
266
267 [ -z "$verbose" ] || {
268 echo;
269 echo "${S}Start Client${E}: ./samhain.new -t check -p none -l none --forever --bind-address=127.0.0.1 &";
270 echo;
271 }
272
273 ${VALGRIND} ./samhain.new -t check -p none -l none --forever --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind &
274 if test x$? = x0; then
275 PROC_S=$!
276 # echo "PID is ${PROC_S}"
277 [ -z "$verbose" ] || log_msg_ok "samhain.new -t check";
278 five_sec_sleep
279 # Redirect the shells (un-)helpful job monitoring messages.
280 # The 'disown' buildin is not portable.
281 { kill -9 ${PROC_S}; sleep 40; } >/dev/null 2>&1
282 else
283 [ -z "$quiet" ] && log_msg_fail "samhain.new -t check";
284 kill $PROC_Y
285 return 1
286 fi
287
288 if [ -t 0 ]; then
289 # enable monitor mode again if interactive
290 set -m
291 fi
292
293 kill $PROC_Y
294 five_sec_sleep
295
296 egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
297 if [ $? -ne 0 ]; then
298 [ -z "$verbose" ] || log_msg_fail "Server start";
299 return 1
300 fi
301 egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1
302 if [ $? -ne 0 ]; then
303 [ -z "$verbose" ] || log_msg_fail "Client connect";
304 return 1
305 fi
306 egrep "remote_host.*File check completed.*" ${LOGFILE} >/dev/null 2>&1
307 if [ $? -ne 0 ]; then
308 [ -z "$verbose" ] || log_msg_fail "Client file check";
309 return 1
310 fi
311 egrep "Time limit exceeded" ${LOGFILE} >/dev/null 2>&1
312 if [ $? -ne 0 ]; then
313 [ -z "$verbose" ] || log_msg_fail "Client dead detection";
314 return 1
315 fi
316 egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1
317 if [ $? -ne 0 ]; then
318 [ -z "$verbose" ] || log_msg_fail "Server exit";
319 return 1
320 fi
321
322 [ -z "$VALGRIND" ] || {
323 tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
324 if [ $tmp -ne 0 ]; then
325 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
326 cat test_log_valgrind
327 return 1;
328 fi;
329 }
330
331 rm -f ${LOGFILE}
332 return 0
333}
334
335do_test_4 () {
336
337 # don't know what is supported on the test platform, so
338 # prepare for both (password and socket credential)
339
340 # 'id -u' is posix
341 if test -f /usr/xpg4/bin/id
342 then
343 me=`/usr/xpg4/bin/id -u`
344 else
345 me=`id -u`
346 fi
347
348 ORIGINAL_1="SetSocketAllowUid=0"
349 REPLACEMENT_1="SetSocketAllowUid=$me"
350 ex -s $RCFILE <<EOF
351%s/${ORIGINAL_1}/${REPLACEMENT_1}/g
352wq
353EOF
354
355 [ -z "$verbose" ] || {
356 echo;
357 echo "${S}Start Server${E}: ./yule -l info -p none &";
358 echo;
359 }
360
361 rm -f $LOGFILE
362 rm -f test_log_valgrind
363
364 ${VALGRIND} ./yule -l info -p none -e none \
365 >/dev/null 2>>test_log_valgrind &
366 PROC_Y=$!
367 five_sec_sleep
368
369 [ -z "$verbose" ] || {
370 echo;
371 echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
372 echo;
373 }
374
375 $MAKE yulectl >/dev/null
376 if [ $? -ne 0 ]; then
377 [ -z "$verbose" ] || log_msg_fail "make yulectl";
378 kill $PROC_Y
379 return 1
380 fi
381
382
383 ./yulectl -v -c RELOAD foobar1 >test_log_yulectl 2>/dev/null
384
385 if [ $? -ne 0 ]; then
386 YULECTL_PASSWORD=samhain; export YULECTL_PASSWORD
387 ./yulectl -v -c RELOAD foobar1 >test_log_yulectl
388 if [ $? -ne 0 ]; then
389 kill ${PROC_Y}
390 [ -z "$verbose" ] || log_msg_fail "yulectl";
391 return 1
392 fi
393 fi
394
395 ./yulectl -v -c RELOAD foobar2 >test_yulectl_log
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 RELOAD foobar3 >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 ./yulectl -v -c LISTALL dummy >test_log_yulectl
412
413 if [ $? -ne 0 ]; then
414 kill ${PROC_Y}
415 [ -z "$verbose" ] || log_msg_fail "yulectl";
416 return 1
417 fi
418
419 tmp=`cat test_log_yulectl | grep RELOAD | wc -l`
420 if [ $tmp -ne 3 ]; then
421 kill ${PROC_Y}
422 [ -z "$verbose" ] || log_msg_fail "command confirmation";
423 return 1
424 fi
425
426 ./yulectl -v -c CANCEL foobar3 >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 ./yulectl -v -c LISTALL dummy >test_log_yulectl
435
436 if [ $? -ne 0 ]; then
437 kill ${PROC_Y}
438 [ -z "$verbose" ] || log_msg_fail "yulectl";
439 return 1
440 fi
441
442 tmp=`cat test_log_yulectl | grep RELOAD | wc -l`
443 if [ $tmp -ne 2 ]; then
444 kill ${PROC_Y}
445 [ -z "$verbose" ] || log_msg_fail "command confirmation";
446 return 1
447 fi
448
449 kill ${PROC_Y}
450 one_sec_sleep
451 one_sec_sleep
452 kill -9 ${PROC_Y} >/dev/null 2>&1
453
454 [ -z "$VALGRIND" ] || {
455 tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
456 if [ $tmp -ne 0 ]; then
457 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
458 cat test_log_valgrind
459 return 1;
460 fi;
461 }
462
463 return 0
464}
465
466do_test_5 () {
467
468 [ -z "$verbose" ] || {
469 echo;
470 echo "${S}Start Server${E}: ./yule -l info -p none &";
471 echo;
472 }
473
474( cat <<EOF
475<!-- head -->
476<html><head><title>test</title></head>
477<body>
478Current time: %T <br>
479<table>
480<!-- ehead -->
481EOF
482) >head.html
483
484( cat <<EOF
485<!-- foot -->
486</table>
487</body>
488<!-- efoot -->
489EOF
490) >foot.html
491
492( cat <<EOF
493<!-- entry -->
494<tr>
495 <td>%H</td>
496 <td>%S</td>
497 <td>%T</td>
498</tr>
499<!-- eentry -->
500EOF
501) >entry.html
502
503 ${VALGRIND} ./yule -l info -p none -e none \
504 >/dev/null 2>>test_log_valgrind &
505 PROC_Y=$!
506 five_sec_sleep
507
508 egrep '<!-- head -->' $HTML >/dev/null 2>&1
509 if [ $? -ne 0 ]; then
510 # rm -f head.html; rm -f foot.html; rm -f entry.html;
511 kill $PROC_Y
512 [ -z "$verbose" ] || log_msg_fail "head.html (1)";
513 return 1
514 fi
515
516 egrep '<!-- foot -->' $HTML >/dev/null 2>&1
517 if [ $? -ne 0 ]; then
518 rm -f head.html; rm -f foot.html; rm -f entry.html;
519 kill $PROC_Y
520 [ -z "$verbose" ] || log_msg_fail "foot.html (1)";
521 return 1
522 fi
523
524 [ -z "$verbose" ] || {
525 echo;
526 echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
527 echo;
528 }
529
530 ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind
531 if test x$? = x0; then
532 [ -z "$verbose" ] || log_msg_ok "samhain.new -t check";
533 else
534 kill $PROC_Y
535 [ -z "$quiet" ] && log_msg_fail "samhain.new -t check";
536 return 1
537 fi
538
539 cp $HTML ${HTML}.tmp
540
541 kill $PROC_Y
542 five_sec_sleep
543
544 # rm -f head.html; rm -f foot.html; rm -f entry.html;
545
546 egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
547 if [ $? -ne 0 ]; then
548 [ -z "$verbose" ] || log_msg_fail "Server start";
549 return 1
550 fi
551 egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1
552 if [ $? -ne 0 ]; then
553 [ -z "$verbose" ] || log_msg_fail "Client connect";
554 return 1
555 fi
556 egrep "remote_host.*Checking.*/bin" $LOGFILE >/dev/null 2>&1
557 if [ $? -ne 0 ]; then
558 [ -z "$verbose" ] || log_msg_fail "Client file check";
559 return 1
560 fi
561 egrep "remote_host.*EXIT.*Samhain" $LOGFILE >/dev/null 2>&1
562 if [ $? -ne 0 ]; then
563 [ -z "$verbose" ] || log_msg_fail "Client exit";
564 return 1
565 fi
566 egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1
567 if [ $? -ne 0 ]; then
568 [ -z "$verbose" ] || log_msg_fail "Server exit";
569 return 1
570 fi
571
572 egrep '<!-- head -->' ${HTML}.tmp >/dev/null 2>&1
573 if [ $? -ne 0 ]; then
574 [ -z "$verbose" ] || log_msg_fail "head.html";
575 return 1
576 fi
577 egrep '<!-- ehead -->' ${HTML}.tmp >/dev/null 2>&1
578 if [ $? -ne 0 ]; then
579 [ -z "$verbose" ] || log_msg_fail "end head.html";
580 return 1
581 fi
582
583 egrep '<!-- entry -->' ${HTML}.tmp >/dev/null 2>&1
584 if [ $? -ne 0 ]; then
585 [ -z "$verbose" ] || log_msg_fail "entry.html";
586 return 1
587 fi
588 egrep '<!-- eentry -->' ${HTML}.tmp >/dev/null 2>&1
589 if [ $? -ne 0 ]; then
590 [ -z "$verbose" ] || log_msg_fail "end entry.html";
591 return 1
592 fi
593
594 egrep '<!-- foot -->' ${HTML}.tmp >/dev/null 2>&1
595 if [ $? -ne 0 ]; then
596 [ -z "$verbose" ] || log_msg_fail "foot.html";
597 return 1
598 fi
599 egrep '<!-- efoot -->' ${HTML}.tmp >/dev/null 2>&1
600 if [ $? -ne 0 ]; then
601 [ -z "$verbose" ] || log_msg_fail "end foot.html";
602 return 1
603 fi
604
605 [ -z "$VALGRIND" ] || {
606 tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
607 if [ $tmp -ne 0 ]; then
608 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
609 cat test_log_valgrind
610 return 1;
611 fi;
612 }
613
614 rm ${HTML}.tmp
615
616 return 0
617}
618
619
620testrun2_internal ()
621{
622 [ -z "$verbose" ] || {
623 echo;
624 echo Working directory: $PW_DIR; echo MAKE is $MAKE;
625 echo;
626 }
627 #
628 #
629 [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; }
630 #
631 if test -r "Makefile"; then
632 $MAKE distclean
633 fi
634 #
635 ${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
636 #
637 if test x$? = x0; then
638 [ -z "$verbose" ] || log_msg_ok "configure...";
639 $MAKE > /dev/null 2>>test_log
640 if test x$? = x0; then
641 [ -z "$verbose" ] || log_msg_ok "make...";
642 else
643 [ -z "$quiet" ] && log_msg_fail "make...";
644 return 1
645 fi
646
647 else
648 [ -z "$quiet" ] && log_msg_fail "configure...";
649 return 1
650 fi
651
652 # save binary and build server2
653 #
654 cp samhain samhain.build || return 1
655 $MAKE clean >/dev/null || return 1
656
657 ${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
658 #
659 if test x$? = x0; then
660 [ -z "$verbose" ] || log_msg_ok "configure...";
661 $MAKE > /dev/null 2>>test_log
662 if test x$? = x0; then
663 [ -z "$verbose" ] || log_msg_ok "make...";
664 else
665 [ -z "$quiet" ] && log_msg_fail "make...";
666 return 1
667 fi
668
669 else
670 [ -z "$quiet" ] && log_msg_fail "configure...";
671 return 1
672 fi
673
674 # save binary and build server
675 #
676 cp yule yule.2 || return 1
677 $MAKE clean >/dev/null || return 1
678
679 ${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
680 #
681 if test x$? = x0; then
682 [ -z "$verbose" ] || log_msg_ok "configure...";
683 $MAKE > /dev/null 2>>test_log
684 if test x$? = x0; then
685 [ -z "$verbose" ] || log_msg_ok "make...";
686 else
687 [ -z "$quiet" ] && log_msg_fail "make...";
688 return 1
689 fi
690
691 else
692 [ -z "$quiet" ] && log_msg_fail "configure...";
693 return 1
694 fi
695
696
697 #####################################################################
698 #
699 #
700 rm -f ./.samhain_file
701 rm -f ./.samhain_log
702 rm -f ./.samhain_lock
703
704 cp ${SCRIPTDIR}/testrc_2.in testrc_2
705
706 ./samhain.build -t init -p none
707
708 if test x$? = x0; then
709 [ -z "$verbose" ] || log_msg_ok "init...";
710 else
711 [ -z "$quiet" ] && log_msg_fail "init...";
712 return 1
713 fi
714
715 # Create a password
716
717 SHPW=`./yule -G`
718 if test x"$SHPW" = x; then
719 [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting"
720 return 1
721 fi
722
723 # Set in client
724
725 ./samhain_setpwd samhain.build new $SHPW >/dev/null
726
727 if test x$? = x0; then
728 [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd samhain.build new $SHPW";
729 else
730 [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd samhain.build new $SHPW";
731 return 1
732 fi
733
734 mv samhain.build.new samhain.new || return 1
735
736 # Set in server
737
738 ./samhain_setpwd yule new $SHPW >/dev/null
739
740 if test x$? = x0; then
741 [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd yule new $SHPW";
742 else
743 [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd yule new $SHPW";
744 return 1
745 fi
746
747 mv yule.new yule || return 1
748
749 #
750
751 rm -f ./.samhain_log*
752 rm -f ./.samhain_lock*
753
754 SHCLT=`./yule -P $SHPW`
755
756 if test x$? = x0; then
757 [ -z "$verbose" ] || log_msg_ok "yule -P $SHPW";
758 else
759 [ -z "$quiet" ] && log_msg_fail "yule -P $SHPW";
760 return 1
761 fi
762
763 SHCLT1=`echo "${SHCLT}" | sed s%HOSTNAME%${SH_LOCALHOST}%`
764 AHOST=`find_hostname`
765 SHCLT2=`echo "${SHCLT}" | sed s%HOSTNAME%${AHOST}%`
766
767
768 echo $SHCLT1 >> testrc_2
769 echo $SHCLT2 >> testrc_2
770 cp testrc_2 testrc_22
771
772 do_test_1
773 if [ $? -eq 0 ]; then
774 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client logging";
775 else
776 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client logging";
777 fi
778
779 do_test_2
780 if [ $? -eq 0 ]; then
781 [ -z "$quiet" ] && log_ok 2 ${MAXTEST} "Client logging, separate logfiles";
782 else
783 [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "Client logging, separate logfiles";
784 fi
785
786 do_test_3
787 if [ $? -eq 0 ]; then
788 [ -z "$quiet" ] && log_ok 3 ${MAXTEST} "Dead client detection";
789 else
790 [ -z "$quiet" ] && log_fail 3 ${MAXTEST} "Dead client detection";
791 fi
792
793 do_test_4
794 if [ $? -eq 0 ]; then
795 [ -z "$quiet" ] && log_ok 4 ${MAXTEST} "Server command socket";
796 else
797 [ -z "$quiet" ] && log_fail 4 ${MAXTEST} "Server command socket";
798 fi
799
800 do_test_5
801 if [ $? -eq 0 ]; then
802 [ -z "$quiet" ] && log_ok 5 ${MAXTEST} "Server status file";
803 else
804 [ -z "$quiet" ] && log_fail 5 ${MAXTEST} "Server status file";
805 fi
806
807 return $?
808}
809
810MAXTEST=5; export MAXTEST
811
812testrun2 ()
813{
814 log_start "RUN CLIENT/SERVER"
815
816 if [ x"$1" = x ]; then
817 [ -z "$quiet" ] && log_msg_fail "Missing hostname"
818 fi
819 #
820 SH_LOCALHOST=$1; export SH_LOCALHOST
821 #
822 testrun2_internal
823 #
824 log_end "RUN CLIENT/SERVER"
825
826 return 0
827}
828
Note: See TracBrowser for help on using the repository browser.