source: trunk/test/testrun_2g.sh@ 580

Last change on this file since 580 was 577, checked in by katerina, 3 years ago

Implement ticket #465 (server option to register alias for hostname).

  • Property svn:executable set to *
File size: 22.0 KB
RevLine 
[550]1#! /bin/sh
2
3#
4# Copyright Rainer Wichmann (2015)
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
24
25SERVER_BUILDOPTS="--quiet $TRUST --enable-network=server --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=${SH_LOCALHOST} --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --enable-debug=gdb --enable-static"; export SERVER_BUILDOPTS
26
27CLIENT_BUILDOPTS="--quiet $TRUST --enable-network=client --enable-srp --prefix=$PW_DIR --with-tmp-dir=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$RCFILE --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --enable-static"; export CLIENT_BUILDOPTS
28
29TEST_DIRS="one two three four"
30TEST_FILES="change leave rmthis"
31BASE="/tmp/testrun_samhain"
32
33TEST_LIST="./tmp_list_file"
34
35ALTHOST=`find_hostname`
36
37PROC_S=0; export PROC_S
38PROC_Y=0; export PROC_Y
39
40mod_files ()
41{
42 rm -f "${TEST_LIST}"
43 touch "${TEST_LIST}"
44 #
45 for dd in ${TEST_DIRS}; do
46 echo "changed" > "${BASE}/$dd/change"
47 rm -f "${BASE}/$dd/rmthis"
48 echo "added" > "${BASE}/$dd/addedthis"
49 echo "${BASE}/$dd" >> "${TEST_LIST}"
50 echo "${BASE}/$dd/change" >> "${TEST_LIST}"
51 echo "${BASE}/$dd/rmthis" >> "${TEST_LIST}"
52 echo "${BASE}/$dd/addedthis" >> "${TEST_LIST}"
53 done
54}
55
56do_test_2_g_yule_start () {
57
58 [ -z "$verbose" ] || {
59 echo;
60 echo "${S}Start Server${E}: ./yule -l info -p none &";
61 echo;
62 }
63 rm -f test_log_valgrind
64
65 # SetSocketAllowUid=$(id -u)
66 #
67 if test -f /usr/xpg4/bin/id; then
68 MY_ID=$(/usr/xpg4/bin/id -u)
69 else
70 MY_ID=$(id -u)
71 fi
72 #
73 sed -i -e "s/SetSocketAllowUid=0/SetSocketAllowUid=${MY_ID}/g" $RCFILE
74
75 # Start server
76 #
77 ${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind &
78 PROC_Y=$!
79 five_sec_sleep
80
81
82 [ -z "$verbose" ] || {
83 echo;
84 echo "${S}Start Client${E}: ./samhain.new -t check -D .. &";
85 echo;
86 }
87 ${VALGRIND} ./samhain.new -t check -D -p none -l none -e info --bind-address=127.0.0.1 --server-host=localhost >/dev/null 2>>test_log_valgrind
88 if test x$? = x0; then
89 [ -z "$verbose" ] || log_msg_ok "starting samhain.new";
90 else
91 [ -z "$quiet" ] && log_msg_fail "starting samhain.new";
92 kill $PROC_Y
93 return 1
94 fi
95 five_sec_sleep
96 PROC_S=$( ps aux | grep samhain.new | grep -v grep | awk '{ print $2; }' | sort | head -n 1 )
97
98 for ff in 1 2; do
99 five_sec_sleep
100 done
101 egrep "File check completed" $LOGFILE >/dev/null 2>&1
102 if [ $? -ne 0 ]; then
103 [ -z "$verbose" ] || log_msg_fail "Client file check";
104 kill $PROC_S; kill $PROC_Y;
105 return 1
106 fi
107 NR=$( egrep "File check completed" $LOGFILE | wc -l )
108 if [ $NR -ne 1 ]; then
109 [ -z "$verbose" ] || log_msg_fail "Client file check (1)";
110 kill $PROC_S; kill $PROC_Y;
111 return 1
112 fi
113
114 return 0
115}
116
117do_test_2_g_two () {
118
119 #
120 # >>> Modify files
121 #
122 mod_files
123 #
124 if ! test -f ${TEST_LIST}; then
125 [ -z "$verbose" ] || log_msg_fail "No file list created";
126 kill $PROC_S; kill $PROC_Y;
127 return 1
128 fi
129 #
130 #
131 # >>> Trigger a scan
132 #
133 kill -TTOU $PROC_S
134 if [ $? -ne 0 ]; then
135 [ -z "$verbose" ] || log_msg_fail "Kill -TTOU";
136 kill $PROC_S; kill $PROC_Y;
137 return 1
138 fi
139
140 for ff in 1 2 3; do
141 five_sec_sleep
142 done
143 NR=$( egrep "File check completed" $LOGFILE | wc -l )
144 if [ $NR -ne 2 ]; then
145 [ -z "$verbose" ] || log_msg_fail "Client file check (2)";
146 kill $PROC_S; kill $PROC_Y;
147 return 1
148 fi
149 [ -z "$verbose" ] || log_msg_ok "sigttou";
150
151 NR=$( egrep "POLICY" $LOGFILE | grep ReadOnly | wc -l )
152 if [ $NR -ne 8 ]; then
153 [ -z "$verbose" ] || log_msg_fail "Client file check (ReadOnly)";
154 kill $PROC_S; kill $PROC_Y;
155 return 1
156 fi
157 NR=$( egrep "POLICY" $LOGFILE | grep ADDED | wc -l )
158 if [ $NR -ne 4 ]; then
159 [ -z "$verbose" ] || log_msg_fail "Client file check (added)";
160 kill $PROC_S; kill $PROC_Y;
161 return 1
162 fi
163 NR=$( egrep "POLICY" $LOGFILE | grep MISSING | wc -l )
164 if [ $NR -ne 4 ]; then
165 [ -z "$verbose" ] || log_msg_fail "Client file check (removed)";
166 kill $PROC_S; kill $PROC_Y;
167 return 1
168 fi
169
170 kill $PROC_S;
171 kill $PROC_Y;
172 return 0
173}
174
175do_test_2_g_one () {
176
177 #
178 # >>> (1) Modify files, create DeltaDB from file list in ${TEST_LIST}
179 #
180 mod_files
181 #
182 if ! test -f ${TEST_LIST}; then
183 [ -z "$verbose" ] || log_msg_fail "No file list created";
184 kill $PROC_S; kill $PROC_Y;
185 return 1
186 fi
187 #
188 ./samhain.new --outfile ./file.delta --create-database "${TEST_LIST}"
189 #
190 if [ $? -ne 0 ]; then
191 [ -z "$verbose" ] || log_msg_fail "Create DeltaDB";
192 kill $PROC_S; kill $PROC_Y;
193 return 1
194 fi
195 if ! test -f ./file.delta; then
196 [ -z "$verbose" ] || log_msg_fail "No DeltaDB created";
197 kill $PROC_S; kill $PROC_Y;
198 return 1
199 fi
200
201 #
202 # >>> (2) Copy to server and tag with a UUID
203 #
204 UUID=$(uuidgen)
205 mv ./file.delta file.${SH_LOCALHOST}.${UUID}
[577]206 if [ "x${SH_LOCALHOST}" != "x${ALTHOST}" ]
207 then
208 cp file.${SH_LOCALHOST}.${UUID} "./file.${ALTHOST}.${UUID}"
209 fi
[550]210
211 #
212 # >>> (3) Tell client to load delta database.
213 # >>> testrc_2: timestamps every 10 sec
214 #
215 grep '^SetLoopTime=10$' rc.${SH_LOCALHOST} >/dev/null 2>&1
216 if [ $? -ne 0 ]; then
217 [ -z "$verbose" ] || log_msg_fail "SetLoopTime != 10 in rc.${SH_LOCALHOST}";
218 kill $PROC_S; kill $PROC_Y;
219 return 1
220 fi
221 grep '^SetLoopTime=10$' rc.${ALTHOST} >/dev/null 2>&1
222 if [ $? -ne 0 ]; then
223 [ -z "$verbose" ] || log_msg_fail "SetLoopTime != 10 in rc.${ALTHOST}";
224 kill $PROC_S; kill $PROC_Y;
225 return 1
226 fi
227
[577]228 NHOSTS=1
229
[550]230 ./yulectl -c "DELTA:${UUID}" ${SH_LOCALHOST}
231 if [ $? -ne 0 ]; then
232 [ -z "$verbose" ] || log_msg_fail "yulectl (1)";
233 kill $PROC_S; kill $PROC_Y;
234 return 1
235 fi
[577]236
237 if [ "x${SH_LOCALHOST}" != "x${ALTHOST}" ]
238 then
239 ./yulectl -c "DELTA:${UUID}" ${ALTHOST}
240 NHOSTS=2
241 if [ $? -ne 0 ]; then
242 [ -z "$verbose" ] || log_msg_fail "yulectl (2)";
243 kill $PROC_S; kill $PROC_Y;
244 return 1
245 fi
[550]246 fi
[577]247
[550]248 NR=$( ./yulectl -c LIST | grep ${UUID} | grep -v grep | wc -l )
[577]249 if [ $NR -ne $NHOSTS ]; then
[550]250 [ -z "$verbose" ] || log_msg_fail "yulectl (3)";
251 [ -z "$verbose" ] || ./yulectl -c LIST
252 kill $PROC_S; kill $PROC_Y;
253 return 1
254 fi
255
256 # Wait and verify that command has been sent
257 #
258 for tt in 1 2 3 4; do
259 five_sec_sleep
260 done
261 #
[577]262 NR=$( ./yulectl -c LISTALL | grep ${UUID} | grep SENT | grep -v grep | wc -l )
263 # NR=$( ./yulectl -c LIST | grep ${UUID} | grep -v grep | wc -l )
[550]264 if [ $NR -ne 1 ]; then
265 [ -z "$verbose" ] || log_msg_fail "yulectl (4)";
266 [ -z "$verbose" ] || ./yulectl -c LISTALL
267 kill $PROC_S; kill $PROC_Y;
268 return 1
269 fi
270
271 #
272 # >>> (4) Trigger a scan
273 #
274 kill -TTOU $PROC_S
275 if [ $? -ne 0 ]; then
276 [ -z "$verbose" ] || log_msg_fail "Kill -TTOU";
277 kill $PROC_S; kill $PROC_Y;
278 return 1
279 fi
280
281 for ff in 1 2; do
282 five_sec_sleep
283 done
284 NR=$( egrep "File check completed" $LOGFILE | wc -l )
285 if [ $NR -ne 2 ]; then
286 [ -z "$verbose" ] || log_msg_fail "Client file check (2)";
287 kill $PROC_S; kill $PROC_Y;
288 return 1
289 fi
290 [ -z "$verbose" ] || log_msg_ok "sigttou";
291
292 NR=$( egrep "POLICY" $LOGFILE | wc -l )
293 if [ $NR -ne 0 ]; then
294 [ -z "$verbose" ] || log_msg_fail "Client file check (3)";
295 kill $PROC_S; kill $PROC_Y;
296 return 1
297 fi
298
299 # --- The End ---
300
301 kill $PROC_S;
302 kill $PROC_Y
303 return 0
304}
305
306do_test_2_g_three () {
307
308 #
309 # >>> (1) Modify files, create DeltaDB from file list in ${TEST_LIST}
310 #
311 mod_files
312 #
313 if ! test -f ${TEST_LIST}; then
314 [ -z "$verbose" ] || log_msg_fail "No file list created";
315 kill $PROC_S; kill $PROC_Y;
316 return 1
317 fi
318 #
319 ./samhain.new --outfile ./file.delta --create-database "${TEST_LIST}"
320 #
321 if [ $? -ne 0 ]; then
322 [ -z "$verbose" ] || log_msg_fail "Create DeltaDB";
323 kill $PROC_S; kill $PROC_Y;
324 return 1
325 fi
326 if ! test -f ./file.delta; then
327 [ -z "$verbose" ] || log_msg_fail "No DeltaDB created";
328 kill $PROC_S; kill $PROC_Y;
329 return 1
330 fi
331 [ -z "$verbose" ] || log_msg_ok "... DeltaDB created ...";
332
333 #
334 # >>> (2) Copy to server and tag with a UUID
335 #
336 UUID=$(uuidgen)
337 if [ x"$1" != "xnosig" ]; then
338 scripts/samhainadmin.pl -s ./test/gnupg/ -k 8A0B337A -m E ./file.delta >/dev/null
339 fi
340 if [ x"$1" == "xnodelta" ]; then
341 rm -f ./file.*
342 else
343 mv ./file.delta file.${SH_LOCALHOST}.${UUID}
[577]344 if [ "x${SH_LOCALHOST}" != "x${ALTHOST}" ]
345 then
346 cp file.${SH_LOCALHOST}.${UUID} "./file.${ALTHOST}.${UUID}"
347 fi
[550]348 fi
349 [ -z "$verbose" ] || log_msg_ok "... DeltaDB copied as file.${SH_LOCALHOST}.${UUID} ...";
350
351 #
352 # >>> (3) Tell client to load delta database.
353 # >>> testrc_2: timestamps every 10 sec
354 #
355 grep '^SetLoopTime=10$' rc.${SH_LOCALHOST} >/dev/null 2>&1
356 if [ $? -ne 0 ]; then
357 [ -z "$verbose" ] || log_msg_fail "SetLoopTime != 10 in rc.${SH_LOCALHOST}";
358 kill $PROC_S; kill $PROC_Y;
359 return 1
360 fi
361 grep '^SetLoopTime=10$' rc.${ALTHOST} >/dev/null 2>&1
362 if [ $? -ne 0 ]; then
363 [ -z "$verbose" ] || log_msg_fail "SetLoopTime != 10 in rc.${ALTHOST}";
364 kill $PROC_S; kill $PROC_Y;
365 return 1
366 fi
367
[577]368 NHOSTS=1
369
[550]370 ./yulectl -c "DELTA:${UUID}" ${SH_LOCALHOST}
371 if [ $? -ne 0 ]; then
372 [ -z "$verbose" ] || log_msg_fail "yulectl (1)";
373 kill $PROC_S; kill $PROC_Y;
374 return 1
375 fi
[577]376
377 if [ "x${SH_LOCALHOST}" != "x${ALTHOST}" ]
378 then
379 ./yulectl -c "DELTA:${UUID}" ${ALTHOST}
380 NHOSTS=2
381 if [ $? -ne 0 ]; then
382 [ -z "$verbose" ] || log_msg_fail "yulectl (2)";
383 kill $PROC_S; kill $PROC_Y;
384 return 1
385 fi
[550]386 fi
[577]387
[550]388 NR=$( ./yulectl -c LIST | grep ${UUID} | grep -v grep | wc -l )
[577]389 if [ $NR -ne $NHOSTS ]; then
[550]390 [ -z "$verbose" ] || log_msg_fail "yulectl (3)";
391 [ -z "$verbose" ] || ./yulectl -c LIST
392 kill $PROC_S; kill $PROC_Y;
393 return 1
394 fi
395 [ -z "$verbose" ] || log_msg_ok "... command sent to client ...";
396
397 # Wait and verify that command has been sent
398 #
399 for tt in 1 2 3 4; do
400 five_sec_sleep
401 done
402 #
[577]403 NR=$( ./yulectl -c LISTALL | grep ${UUID} | grep SENT | grep -v grep | wc -l )
[550]404 if [ $NR -ne 1 ]; then
[577]405 [ -z "$verbose" ] || log_msg_fail "yulectl (4): ${UUID}";
[550]406 [ -z "$verbose" ] || ./yulectl -c LISTALL
[577]407 [ -z "$verbose" ] || echo "(now just LIST)"
408 [ -z "$verbose" ] || ./yulectl -c LIST
[550]409 kill $PROC_S; kill $PROC_Y;
410 return 1
411 fi
[577]412 [ -z "$verbose" ] || OLINE=$( ./yulectl -c LISTALL | grep ${UUID} )
[550]413 [ -z "$verbose" ] || echo "${OLINE}"
414
415 #
416 # >>> (4) Trigger a scan
417 #
418 kill -TTOU $PROC_S
419 if [ $? -ne 0 ]; then
420 [ -z "$verbose" ] || log_msg_fail "Kill -TTOU";
421 kill $PROC_S; kill $PROC_Y;
422 return 1
423 fi
424 [ -z "$verbose" ] || echo " ... TTOU sent to /${PROC_S}/ ...";
425
426 for ff in 1 2; do
427 five_sec_sleep
428 done
429 if [ x"$1" != x ]; then
430 if [ x"$1" = xnodelta ]; then
431 NR=$( egrep "File download failed" $LOGFILE | wc -l )
432 else
433 NR=$( egrep "No good signature" $LOGFILE | wc -l )
434 fi
435 if [ $NR -ne 1 ]; then
436 [ -z "$verbose" ] || log_msg_fail "Client file check (expected fail)";
437 kill $PROC_S; kill $PROC_Y;
438 return 1
439 else
440 [ -z "$verbose" ] || log_msg_ok "Client file check (expected fail)";
441 kill $PROC_S; kill $PROC_Y;
442 return 0
443 fi
444 fi
445
446 NR=$( egrep "File check completed" $LOGFILE | wc -l )
447 if [ $NR -ne 2 ]; then
448 [ -z "$verbose" ] || log_msg_fail "Client file check (2)";
449 kill $PROC_S; kill $PROC_Y;
450 return 1
451 fi
452 [ -z "$verbose" ] || log_msg_ok "sigttou";
453
454 NR=$( egrep "POLICY" $LOGFILE | wc -l )
455 if [ $NR -ne 0 ]; then
456 [ -z "$verbose" ] || log_msg_fail "Client file check (3)";
457 kill $PROC_S; kill $PROC_Y;
458 return 1
459 fi
460
461 # --- The End ---
462
463 kill $PROC_S;
464 kill $PROC_Y
465 return 0
466}
467
468testrun2g_prepare ()
469{
470 #####################################################################
471 #
472 # Create test area and initialize database
473 #
474 rm -f ./.samhain_file
475 rm -f ./.samhain_log
476 rm -f ./.samhain_lock
477 rm -f ./rc.${SH_LOCALHOST}
478 rm -f ./rc.${ALTHOST}
479 rm -f ./file.*
480 #
481 rm -rf ${BASE}
482 #
483 mkdir ${BASE} 2>/dev/null
484 for dd in ${TEST_DIRS}; do
485 mkdir ${BASE}/$dd
486 for ff in ${TEST_FILES}; do
487 echo "foobar" > ${BASE}/$dd/$ff
488 done
489 done
490 #
491 ./samhain.build -t init -p none
492
493 if test x$? = x0; then
494 [ -z "$verbose" ] || log_msg_ok "init...";
495 else
496 [ -z "$quiet" ] && log_msg_fail "init...";
497 return 1
498 fi
499}
500
501testrun2g_build ()
502{
503 [ -z "$verbose" ] || {
504 echo;
505 echo Working directory: $PW_DIR; echo MAKE is $MAKE;
506 echo;
507 }
508 #
509 #
510 [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; }
511 #
512 if test -r "Makefile"; then
513 $MAKE distclean
514 fi
515 #
516 ${TOP_SRCDIR}/configure ${CLIENT_BUILDOPTS} $1 $2 >/dev/null 2>&1
517 #
518 if test x$? = x0; then
519 [ -z "$verbose" ] || log_msg_ok "configure...";
520 $MAKE > /dev/null 2>>test_log
521 if test x$? = x0; then
522 [ -z "$verbose" ] || log_msg_ok "make...";
523 else
524 [ -z "$quiet" ] && log_msg_fail "make...";
525 return 1
526 fi
527
528 else
529 [ -z "$quiet" ] && log_msg_fail "configure...";
530 return 1
531 fi
532
533 # save binary and build server
534 #
535 cp samhain samhain.build || return 1
[551]536 if test -f scripts/samhainadmin.pl
537 then
538 cp scripts/samhainadmin.pl scripts/xxx_samhainadmin.pl
539 fi
[550]540 $MAKE clean >/dev/null || return 1
541
542 ${TOP_SRCDIR}/configure ${SERVER_BUILDOPTS}
543 #
544 if test x$? = x0; then
545 [ -z "$verbose" ] || log_msg_ok "configure...";
546 $MAKE > /dev/null 2>>test_log
547 if test x$? = x0; then
548 [ -z "$verbose" ] || log_msg_ok "make...";
549 else
550 [ -z "$quiet" ] && log_msg_fail "make...";
551 return 1
552 fi
553
554 else
555 [ -z "$quiet" ] && log_msg_fail "configure...";
556 return 1
557 fi
558
559 # Create a password
560
561 SHPW=`./yule -G`
562 if test x"$SHPW" = x; then
563 [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting"
564 return 1
565 fi
566
567 # Set in client
568
569 ./samhain_setpwd samhain.build new $SHPW >/dev/null
570
571 if test x$? = x0; then
572 [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd samhain.build new $SHPW";
573 else
574 [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd samhain.build new $SHPW";
575 return 1
576 fi
577
578 mv samhain.build.new samhain.new || return 1
[551]579 if test -f scripts/xxx_samhainadmin.pl
580 then
581 cp scripts/xxx_samhainadmin.pl scripts/samhainadmin.pl
582 fi
[550]583
584 rm -f ./.samhain_log*
585 rm -f ./.samhain_lock
586
587 SHCLT=`./yule -P $SHPW`
588
589 if test x$? = x0; then
590 [ -z "$verbose" ] || log_msg_ok "yule -P $SHPW";
591 else
592 [ -z "$quiet" ] && log_msg_fail "yule -P $SHPW";
593 return 1
594 fi
595
596 SHCLT1=`echo "${SHCLT}" | sed s%HOSTNAME%${SH_LOCALHOST}%`
597 AHOST=`find_hostname`
598 SHCLT2=`echo "${SHCLT}" | sed s%HOSTNAME%${AHOST}%`
599
600 cp ${SCRIPTDIR}/testrc_2.in testrc_2
601 #
602 sed --in-place -e 's,file = /tmp,dir = 99/tmp/testrun_samhain,g' testrc_2
603 #
604 sed --in-place -e 's,SetUdpActive=no,ReportCheckflags=yes,g' testrc_2
605 #
606 echo $SHCLT1 >> testrc_2
607 echo $SHCLT2 >> testrc_2
608
609 echo $SHPW > ./testpw
610}
611
612testrun2g_signrc ()
613{
614 scripts/samhainadmin.pl -s ./test/gnupg/ -m R $1 >/dev/null
615 scripts/samhainadmin.pl -s ./test/gnupg/ -k 8A0B337A -m E $1 >/dev/null
616}
617
618testrun2g_signdb ()
619{
620 scripts/samhainadmin.pl -s ./test/gnupg/ -k 8A0B337A -m E ./.samhain_file >/dev/null
621}
622
623copy_rc_db_files ()
624{
625 cp ./testrc_2 ./rc.${SH_LOCALHOST}
626 mv ./.samhain_file ./file.${SH_LOCALHOST}
627 if [ $? -ne 0 ]; then
628 [ -z "$verbose" ] || log_msg_fail "No .samhain_file";
629 return 1
630 fi
631 chmod 644 ./rc.${SH_LOCALHOST}
632 chmod 644 ./file.${SH_LOCALHOST}
633
[577]634 if [ "x${SH_LOCALHOST}" != "x${ALTHOST}" ]
635 then
636 cp ./testrc_2 "./rc.${ALTHOST}"
637 cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null
638 chmod 644 ./rc.${ALTHOST}
639 chmod 644 ./file.${ALTHOST}
640 fi
[550]641}
642
643MAXTEST=6; export MAXTEST
644
645testrun2g ()
646{
647 log_start "RUN CLIENT/SERVER CASE TWO";
648 #
649 if [ x"$1" = x ]; then
650 [ -z "$quiet" ] && log_msg_fail "Missing hostname"
651 fi
652 #
653 SH_LOCALHOST=$1; export SH_LOCALHOST
654 #
655
656
657 # Test with missing delta
658 #
659 gpg --list-keys | grep 8A0B337A >/dev/null 2>&1
660 if [ $? -ne 0 ]; then
661 echo "You need to do 'gpg --import test/gnupg/public-key.asc' first"
662 log_skip 1 $MAXTEST 'Case Two w/signed files'
663 else
664 testrun2g_build "--with-gpg=/usr/bin/gpg" "--with-keyid=0x8A0B337A"
665 if [ $? -eq 0 ]; then
666 [ -z "$verbose" ] || log_msg_ok "build..";
667 testrun2g_signrc ./testrc_2
668 fi
669 if [ $? -eq 0 ]; then
670 [ -z "$verbose" ] || log_msg_ok "sign rc..";
671 testrun2g_prepare
672 fi
673 if [ $? -eq 0 ]; then
674 [ -z "$verbose" ] || log_msg_ok "prepare..";
675 testrun2g_signdb
676 fi
677 if [ $? -eq 0 ]; then
678 [ -z "$verbose" ] || log_msg_ok "sign db..";
679 copy_rc_db_files
680 fi
681 if [ $? -eq 0 ]; then
682 [ -z "$verbose" ] || log_msg_ok "copy..";
683 do_test_2_g_yule_start
684 fi
685 if [ $? -eq 0 ]; then
686 [ -z "$verbose" ] || log_msg_ok "start yule..";
687 do_test_2_g_three nodelta
688 fi
689 if [ $? -eq 0 ]; then
690 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Case Two w/missing delta";
691 else
692 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Case Two w/missing delta";
693 fi
694 fi
695
696 # Test with unsigned delta
697 #
698 gpg --list-keys | grep 8A0B337A >/dev/null 2>&1
699 if [ $? -ne 0 ]; then
700 echo "You need to do 'gpg --import test/gnupg/public-key.asc' first"
701 log_skip 1 $MAXTEST 'Case Two w/signed files'
702 else
703 testrun2g_build "--with-gpg=/usr/bin/gpg" "--with-keyid=0x8A0B337A"
704 if [ $? -eq 0 ]; then
705 [ -z "$verbose" ] || log_msg_ok "build..";
706 testrun2g_signrc ./testrc_2
707 fi
708 if [ $? -eq 0 ]; then
709 [ -z "$verbose" ] || log_msg_ok "sign rc..";
710 testrun2g_prepare
711 fi
712 if [ $? -eq 0 ]; then
713 [ -z "$verbose" ] || log_msg_ok "prepare..";
714 testrun2g_signdb
715 fi
716 if [ $? -eq 0 ]; then
717 [ -z "$verbose" ] || log_msg_ok "sign db..";
718 copy_rc_db_files
719 fi
720 if [ $? -eq 0 ]; then
721 [ -z "$verbose" ] || log_msg_ok "copy..";
722 do_test_2_g_yule_start
723 fi
724 if [ $? -eq 0 ]; then
725 [ -z "$verbose" ] || log_msg_ok "start yule..";
726 do_test_2_g_three nosig
727 fi
728 if [ $? -eq 0 ]; then
729 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Case Two w/unsigned delta";
730 else
731 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Case Two w/unsigned delta";
732 fi
733 fi
734
735 # Test with signed files, no sig client
736 #
737 gpg --list-keys | grep 8A0B337A >/dev/null 2>&1
738 if [ $? -ne 0 ]; then
739 echo "You need to do 'gpg --import test/gnupg/public-key.asc' first"
740 log_skip 1 $MAXTEST 'Case Two w/signed files'
741 else
742 testrun2g_build
743 if [ $? -eq 0 ]; then
744 [ -z "$verbose" ] || log_msg_ok "build..";
745 testrun2g_signrc ./testrc_2
746 fi
747 if [ $? -eq 0 ]; then
748 [ -z "$verbose" ] || log_msg_ok "sign rc..";
749 testrun2g_prepare
750 fi
751 if [ $? -eq 0 ]; then
752 [ -z "$verbose" ] || log_msg_ok "prepare..";
753 testrun2g_signdb
754 fi
755 if [ $? -eq 0 ]; then
756 [ -z "$verbose" ] || log_msg_ok "sign db..";
757 copy_rc_db_files
758 fi
759 if [ $? -eq 0 ]; then
760 [ -z "$verbose" ] || log_msg_ok "copy..";
761 do_test_2_g_yule_start
762 fi
763 if [ $? -eq 0 ]; then
764 [ -z "$verbose" ] || log_msg_ok "start yule..";
765 do_test_2_g_three
766 fi
767 if [ $? -eq 0 ]; then
768 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Case Two w/signed files+nosig client";
769 else
770 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Case Two w/signed files+nosig client";
771 fi
772 fi
773
774 # Test with signed files
775 #
776 gpg --list-keys | grep 8A0B337A >/dev/null 2>&1
777 if [ $? -ne 0 ]; then
778 echo "You need to do 'gpg --import test/gnupg/public-key.asc' first"
779 log_skip 1 $MAXTEST 'Case Two w/signed files'
780 else
781 testrun2g_build "--with-gpg=/usr/bin/gpg" "--with-keyid=0x8A0B337A"
782 if [ $? -eq 0 ]; then
783 [ -z "$verbose" ] || log_msg_ok "build..";
784 testrun2g_signrc ./testrc_2
785 fi
786 if [ $? -eq 0 ]; then
787 [ -z "$verbose" ] || log_msg_ok "sign rc..";
788 testrun2g_prepare
789 fi
790 if [ $? -eq 0 ]; then
791 [ -z "$verbose" ] || log_msg_ok "prepare..";
792 testrun2g_signdb
793 fi
794 if [ $? -eq 0 ]; then
795 [ -z "$verbose" ] || log_msg_ok "sign db..";
796 copy_rc_db_files
797 fi
798 if [ $? -eq 0 ]; then
799 [ -z "$verbose" ] || log_msg_ok "copy..";
800 do_test_2_g_yule_start
801 fi
802 if [ $? -eq 0 ]; then
803 [ -z "$verbose" ] || log_msg_ok "start yule..";
804 do_test_2_g_three
805 fi
806 if [ $? -eq 0 ]; then
807 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Case Two w/signed files";
808 else
809 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Case Two w/signed files";
810 fi
811 fi
812
813 # Test with non-signed files
814 #
815 testrun2g_build
816 if [ $? -eq 0 ]; then
817 [ -z "$verbose" ] || log_msg_ok "build..";
818 testrun2g_prepare
819 fi
820 if [ $? -eq 0 ]; then
821 [ -z "$verbose" ] || log_msg_ok "prepare..";
822 copy_rc_db_files
823 fi
824 if [ $? -eq 0 ]; then
825 [ -z "$verbose" ] || log_msg_ok "copy..";
826 do_test_2_g_yule_start
827 fi
828 if [ $? -eq 0 ]; then
829 [ -z "$verbose" ] || log_msg_ok "start yule..";
830 do_test_2_g_one
831 fi
832 if [ $? -eq 0 ]; then
833 [ -z "$quiet" ] && log_ok 2 ${MAXTEST} "Case Two w/unsigned files";
834 else
835 [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "Case Two w/unsigned files";
836 fi
837
838
839
840 #
841 testrun2g_prepare
842 if [ $? -eq 0 ]; then
843 [ -z "$verbose" ] || log_msg_ok "prepare..";
844 copy_rc_db_files
845 fi
846 if [ $? -eq 0 ]; then
847 [ -z "$verbose" ] || log_msg_ok "copy..";
848 do_test_2_g_yule_start
849 fi
850 if [ $? -eq 0 ]; then
851 [ -z "$verbose" ] || log_msg_ok "start yule..";
852 do_test_2_g_two
853 fi
854 if [ $? -eq 0 ]; then
855 [ -z "$quiet" ] && log_ok 3 ${MAXTEST} "Case Two w/o delta";
856 else
857 [ -z "$quiet" ] && log_fail 3 ${MAXTEST} "Case Two w/o delta";
858 fi
859
[551]860 if test -f scripts/xxx_samhainadmin.pl
861 then
862 rm -f scripts/xxx_samhainadmin.pl
863 fi
[550]864
[551]865
[550]866 log_end "RUN CLIENT/SERVER CASE TWO"
867}
Note: See TracBrowser for help on using the repository browser.