summaryrefslogtreecommitdiffstats
path: root/test/testrun_2g.sh
diff options
context:
space:
mode:
Diffstat (limited to 'test/testrun_2g.sh')
-rwxr-xr-xtest/testrun_2g.sh95
1 files changed, 71 insertions, 24 deletions
diff --git a/test/testrun_2g.sh b/test/testrun_2g.sh
index dadbba6..2440f52 100755
--- a/test/testrun_2g.sh
+++ b/test/testrun_2g.sh
@@ -93,7 +93,7 @@ do_test_2_g_yule_start () {
return 1
fi
five_sec_sleep
- PROC_S=$( ps aux | grep samhain.new | grep -v grep | awk '{ print $2; }' )
+ PROC_S=$( ps aux | grep samhain.new | grep -v grep | awk '{ print $2; }' | sort | head -n 1 )
for ff in 1 2; do
five_sec_sleep
@@ -203,7 +203,10 @@ do_test_2_g_one () {
#
UUID=$(uuidgen)
mv ./file.delta file.${SH_LOCALHOST}.${UUID}
- cp file.${SH_LOCALHOST}.${UUID} "./file.${ALTHOST}.${UUID}"
+ if [ "x${SH_LOCALHOST}" != "x${ALTHOST}" ]
+ then
+ cp file.${SH_LOCALHOST}.${UUID} "./file.${ALTHOST}.${UUID}"
+ fi
#
# >>> (3) Tell client to load delta database.
@@ -222,20 +225,28 @@ do_test_2_g_one () {
return 1
fi
+ NHOSTS=1
+
./yulectl -c "DELTA:${UUID}" ${SH_LOCALHOST}
if [ $? -ne 0 ]; then
[ -z "$verbose" ] || log_msg_fail "yulectl (1)";
kill $PROC_S; kill $PROC_Y;
return 1
fi
- ./yulectl -c "DELTA:${UUID}" ${ALTHOST}
- if [ $? -ne 0 ]; then
- [ -z "$verbose" ] || log_msg_fail "yulectl (2)";
- kill $PROC_S; kill $PROC_Y;
- return 1
+
+ if [ "x${SH_LOCALHOST}" != "x${ALTHOST}" ]
+ then
+ ./yulectl -c "DELTA:${UUID}" ${ALTHOST}
+ NHOSTS=2
+ if [ $? -ne 0 ]; then
+ [ -z "$verbose" ] || log_msg_fail "yulectl (2)";
+ kill $PROC_S; kill $PROC_Y;
+ return 1
+ fi
fi
+
NR=$( ./yulectl -c LIST | grep ${UUID} | grep -v grep | wc -l )
- if [ $NR -ne 2 ]; then
+ if [ $NR -ne $NHOSTS ]; then
[ -z "$verbose" ] || log_msg_fail "yulectl (3)";
[ -z "$verbose" ] || ./yulectl -c LIST
kill $PROC_S; kill $PROC_Y;
@@ -248,7 +259,8 @@ do_test_2_g_one () {
five_sec_sleep
done
#
- NR=$( ./yulectl -c LIST | grep ${UUID} | grep -v grep | wc -l )
+ NR=$( ./yulectl -c LISTALL | grep ${UUID} | grep SENT | grep -v grep | wc -l )
+ # NR=$( ./yulectl -c LIST | grep ${UUID} | grep -v grep | wc -l )
if [ $NR -ne 1 ]; then
[ -z "$verbose" ] || log_msg_fail "yulectl (4)";
[ -z "$verbose" ] || ./yulectl -c LISTALL
@@ -316,7 +328,8 @@ do_test_2_g_three () {
kill $PROC_S; kill $PROC_Y;
return 1
fi
-
+ [ -z "$verbose" ] || log_msg_ok "... DeltaDB created ...";
+
#
# >>> (2) Copy to server and tag with a UUID
#
@@ -328,8 +341,12 @@ do_test_2_g_three () {
rm -f ./file.*
else
mv ./file.delta file.${SH_LOCALHOST}.${UUID}
- cp file.${SH_LOCALHOST}.${UUID} "./file.${ALTHOST}.${UUID}"
+ if [ "x${SH_LOCALHOST}" != "x${ALTHOST}" ]
+ then
+ cp file.${SH_LOCALHOST}.${UUID} "./file.${ALTHOST}.${UUID}"
+ fi
fi
+ [ -z "$verbose" ] || log_msg_ok "... DeltaDB copied as file.${SH_LOCALHOST}.${UUID} ...";
#
# >>> (3) Tell client to load delta database.
@@ -348,25 +365,34 @@ do_test_2_g_three () {
return 1
fi
+ NHOSTS=1
+
./yulectl -c "DELTA:${UUID}" ${SH_LOCALHOST}
if [ $? -ne 0 ]; then
[ -z "$verbose" ] || log_msg_fail "yulectl (1)";
kill $PROC_S; kill $PROC_Y;
return 1
fi
- ./yulectl -c "DELTA:${UUID}" ${ALTHOST}
- if [ $? -ne 0 ]; then
- [ -z "$verbose" ] || log_msg_fail "yulectl (2)";
- kill $PROC_S; kill $PROC_Y;
- return 1
+
+ if [ "x${SH_LOCALHOST}" != "x${ALTHOST}" ]
+ then
+ ./yulectl -c "DELTA:${UUID}" ${ALTHOST}
+ NHOSTS=2
+ if [ $? -ne 0 ]; then
+ [ -z "$verbose" ] || log_msg_fail "yulectl (2)";
+ kill $PROC_S; kill $PROC_Y;
+ return 1
+ fi
fi
+
NR=$( ./yulectl -c LIST | grep ${UUID} | grep -v grep | wc -l )
- if [ $NR -ne 2 ]; then
+ if [ $NR -ne $NHOSTS ]; then
[ -z "$verbose" ] || log_msg_fail "yulectl (3)";
[ -z "$verbose" ] || ./yulectl -c LIST
kill $PROC_S; kill $PROC_Y;
return 1
fi
+ [ -z "$verbose" ] || log_msg_ok "... command sent to client ...";
# Wait and verify that command has been sent
#
@@ -374,13 +400,17 @@ do_test_2_g_three () {
five_sec_sleep
done
#
- NR=$( ./yulectl -c LIST | grep ${UUID} | grep -v grep | wc -l )
+ NR=$( ./yulectl -c LISTALL | grep ${UUID} | grep SENT | grep -v grep | wc -l )
if [ $NR -ne 1 ]; then
- [ -z "$verbose" ] || log_msg_fail "yulectl (4)";
+ [ -z "$verbose" ] || log_msg_fail "yulectl (4): ${UUID}";
[ -z "$verbose" ] || ./yulectl -c LISTALL
+ [ -z "$verbose" ] || echo "(now just LIST)"
+ [ -z "$verbose" ] || ./yulectl -c LIST
kill $PROC_S; kill $PROC_Y;
return 1
fi
+ [ -z "$verbose" ] || OLINE=$( ./yulectl -c LISTALL | grep ${UUID} )
+ [ -z "$verbose" ] || echo "${OLINE}"
#
# >>> (4) Trigger a scan
@@ -391,7 +421,8 @@ do_test_2_g_three () {
kill $PROC_S; kill $PROC_Y;
return 1
fi
-
+ [ -z "$verbose" ] || echo " ... TTOU sent to /${PROC_S}/ ...";
+
for ff in 1 2; do
five_sec_sleep
done
@@ -502,6 +533,10 @@ testrun2g_build ()
# save binary and build server
#
cp samhain samhain.build || return 1
+ if test -f scripts/samhainadmin.pl
+ then
+ cp scripts/samhainadmin.pl scripts/xxx_samhainadmin.pl
+ fi
$MAKE clean >/dev/null || return 1
${TOP_SRCDIR}/configure ${SERVER_BUILDOPTS}
@@ -541,6 +576,10 @@ testrun2g_build ()
fi
mv samhain.build.new samhain.new || return 1
+ if test -f scripts/xxx_samhainadmin.pl
+ then
+ cp scripts/xxx_samhainadmin.pl scripts/samhainadmin.pl
+ fi
rm -f ./.samhain_log*
rm -f ./.samhain_lock
@@ -592,10 +631,13 @@ copy_rc_db_files ()
chmod 644 ./rc.${SH_LOCALHOST}
chmod 644 ./file.${SH_LOCALHOST}
- cp ./testrc_2 "./rc.${ALTHOST}"
- cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null
- chmod 644 ./rc.${ALTHOST}
- chmod 644 ./file.${ALTHOST}
+ if [ "x${SH_LOCALHOST}" != "x${ALTHOST}" ]
+ then
+ cp ./testrc_2 "./rc.${ALTHOST}"
+ cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null
+ chmod 644 ./rc.${ALTHOST}
+ chmod 644 ./file.${ALTHOST}
+ fi
}
MAXTEST=6; export MAXTEST
@@ -815,6 +857,11 @@ testrun2g ()
[ -z "$quiet" ] && log_fail 3 ${MAXTEST} "Case Two w/o delta";
fi
+ if test -f scripts/xxx_samhainadmin.pl
+ then
+ rm -f scripts/xxx_samhainadmin.pl
+ fi
+
log_end "RUN CLIENT/SERVER CASE TWO"
}