source: trunk/test/testrun_2.sh@ 414

Last change on this file since 414 was 369, checked in by katerina, 13 years ago

Fix bug in sh_inotify_read().

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;
[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
539 kill $PROC_Y
[51]540 five_sec_sleep
[22]541
542 # rm -f head.html; rm -f foot.html; rm -f entry.html;
543
544 egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
545 if [ $? -ne 0 ]; then
546 [ -z "$verbose" ] || log_msg_fail "Server start";
547 return 1
548 fi
549 egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1
550 if [ $? -ne 0 ]; then
551 [ -z "$verbose" ] || log_msg_fail "Client connect";
552 return 1
553 fi
554 egrep "remote_host.*Checking.*/bin" $LOGFILE >/dev/null 2>&1
555 if [ $? -ne 0 ]; then
556 [ -z "$verbose" ] || log_msg_fail "Client file check";
557 return 1
558 fi
559 egrep "remote_host.*EXIT.*Samhain" $LOGFILE >/dev/null 2>&1
560 if [ $? -ne 0 ]; then
561 [ -z "$verbose" ] || log_msg_fail "Client exit";
562 return 1
563 fi
564 egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1
565 if [ $? -ne 0 ]; then
566 [ -z "$verbose" ] || log_msg_fail "Server exit";
567 return 1
568 fi
569
570 egrep '<!-- head -->' $HTML >/dev/null 2>&1
571 if [ $? -ne 0 ]; then
572 [ -z "$verbose" ] || log_msg_fail "head.html";
573 return 1
574 fi
575 egrep '<!-- ehead -->' $HTML >/dev/null 2>&1
576 if [ $? -ne 0 ]; then
[27]577 [ -z "$verbose" ] || log_msg_fail "end head.html";
[22]578 return 1
579 fi
580
581 egrep '<!-- entry -->' $HTML >/dev/null 2>&1
582 if [ $? -ne 0 ]; then
583 [ -z "$verbose" ] || log_msg_fail "entry.html";
584 return 1
585 fi
586 egrep '<!-- eentry -->' $HTML >/dev/null 2>&1
587 if [ $? -ne 0 ]; then
[27]588 [ -z "$verbose" ] || log_msg_fail "end entry.html";
[22]589 return 1
590 fi
591
592 egrep '<!-- foot -->' $HTML >/dev/null 2>&1
593 if [ $? -ne 0 ]; then
594 [ -z "$verbose" ] || log_msg_fail "foot.html";
595 return 1
596 fi
597 egrep '<!-- efoot -->' $HTML >/dev/null 2>&1
598 if [ $? -ne 0 ]; then
[27]599 [ -z "$verbose" ] || log_msg_fail "end foot.html";
[22]600 return 1
601 fi
602
603 [ -z "$VALGRIND" ] || {
604 tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
605 if [ $tmp -ne 0 ]; then
606 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
607 cat test_log_valgrind
608 return 1;
609 fi;
610 }
611
612 return 0
613}
614
615
[19]616testrun2_internal ()
[1]617{
[19]618 [ -z "$verbose" ] || {
619 echo;
620 echo Working directory: $PW_DIR; echo MAKE is $MAKE;
621 echo;
622 }
[1]623 #
624 #
[19]625 [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; }
[1]626 #
627 if test -r "Makefile"; then
628 $MAKE distclean
629 fi
630 #
[19]631 ${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]632 #
633 if test x$? = x0; then
[19]634 [ -z "$verbose" ] || log_msg_ok "configure...";
635 $MAKE > /dev/null 2>>test_log
[1]636 if test x$? = x0; then
[19]637 [ -z "$verbose" ] || log_msg_ok "make...";
[1]638 else
[19]639 [ -z "$quiet" ] && log_msg_fail "make...";
640 return 1
[1]641 fi
642
643 else
[19]644 [ -z "$quiet" ] && log_msg_fail "configure...";
645 return 1
[1]646 fi
647
[27]648 # save binary and build server2
[1]649 #
[19]650 cp samhain samhain.build || return 1
[30]651 $MAKE clean >/dev/null || return 1
[1]652
[27]653 ${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]654 #
655 if test x$? = x0; then
[19]656 [ -z "$verbose" ] || log_msg_ok "configure...";
657 $MAKE > /dev/null 2>>test_log
[1]658 if test x$? = x0; then
[19]659 [ -z "$verbose" ] || log_msg_ok "make...";
[1]660 else
[19]661 [ -z "$quiet" ] && log_msg_fail "make...";
662 return 1
[1]663 fi
664
665 else
[19]666 [ -z "$quiet" ] && log_msg_fail "configure...";
667 return 1
[1]668 fi
669
[27]670 # save binary and build server
671 #
672 cp yule yule.2 || return 1
[30]673 $MAKE clean >/dev/null || return 1
[19]674
[27]675 ${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
676 #
677 if test x$? = x0; then
678 [ -z "$verbose" ] || log_msg_ok "configure...";
679 $MAKE > /dev/null 2>>test_log
680 if test x$? = x0; then
681 [ -z "$verbose" ] || log_msg_ok "make...";
682 else
683 [ -z "$quiet" ] && log_msg_fail "make...";
684 return 1
685 fi
686
687 else
688 [ -z "$quiet" ] && log_msg_fail "configure...";
689 return 1
690 fi
691
692
[1]693 #####################################################################
694 #
695 #
696 rm -f ./.samhain_file
697 rm -f ./.samhain_log
698 rm -f ./.samhain_lock
699
700 cp ${SCRIPTDIR}/testrc_2.in testrc_2
701
[19]702 ./samhain.build -t init -p none
[1]703
[19]704 if test x$? = x0; then
705 [ -z "$verbose" ] || log_msg_ok "init...";
706 else
707 [ -z "$quiet" ] && log_msg_fail "init...";
708 return 1
709 fi
[1]710
711 # Create a password
712
713 SHPW=`./yule -G`
714 if test x"$SHPW" = x; then
[19]715 [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting"
716 return 1
[1]717 fi
718
719 # Set in client
720
[19]721 ./samhain_setpwd samhain.build new $SHPW >/dev/null
[1]722
[19]723 if test x$? = x0; then
724 [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd samhain.build new $SHPW";
725 else
726 [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd samhain.build new $SHPW";
727 return 1
728 fi
[1]729
[19]730 mv samhain.build.new samhain.new || return 1
731
[27]732 # Set in server
[1]733
[27]734 ./samhain_setpwd yule new $SHPW >/dev/null
735
736 if test x$? = x0; then
737 [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd yule new $SHPW";
738 else
739 [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd yule new $SHPW";
740 return 1
741 fi
742
743 mv yule.new yule || return 1
744
745 #
746
747 rm -f ./.samhain_log*
748 rm -f ./.samhain_lock*
749
[29]750 SHCLT=`./yule -P $SHPW`
[1]751
[19]752 if test x$? = x0; then
753 [ -z "$verbose" ] || log_msg_ok "yule -P $SHPW";
754 else
755 [ -z "$quiet" ] && log_msg_fail "yule -P $SHPW";
756 return 1
757 fi
758
[29]759 SHCLT1=`echo "${SHCLT}" | sed s%HOSTNAME%${SH_LOCALHOST}%`
760 AHOST=`find_hostname`
761 SHCLT2=`echo "${SHCLT}" | sed s%HOSTNAME%${AHOST}%`
762
763
764 echo $SHCLT1 >> testrc_2
765 echo $SHCLT2 >> testrc_2
[27]766 cp testrc_2 testrc_22
[1]767
[19]768 do_test_1
769 if [ $? -eq 0 ]; then
770 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client logging";
771 else
772 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client logging";
773 fi
[1]774
[19]775 do_test_2
776 if [ $? -eq 0 ]; then
[22]777 [ -z "$quiet" ] && log_ok 2 ${MAXTEST} "Client logging, separate logfiles";
[19]778 else
[22]779 [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "Client logging, separate logfiles";
[19]780 fi
[1]781
[19]782 do_test_3
783 if [ $? -eq 0 ]; then
784 [ -z "$quiet" ] && log_ok 3 ${MAXTEST} "Dead client detection";
[1]785 else
[19]786 [ -z "$quiet" ] && log_fail 3 ${MAXTEST} "Dead client detection";
[1]787 fi
[19]788
[22]789 do_test_4
790 if [ $? -eq 0 ]; then
791 [ -z "$quiet" ] && log_ok 4 ${MAXTEST} "Server command socket";
792 else
793 [ -z "$quiet" ] && log_fail 4 ${MAXTEST} "Server command socket";
794 fi
795
796 do_test_5
797 if [ $? -eq 0 ]; then
798 [ -z "$quiet" ] && log_ok 5 ${MAXTEST} "Server status file";
799 else
800 [ -z "$quiet" ] && log_fail 5 ${MAXTEST} "Server status file";
801 fi
802
[19]803 return $?
[1]804}
805
[22]806MAXTEST=5; export MAXTEST
[19]807
808testrun2 ()
809{
810 log_start "RUN CLIENT/SERVER"
811
812 if [ x"$1" = x ]; then
813 [ -z "$quiet" ] && log_msg_fail "Missing hostname"
[1]814 fi
[19]815 #
[1]816 SH_LOCALHOST=$1; export SH_LOCALHOST
[19]817 #
818 testrun2_internal
819 #
820 log_end "RUN CLIENT/SERVER"
[1]821
[19]822 return 0
823}
[1]824
Note: See TracBrowser for help on using the repository browser.