source: trunk/test/testrun_2.sh@ 581

Last change on this file since 581 was 501, checked in by katerina, 9 years ago

Fix for ticket #397 (regression in sh_static.c).

File size: 20.0 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;
[369]256 echo "${S}Start Server${E}: ./yule -p none -e none &";
[19]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;
[369]269 echo "${S}Start Client${E}: ./samhain.new -t check -p none -l none --forever --bind-address=127.0.0.1 &";
[19]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 kill $PROC_Y
[51]294 five_sec_sleep
[19]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
[22]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 }
[19]330
[22]331 rm -f ${LOGFILE}
[19]332 return 0
333}
334
[22]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
[51]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
[22]347
348 ORIGINAL_1="SetSocketAllowUid=0"
349 REPLACEMENT_1="SetSocketAllowUid=$me"
[51]350 ex -s $RCFILE <<EOF
[30]351%s/${ORIGINAL_1}/${REPLACEMENT_1}/g
352wq
[22]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
[27]364 ${VALGRIND} ./yule -l info -p none -e none \
365 >/dev/null 2>>test_log_valgrind &
[22]366 PROC_Y=$!
[51]367 five_sec_sleep
[22]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}
[51]450 one_sec_sleep
451 one_sec_sleep
[30]452 kill -9 ${PROC_Y} >/dev/null 2>&1
[22]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
[27]503 ${VALGRIND} ./yule -l info -p none -e none \
504 >/dev/null 2>>test_log_valgrind &
[22]505 PROC_Y=$!
[51]506 five_sec_sleep
[22]507
508 egrep '<!-- head -->' $HTML >/dev/null 2>&1
509 if [ $? -ne 0 ]; then
[27]510 # rm -f head.html; rm -f foot.html; rm -f entry.html;
[22]511 kill $PROC_Y
[27]512 [ -z "$verbose" ] || log_msg_fail "head.html (1)";
[22]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
[27]520 [ -z "$verbose" ] || log_msg_fail "foot.html (1)";
[22]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
[415]539 cp $HTML ${HTML}.tmp
540
[22]541 kill $PROC_Y
[51]542 five_sec_sleep
[22]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
[415]572 egrep '<!-- head -->' ${HTML}.tmp >/dev/null 2>&1
[22]573 if [ $? -ne 0 ]; then
574 [ -z "$verbose" ] || log_msg_fail "head.html";
575 return 1
576 fi
[415]577 egrep '<!-- ehead -->' ${HTML}.tmp >/dev/null 2>&1
[22]578 if [ $? -ne 0 ]; then
[27]579 [ -z "$verbose" ] || log_msg_fail "end head.html";
[22]580 return 1
581 fi
582
[415]583 egrep '<!-- entry -->' ${HTML}.tmp >/dev/null 2>&1
[22]584 if [ $? -ne 0 ]; then
585 [ -z "$verbose" ] || log_msg_fail "entry.html";
586 return 1
587 fi
[415]588 egrep '<!-- eentry -->' ${HTML}.tmp >/dev/null 2>&1
[22]589 if [ $? -ne 0 ]; then
[27]590 [ -z "$verbose" ] || log_msg_fail "end entry.html";
[22]591 return 1
592 fi
593
[415]594 egrep '<!-- foot -->' ${HTML}.tmp >/dev/null 2>&1
[22]595 if [ $? -ne 0 ]; then
596 [ -z "$verbose" ] || log_msg_fail "foot.html";
597 return 1
598 fi
[415]599 egrep '<!-- efoot -->' ${HTML}.tmp >/dev/null 2>&1
[22]600 if [ $? -ne 0 ]; then
[27]601 [ -z "$verbose" ] || log_msg_fail "end foot.html";
[22]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
[415]614 rm ${HTML}.tmp
615
[22]616 return 0
617}
618
619
[19]620testrun2_internal ()
[1]621{
[19]622 [ -z "$verbose" ] || {
623 echo;
624 echo Working directory: $PW_DIR; echo MAKE is $MAKE;
625 echo;
626 }
[1]627 #
628 #
[19]629 [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; }
[1]630 #
631 if test -r "Makefile"; then
632 $MAKE distclean
633 fi
634 #
[501]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 --enable-static
[1]636 #
637 if test x$? = x0; then
[19]638 [ -z "$verbose" ] || log_msg_ok "configure...";
639 $MAKE > /dev/null 2>>test_log
[1]640 if test x$? = x0; then
[19]641 [ -z "$verbose" ] || log_msg_ok "make...";
[1]642 else
[19]643 [ -z "$quiet" ] && log_msg_fail "make...";
644 return 1
[1]645 fi
646
647 else
[19]648 [ -z "$quiet" ] && log_msg_fail "configure...";
649 return 1
[1]650 fi
651
[27]652 # save binary and build server2
[1]653 #
[19]654 cp samhain samhain.build || return 1
[30]655 $MAKE clean >/dev/null || return 1
[1]656
[27]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
[1]658 #
659 if test x$? = x0; then
[19]660 [ -z "$verbose" ] || log_msg_ok "configure...";
661 $MAKE > /dev/null 2>>test_log
[1]662 if test x$? = x0; then
[19]663 [ -z "$verbose" ] || log_msg_ok "make...";
[1]664 else
[19]665 [ -z "$quiet" ] && log_msg_fail "make...";
666 return 1
[1]667 fi
668
669 else
[19]670 [ -z "$quiet" ] && log_msg_fail "configure...";
671 return 1
[1]672 fi
673
[27]674 # save binary and build server
675 #
676 cp yule yule.2 || return 1
[30]677 $MAKE clean >/dev/null || return 1
[19]678
[27]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
[1]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
[19]706 ./samhain.build -t init -p none
[1]707
[19]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
[1]714
715 # Create a password
716
717 SHPW=`./yule -G`
718 if test x"$SHPW" = x; then
[19]719 [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting"
720 return 1
[1]721 fi
722
723 # Set in client
724
[19]725 ./samhain_setpwd samhain.build new $SHPW >/dev/null
[1]726
[19]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
[1]733
[19]734 mv samhain.build.new samhain.new || return 1
735
[27]736 # Set in server
[1]737
[27]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
[29]754 SHCLT=`./yule -P $SHPW`
[1]755
[19]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
[29]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
[27]770 cp testrc_2 testrc_22
[1]771
[19]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
[1]778
[19]779 do_test_2
780 if [ $? -eq 0 ]; then
[22]781 [ -z "$quiet" ] && log_ok 2 ${MAXTEST} "Client logging, separate logfiles";
[19]782 else
[22]783 [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "Client logging, separate logfiles";
[19]784 fi
[1]785
[19]786 do_test_3
787 if [ $? -eq 0 ]; then
788 [ -z "$quiet" ] && log_ok 3 ${MAXTEST} "Dead client detection";
[1]789 else
[19]790 [ -z "$quiet" ] && log_fail 3 ${MAXTEST} "Dead client detection";
[1]791 fi
[19]792
[22]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
[19]807 return $?
[1]808}
809
[22]810MAXTEST=5; export MAXTEST
[19]811
812testrun2 ()
813{
814 log_start "RUN CLIENT/SERVER"
815
816 if [ x"$1" = x ]; then
817 [ -z "$quiet" ] && log_msg_fail "Missing hostname"
[1]818 fi
[19]819 #
[1]820 SH_LOCALHOST=$1; export SH_LOCALHOST
[19]821 #
822 testrun2_internal
823 #
824 log_end "RUN CLIENT/SERVER"
[1]825
[19]826 return 0
827}
[1]828
Note: See TracBrowser for help on using the repository browser.