[1] | 1 | #! /bin/sh
|
---|
| 2 |
|
---|
[19] | 3 | LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
|
---|
| 4 | RCFILE="$PW_DIR/testrc_2"; export RCFILE
|
---|
[1] | 5 |
|
---|
[19] | 6 | SERVER_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"; export SERVER_BUILDOPTS
|
---|
[1] | 7 |
|
---|
[19] | 8 | CLIENT_BUILDOPTS="--quiet $TRUST --enable-debug --enable-network=client --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$RCFILE --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=localhost --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock"; export CLIENT_BUILDOPTS
|
---|
[1] | 9 |
|
---|
[19] | 10 | do_test_1_a () {
|
---|
[1] | 11 |
|
---|
[19] | 12 | [ -z "$verbose" ] || {
|
---|
| 13 | echo;
|
---|
| 14 | echo "${S}Start Server${E}: ./yule -l info -p none &";
|
---|
| 15 | echo;
|
---|
| 16 | }
|
---|
| 17 | ./yule -l info -p none >/dev/null 2>&1 &
|
---|
| 18 | PROC_Y=$!
|
---|
| 19 | sleep 5
|
---|
[1] | 20 |
|
---|
[19] | 21 | [ -z "$verbose" ] || {
|
---|
| 22 | echo;
|
---|
| 23 | echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
|
---|
| 24 | echo;
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>&1
|
---|
| 28 | if test x$? = x0; then
|
---|
| 29 | [ -z "$verbose" ] || log_msg_ok "samhain.new -t check";
|
---|
[1] | 30 | else
|
---|
[19] | 31 | [ -z "$quiet" ] && log_msg_fail "samhain.new -t check";
|
---|
| 32 | kill $PROC_Y
|
---|
| 33 | return 1
|
---|
[1] | 34 | fi
|
---|
| 35 |
|
---|
[19] | 36 | kill $PROC_Y
|
---|
| 37 | sleep 5
|
---|
[1] | 38 |
|
---|
[19] | 39 | egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
|
---|
| 40 | if [ $? -ne 0 ]; then
|
---|
| 41 | [ -z "$verbose" ] || log_msg_fail "Server start";
|
---|
| 42 | return 1
|
---|
| 43 | fi
|
---|
| 44 | egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1
|
---|
| 45 | if [ $? -ne 0 ]; then
|
---|
| 46 | [ -z "$verbose" ] || log_msg_fail "Client connect";
|
---|
| 47 | return 1
|
---|
| 48 | fi
|
---|
| 49 | egrep "Checking.*/etc" $LOGFILE >/dev/null 2>&1
|
---|
| 50 | if [ $? -ne 0 ]; then
|
---|
| 51 | [ -z "$verbose" ] || log_msg_fail "Client file check";
|
---|
| 52 | return 1
|
---|
| 53 | fi
|
---|
| 54 | egrep "EXIT.*Samhain" $LOGFILE >/dev/null 2>&1
|
---|
| 55 | if [ $? -ne 0 ]; then
|
---|
| 56 | [ -z "$verbose" ] || log_msg_fail "Client exit";
|
---|
| 57 | return 1
|
---|
| 58 | fi
|
---|
| 59 | egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1
|
---|
| 60 | if [ $? -ne 0 ]; then
|
---|
| 61 | [ -z "$verbose" ] || log_msg_fail "Server exit";
|
---|
| 62 | return 1
|
---|
| 63 | fi
|
---|
| 64 |
|
---|
[1] | 65 |
|
---|
[19] | 66 | return 0
|
---|
| 67 | }
|
---|
[1] | 68 |
|
---|
[19] | 69 | testrun2a_internal ()
|
---|
[1] | 70 | {
|
---|
[19] | 71 | [ -z "$verbose" ] || {
|
---|
| 72 | echo;
|
---|
| 73 | echo Working directory: $PW_DIR; echo MAKE is $MAKE;
|
---|
| 74 | echo;
|
---|
| 75 | }
|
---|
[1] | 76 | #
|
---|
| 77 | #
|
---|
[19] | 78 | [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; }
|
---|
[1] | 79 | #
|
---|
| 80 | if test -r "Makefile"; then
|
---|
| 81 | $MAKE distclean
|
---|
| 82 | fi
|
---|
| 83 | #
|
---|
[19] | 84 | ${TOP_SRCDIR}/configure ${CLIENT_BUILDOPTS}
|
---|
[1] | 85 | #
|
---|
| 86 | if test x$? = x0; then
|
---|
[19] | 87 | [ -z "$verbose" ] || log_msg_ok "configure...";
|
---|
| 88 | $MAKE > /dev/null 2>>test_log
|
---|
[1] | 89 | if test x$? = x0; then
|
---|
[19] | 90 | [ -z "$verbose" ] || log_msg_ok "make...";
|
---|
[1] | 91 | else
|
---|
[19] | 92 | [ -z "$quiet" ] && log_msg_fail "make...";
|
---|
| 93 | return 1
|
---|
[1] | 94 | fi
|
---|
| 95 |
|
---|
| 96 | else
|
---|
[19] | 97 | [ -z "$quiet" ] && log_msg_fail "configure...";
|
---|
| 98 | return 1
|
---|
[1] | 99 | fi
|
---|
| 100 |
|
---|
| 101 | # save binary and build server
|
---|
| 102 | #
|
---|
[19] | 103 | cp samhain samhain.build || return 1
|
---|
| 104 | make clean >/dev/null || return 1
|
---|
[1] | 105 |
|
---|
[19] | 106 | ${TOP_SRCDIR}/configure ${SERVER_BUILDOPTS}
|
---|
[1] | 107 | #
|
---|
| 108 | if test x$? = x0; then
|
---|
[19] | 109 | [ -z "$verbose" ] || log_msg_ok "configure...";
|
---|
| 110 | $MAKE > /dev/null 2>>test_log
|
---|
[1] | 111 | if test x$? = x0; then
|
---|
[19] | 112 | [ -z "$verbose" ] || log_msg_ok "make...";
|
---|
[1] | 113 | else
|
---|
[19] | 114 | [ -z "$quiet" ] && log_msg_fail "make...";
|
---|
| 115 | return 1
|
---|
[1] | 116 | fi
|
---|
| 117 |
|
---|
| 118 | else
|
---|
[19] | 119 | [ -z "$quiet" ] && log_msg_fail "configure...";
|
---|
| 120 | return 1
|
---|
[1] | 121 | fi
|
---|
| 122 |
|
---|
| 123 |
|
---|
[19] | 124 | #####################################################################
|
---|
| 125 | #
|
---|
| 126 | #
|
---|
[1] | 127 | rm -f ./.samhain_file
|
---|
| 128 | rm -f ./.samhain_log
|
---|
| 129 | rm -f ./.samhain_lock
|
---|
| 130 | rm -f ./rc.${SH_LOCALHOST}
|
---|
| 131 | rm -f ./file.${SH_LOCALHOST}
|
---|
| 132 |
|
---|
| 133 | cp ${SCRIPTDIR}/testrc_2.in testrc_2
|
---|
| 134 |
|
---|
[19] | 135 | ./samhain.build -t init -p none
|
---|
[1] | 136 |
|
---|
[19] | 137 | if test x$? = x0; then
|
---|
| 138 | [ -z "$verbose" ] || log_msg_ok "init...";
|
---|
| 139 | else
|
---|
| 140 | [ -z "$quiet" ] && log_msg_fail "init...";
|
---|
| 141 | return 1
|
---|
| 142 | fi
|
---|
[1] | 143 |
|
---|
| 144 | # Create a password
|
---|
| 145 |
|
---|
| 146 | SHPW=`./yule -G`
|
---|
| 147 | if test x"$SHPW" = x; then
|
---|
[19] | 148 | [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting"
|
---|
| 149 | return 1
|
---|
[1] | 150 | fi
|
---|
| 151 |
|
---|
| 152 | # Set in client
|
---|
| 153 |
|
---|
[19] | 154 | ./samhain_setpwd samhain.build new $SHPW >/dev/null
|
---|
[1] | 155 |
|
---|
[19] | 156 | if test x$? = x0; then
|
---|
| 157 | [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd samhain.build new $SHPW";
|
---|
| 158 | else
|
---|
| 159 | [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd samhain.build new $SHPW";
|
---|
| 160 | return 1
|
---|
| 161 | fi
|
---|
[1] | 162 |
|
---|
[19] | 163 | mv samhain.build.new samhain.new || return 1
|
---|
| 164 |
|
---|
| 165 | rm -f ./.samhain_log*
|
---|
[1] | 166 | rm -f ./.samhain_lock
|
---|
| 167 |
|
---|
| 168 | SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%`
|
---|
| 169 |
|
---|
[19] | 170 | if test x$? = x0; then
|
---|
| 171 | [ -z "$verbose" ] || log_msg_ok "yule -P $SHPW";
|
---|
| 172 | else
|
---|
| 173 | [ -z "$quiet" ] && log_msg_fail "yule -P $SHPW";
|
---|
| 174 | return 1
|
---|
| 175 | fi
|
---|
| 176 |
|
---|
[1] | 177 | echo $SHCLT >> testrc_2
|
---|
| 178 |
|
---|
[19] | 179 | cp ./testrc_2 ./rc.${SH_LOCALHOST}
|
---|
| 180 | mv ./.samhain_file ./file.${SH_LOCALHOST}
|
---|
[1] | 181 |
|
---|
[19] | 182 | ALTHOST=`find_hostname`
|
---|
| 183 | cp ./testrc_2 "./rc.${ALTHOST}"
|
---|
| 184 | cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null
|
---|
[1] | 185 |
|
---|
| 186 | }
|
---|
| 187 |
|
---|
[19] | 188 | MAXTEST=1; export MAXTEST
|
---|
| 189 |
|
---|
| 190 | testrun2a ()
|
---|
| 191 | {
|
---|
| 192 | log_start "RUN FULL CLIENT/SERVER";
|
---|
| 193 | #
|
---|
| 194 | if [ x"$1" = x ]; then
|
---|
| 195 | [ -z "$quiet" ] && log_msg_fail "Missing hostname"
|
---|
[1] | 196 | fi
|
---|
[19] | 197 | #
|
---|
[1] | 198 | SH_LOCALHOST=$1; export SH_LOCALHOST
|
---|
[19] | 199 | #
|
---|
| 200 | testrun2a_internal
|
---|
| 201 | #
|
---|
| 202 | do_test_1_a
|
---|
| 203 | if [ $? -eq 0 ]; then
|
---|
| 204 | [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client download+logging";
|
---|
| 205 | else
|
---|
| 206 | [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client download+logging";
|
---|
| 207 | fi
|
---|
| 208 | #
|
---|
| 209 | if [ -n "$cleanup" ]; then
|
---|
| 210 | rm -f ./rc.${SH_LOCALHOST}
|
---|
| 211 | rm -f ./file.${SH_LOCALHOST}
|
---|
| 212 | ALTHOST=`find_hostname`
|
---|
| 213 | rm -f "./file.${ALTHOST}"
|
---|
| 214 | rm -f "./rc.${ALTHOST}"
|
---|
| 215 | fi
|
---|
| 216 | #
|
---|
| 217 | log_end "RUN FULL CLIENT/SERVER"
|
---|
| 218 | }
|
---|
[1] | 219 |
|
---|