Index: trunk/test/testrun_2.sh
===================================================================
--- trunk/test/testrun_2.sh	(revision 19)
+++ trunk/test/testrun_2.sh	(revision 22)
@@ -3,4 +3,5 @@
 LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
 RCFILE="$PW_DIR/testrc_2";  export RCFILE
+HTML="$PW_DIR/yule.html";  export HTML
 
 
@@ -12,5 +13,8 @@
 	    echo; 
 	}
-	./yule -l info -p none >/dev/null 2>&1 &
+
+	rm -f test_log_valgrind
+
+	${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind &
 	PROC_Y=$!
 	sleep 5
@@ -22,5 +26,5 @@
 	}
 
-	./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>&1
+	${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind
 	if test x$? = x0; then
 	    [ -z "$verbose" ] || log_msg_ok    "samhain.new -t check";
@@ -59,5 +63,13 @@
 	    return 1
 	fi
-	
+
+	[ -z "$VALGRIND" ] || {
+	    tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
+	    if [ $tmp -ne 0 ]; then
+		[ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
+		cat test_log_valgrind
+		return 1;
+	    fi;
+	}
 
 	return 0
@@ -81,6 +93,7 @@
 
 	rm -f $LOGFILE
-
-	./yule -l info -p none >/dev/null 2>&1 &
+	rm -f test_log_valgrind
+
+	${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind &
 	PROC_Y=$!
 	sleep 5
@@ -92,5 +105,5 @@
 	}
 
-	./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>&1
+	${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind
 	if test x$? = x0; then
 	    [ -z "$verbose" ] || log_msg_ok    "samhain.new -t check";
@@ -112,5 +125,5 @@
 	    CLIENTLOG="${LOGFILE}.${remhost}"
 	else
-	    CLIENTLOG=`ls -1 ${LOGFILE}.* | tail -n 1`
+	    CLIENTLOG=`ls -1 ${LOGFILE}.* 2>/dev/null | tail -n 1`
 	fi
 
@@ -140,4 +153,13 @@
 	    return 1
 	fi
+
+	[ -z "$VALGRIND" ] || {
+	    tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
+	    if [ $tmp -ne 0 ]; then
+		[ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
+		cat test_log_valgrind
+		return 1;
+	    fi;
+	}
 	
 	rm -f ${LOGFILE}.${remhost}
@@ -171,6 +193,7 @@
 
 	rm -f $LOGFILE
-
-	./yule -p none >/dev/null 2>&1 &
+	rm -f test_log_valgrind
+
+	${VALGRIND} ./yule -p none >/dev/null 2>>test_log_valgrind &
 	PROC_Y=$!
 	sleep 5
@@ -182,5 +205,5 @@
 	}
 
-	./samhain.new -t check -p none -l none --forever --bind-address=127.0.0.1 >/dev/null 2>&1 &
+	${VALGRIND} ./samhain.new -t check -p none -l none --forever --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind &
 	if test x$? = x0; then
 	    PROC_S=$!
@@ -231,8 +254,288 @@
 	    return 1
 	fi
+
+	[ -z "$VALGRIND" ] || {
+	    tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
+	    if [ $tmp -ne 0 ]; then
+		[ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
+		cat test_log_valgrind
+		return 1;
+	    fi;
+	}
 	
-	rm -f ${LOGFILE}.${remhost}
+	rm -f ${LOGFILE}
 	return 0
 }
+
+do_test_4 () {
+
+        # don't know what is supported on the test platform, so
+        # prepare for both (password and socket credential)
+
+        # 'id -u' is posix
+        me=`id -u`
+
+	ORIGINAL_1="SetSocketAllowUid=0"
+	REPLACEMENT_1="SetSocketAllowUid=$me"
+        ex $RCFILE <<EOF
+:%s/${ORIGINAL_1}/${REPLACEMENT_1}/g
+:wq
+EOF
+
+	[ -z "$verbose" ] || { 
+	    echo; 
+	    echo "${S}Start Server${E}: ./yule -l info -p none &"; 
+	    echo; 
+	}
+
+	rm -f $LOGFILE
+	rm -f test_log_valgrind
+
+	${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind &
+	PROC_Y=$!
+	sleep 5
+
+	[ -z "$verbose" ] || { 
+	    echo; 
+	    echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check"; 
+	    echo; 
+	}
+
+	$MAKE yulectl >/dev/null 
+	if [ $? -ne 0 ]; then
+	    [ -z "$verbose" ] || log_msg_fail "make yulectl";
+	    kill $PROC_Y
+	    return 1
+	fi
+
+
+	./yulectl -v -c RELOAD foobar1 >test_log_yulectl 2>/dev/null
+
+	if [ $? -ne 0 ]; then 
+	    YULECTL_PASSWORD=samhain; export YULECTL_PASSWORD
+	    ./yulectl -v -c RELOAD foobar1 >test_log_yulectl
+	    if [ $? -ne 0 ]; then
+		kill ${PROC_Y}
+		[ -z "$verbose" ] || log_msg_fail "yulectl";
+		return 1
+	    fi
+	fi
+
+	./yulectl -v -c RELOAD foobar2 >test_yulectl_log
+
+	if [ $? -ne 0 ]; then
+	    kill ${PROC_Y}
+	    [ -z "$verbose" ] || log_msg_fail "yulectl";
+	    return 1
+	fi
+
+	./yulectl -v -c RELOAD foobar3 >test_log_yulectl
+
+	if [ $? -ne 0 ]; then
+	    kill ${PROC_Y}
+	    [ -z "$verbose" ] || log_msg_fail "yulectl";
+	    return 1
+	fi
+
+	./yulectl -v -c LISTALL dummy >test_log_yulectl
+
+	if [ $? -ne 0 ]; then
+	    kill ${PROC_Y}
+	    [ -z "$verbose" ] || log_msg_fail "yulectl";
+	    return 1
+	fi
+
+	tmp=`cat test_log_yulectl | grep RELOAD | wc -l`
+	if [ $tmp -ne 3 ]; then
+	    kill ${PROC_Y}
+	    [ -z "$verbose" ] || log_msg_fail "command confirmation";
+	    return 1
+	fi
+
+	./yulectl -v -c CANCEL foobar3 >test_log_yulectl
+
+	if [ $? -ne 0 ]; then
+	    kill ${PROC_Y}
+	    [ -z "$verbose" ] || log_msg_fail "yulectl";
+	    return 1
+	fi
+
+	./yulectl -v -c LISTALL dummy >test_log_yulectl
+
+	if [ $? -ne 0 ]; then
+	    kill ${PROC_Y}
+	    [ -z "$verbose" ] || log_msg_fail "yulectl";
+	    return 1
+	fi
+
+	tmp=`cat test_log_yulectl | grep RELOAD | wc -l`
+	if [ $tmp -ne 2 ]; then
+	    kill ${PROC_Y}
+	    [ -z "$verbose" ] || log_msg_fail "command confirmation";
+	    return 1
+	fi
+
+	kill ${PROC_Y}
+
+	[ -z "$VALGRIND" ] || {
+	    tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
+	    if [ $tmp -ne 0 ]; then
+		[ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
+		cat test_log_valgrind
+		return 1;
+	    fi;
+	}
+	
+	return 0
+}
+
+do_test_5 () {
+
+	[ -z "$verbose" ] || { 
+	    echo; 
+	    echo "${S}Start Server${E}: ./yule -l info -p none &"; 
+	    echo; 
+	}
+
+( cat <<EOF
+<!-- head -->
+<html><head><title>test</title></head>
+<body>
+Current time: %T <br>
+<table>
+<!-- ehead -->
+EOF
+) >head.html
+
+( cat <<EOF
+<!-- foot -->
+</table>
+</body>
+<!-- efoot -->
+EOF
+) >foot.html
+
+( cat <<EOF
+<!-- entry -->
+<tr>
+  <td>%H</td>
+  <td>%S</td>
+  <td>%T</td>
+</tr>
+<!-- eentry -->
+EOF
+) >entry.html
+
+	${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind &
+	PROC_Y=$!
+	sleep 5
+
+	egrep '<!-- head -->' $HTML >/dev/null 2>&1
+	if [ $? -ne 0 ]; then
+	    rm -f head.html; rm -f foot.html; rm -f entry.html;
+	    kill $PROC_Y
+	    [ -z "$verbose" ] || log_msg_fail "head.html";
+	    return 1
+	fi
+
+	egrep '<!-- foot -->' $HTML >/dev/null 2>&1
+	if [ $? -ne 0 ]; then
+	    rm -f head.html; rm -f foot.html; rm -f entry.html;
+	    kill $PROC_Y
+	    [ -z "$verbose" ] || log_msg_fail "foot.html";
+	    return 1
+	fi
+
+	[ -z "$verbose" ] || { 
+	    echo; 
+	    echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check"; 
+	    echo; 
+	}
+
+	${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind
+	if test x$? = x0; then
+	    [ -z "$verbose" ] || log_msg_ok    "samhain.new -t check";
+	else
+	    kill $PROC_Y
+	    [ -z "$quiet" ]   && log_msg_fail  "samhain.new -t check";
+	    return 1
+	fi
+
+	kill $PROC_Y
+	sleep 5
+
+	# rm -f head.html; rm -f foot.html; rm -f entry.html;
+
+	egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
+	if [ $? -ne 0 ]; then
+	    [ -z "$verbose" ] || log_msg_fail "Server start";
+	    return 1
+	fi
+	egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1
+	if [ $? -ne 0 ]; then
+	    [ -z "$verbose" ] || log_msg_fail "Client connect";
+	    return 1
+	fi
+	egrep "remote_host.*Checking.*/bin" $LOGFILE >/dev/null 2>&1
+	if [ $? -ne 0 ]; then
+	    [ -z "$verbose" ] || log_msg_fail "Client file check";
+	    return 1
+	fi
+	egrep "remote_host.*EXIT.*Samhain" $LOGFILE >/dev/null 2>&1
+	if [ $? -ne 0 ]; then
+	    [ -z "$verbose" ] || log_msg_fail "Client exit";
+	    return 1
+	fi
+	egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1
+	if [ $? -ne 0 ]; then
+	    [ -z "$verbose" ] || log_msg_fail "Server exit";
+	    return 1
+	fi
+
+	egrep '<!-- head -->' $HTML >/dev/null 2>&1
+	if [ $? -ne 0 ]; then
+	    [ -z "$verbose" ] || log_msg_fail "head.html";
+	    return 1
+	fi
+	egrep '<!-- ehead -->' $HTML >/dev/null 2>&1
+	if [ $? -ne 0 ]; then
+	    [ -z "$verbose" ] || log_msg_fail "head.html";
+	    return 1
+	fi
+
+	egrep '<!-- entry -->' $HTML >/dev/null 2>&1
+	if [ $? -ne 0 ]; then
+	    [ -z "$verbose" ] || log_msg_fail "entry.html";
+	    return 1
+	fi
+	egrep '<!-- eentry -->' $HTML >/dev/null 2>&1
+	if [ $? -ne 0 ]; then
+	    [ -z "$verbose" ] || log_msg_fail "entry.html";
+	    return 1
+	fi
+
+	egrep '<!-- foot -->' $HTML >/dev/null 2>&1
+	if [ $? -ne 0 ]; then
+	    [ -z "$verbose" ] || log_msg_fail "foot.html";
+	    return 1
+	fi
+	egrep '<!-- efoot -->' $HTML >/dev/null 2>&1
+	if [ $? -ne 0 ]; then
+	    [ -z "$verbose" ] || log_msg_fail "foot.html";
+	    return 1
+	fi
+
+	[ -z "$VALGRIND" ] || {
+	    tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
+	    if [ $tmp -ne 0 ]; then
+		[ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
+		cat test_log_valgrind
+		return 1;
+	    fi;
+	}
+
+	return 0
+}
+
 
 testrun2_internal ()
@@ -273,5 +576,5 @@
 	make clean >/dev/null || return 1
 
-	${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-data-file=$PW_DIR/.samhain_file --enable-identity=rainer --enable-encrypt=2
+	${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-data-file=$PW_DIR/.samhain_file --with-html-file=$HTML --enable-encrypt=2
 	#
 	if test x$? = x0; then
@@ -353,7 +656,7 @@
 	do_test_2
 	if [ $? -eq 0 ]; then
-	    [ -z "$quiet" ] && log_ok   2 ${MAXTEST} "Client logging, seperate logfiles";
-	else
-	    [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "Client logging, seperate logfiles";
+	    [ -z "$quiet" ] && log_ok   2 ${MAXTEST} "Client logging, separate logfiles";
+	else
+	    [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "Client logging, separate logfiles";
 	fi
 
@@ -365,8 +668,22 @@
 	fi
 
+	do_test_4
+	if [ $? -eq 0 ]; then
+	    [ -z "$quiet" ] && log_ok   4 ${MAXTEST} "Server command socket";
+	else
+	    [ -z "$quiet" ] && log_fail 4 ${MAXTEST} "Server command socket";
+	fi
+
+	do_test_5
+	if [ $? -eq 0 ]; then
+	    [ -z "$quiet" ] && log_ok   5 ${MAXTEST} "Server status file";
+	else
+	    [ -z "$quiet" ] && log_fail 5 ${MAXTEST} "Server status file";
+	fi
+
 	return $?
 }
 
-MAXTEST=3; export MAXTEST
+MAXTEST=5; export MAXTEST
 
 testrun2 ()
