source: trunk/test/testrun_2.sh@ 201

Last change on this file since 201 was 51, checked in by rainer, 18 years ago

Fix problems with linux kernel 2.6.17

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