[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] | 22 | LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
|
---|
| 23 | RCFILE="$PW_DIR/testrc_2"; export RCFILE
|
---|
[1] | 24 |
|
---|
[19] | 25 | 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] | 26 |
|
---|
[19] | 27 | 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] | 28 |
|
---|
[19] | 29 | do_test_1_a () {
|
---|
[1] | 30 |
|
---|
[19] | 31 | [ -z "$verbose" ] || {
|
---|
| 32 | echo;
|
---|
| 33 | echo "${S}Start Server${E}: ./yule -l info -p none &";
|
---|
| 34 | echo;
|
---|
| 35 | }
|
---|
[22] | 36 | rm -f test_log_valgrind
|
---|
| 37 |
|
---|
| 38 | ${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind &
|
---|
[19] | 39 | PROC_Y=$!
|
---|
| 40 | sleep 5
|
---|
[1] | 41 |
|
---|
[19] | 42 | [ -z "$verbose" ] || {
|
---|
| 43 | echo;
|
---|
| 44 | echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
|
---|
| 45 | echo;
|
---|
| 46 | }
|
---|
| 47 |
|
---|
[22] | 48 | ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind
|
---|
[19] | 49 | if test x$? = x0; then
|
---|
| 50 | [ -z "$verbose" ] || log_msg_ok "samhain.new -t check";
|
---|
[1] | 51 | else
|
---|
[19] | 52 | [ -z "$quiet" ] && log_msg_fail "samhain.new -t check";
|
---|
| 53 | kill $PROC_Y
|
---|
| 54 | return 1
|
---|
[1] | 55 | fi
|
---|
| 56 |
|
---|
[19] | 57 | kill $PROC_Y
|
---|
| 58 | sleep 5
|
---|
[1] | 59 |
|
---|
[19] | 60 | egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
|
---|
| 61 | if [ $? -ne 0 ]; then
|
---|
| 62 | [ -z "$verbose" ] || log_msg_fail "Server start";
|
---|
| 63 | return 1
|
---|
| 64 | fi
|
---|
| 65 | egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1
|
---|
| 66 | if [ $? -ne 0 ]; then
|
---|
| 67 | [ -z "$verbose" ] || log_msg_fail "Client connect";
|
---|
| 68 | return 1
|
---|
| 69 | fi
|
---|
| 70 | egrep "Checking.*/etc" $LOGFILE >/dev/null 2>&1
|
---|
| 71 | if [ $? -ne 0 ]; then
|
---|
| 72 | [ -z "$verbose" ] || log_msg_fail "Client file check";
|
---|
| 73 | return 1
|
---|
| 74 | fi
|
---|
| 75 | egrep "EXIT.*Samhain" $LOGFILE >/dev/null 2>&1
|
---|
| 76 | if [ $? -ne 0 ]; then
|
---|
| 77 | [ -z "$verbose" ] || log_msg_fail "Client exit";
|
---|
| 78 | return 1
|
---|
| 79 | fi
|
---|
| 80 | egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1
|
---|
| 81 | if [ $? -ne 0 ]; then
|
---|
| 82 | [ -z "$verbose" ] || log_msg_fail "Server exit";
|
---|
| 83 | return 1
|
---|
| 84 | fi
|
---|
| 85 |
|
---|
[22] | 86 | [ -z "$VALGRIND" ] || {
|
---|
| 87 | tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
|
---|
| 88 | if [ $tmp -ne 0 ]; then
|
---|
| 89 | [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
|
---|
| 90 | cat test_log_valgrind
|
---|
| 91 | return 1;
|
---|
| 92 | fi;
|
---|
| 93 | }
|
---|
[1] | 94 |
|
---|
[19] | 95 | return 0
|
---|
| 96 | }
|
---|
[1] | 97 |
|
---|
[19] | 98 | testrun2a_internal ()
|
---|
[1] | 99 | {
|
---|
[19] | 100 | [ -z "$verbose" ] || {
|
---|
| 101 | echo;
|
---|
| 102 | echo Working directory: $PW_DIR; echo MAKE is $MAKE;
|
---|
| 103 | echo;
|
---|
| 104 | }
|
---|
[1] | 105 | #
|
---|
| 106 | #
|
---|
[19] | 107 | [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; }
|
---|
[1] | 108 | #
|
---|
| 109 | if test -r "Makefile"; then
|
---|
| 110 | $MAKE distclean
|
---|
| 111 | fi
|
---|
| 112 | #
|
---|
[19] | 113 | ${TOP_SRCDIR}/configure ${CLIENT_BUILDOPTS}
|
---|
[1] | 114 | #
|
---|
| 115 | if test x$? = x0; then
|
---|
[19] | 116 | [ -z "$verbose" ] || log_msg_ok "configure...";
|
---|
| 117 | $MAKE > /dev/null 2>>test_log
|
---|
[1] | 118 | if test x$? = x0; then
|
---|
[19] | 119 | [ -z "$verbose" ] || log_msg_ok "make...";
|
---|
[1] | 120 | else
|
---|
[19] | 121 | [ -z "$quiet" ] && log_msg_fail "make...";
|
---|
| 122 | return 1
|
---|
[1] | 123 | fi
|
---|
| 124 |
|
---|
| 125 | else
|
---|
[19] | 126 | [ -z "$quiet" ] && log_msg_fail "configure...";
|
---|
| 127 | return 1
|
---|
[1] | 128 | fi
|
---|
| 129 |
|
---|
| 130 | # save binary and build server
|
---|
| 131 | #
|
---|
[19] | 132 | cp samhain samhain.build || return 1
|
---|
| 133 | make clean >/dev/null || return 1
|
---|
[1] | 134 |
|
---|
[19] | 135 | ${TOP_SRCDIR}/configure ${SERVER_BUILDOPTS}
|
---|
[1] | 136 | #
|
---|
| 137 | if test x$? = x0; then
|
---|
[19] | 138 | [ -z "$verbose" ] || log_msg_ok "configure...";
|
---|
| 139 | $MAKE > /dev/null 2>>test_log
|
---|
[1] | 140 | if test x$? = x0; then
|
---|
[19] | 141 | [ -z "$verbose" ] || log_msg_ok "make...";
|
---|
[1] | 142 | else
|
---|
[19] | 143 | [ -z "$quiet" ] && log_msg_fail "make...";
|
---|
| 144 | return 1
|
---|
[1] | 145 | fi
|
---|
| 146 |
|
---|
| 147 | else
|
---|
[19] | 148 | [ -z "$quiet" ] && log_msg_fail "configure...";
|
---|
| 149 | return 1
|
---|
[1] | 150 | fi
|
---|
| 151 |
|
---|
| 152 |
|
---|
[19] | 153 | #####################################################################
|
---|
| 154 | #
|
---|
| 155 | #
|
---|
[1] | 156 | rm -f ./.samhain_file
|
---|
| 157 | rm -f ./.samhain_log
|
---|
| 158 | rm -f ./.samhain_lock
|
---|
| 159 | rm -f ./rc.${SH_LOCALHOST}
|
---|
| 160 | rm -f ./file.${SH_LOCALHOST}
|
---|
[25] | 161 | rm -f "./rc.${ALTHOST}"
|
---|
| 162 | rm -f "./file.${ALTHOST}"
|
---|
[1] | 163 |
|
---|
| 164 | cp ${SCRIPTDIR}/testrc_2.in testrc_2
|
---|
| 165 |
|
---|
[19] | 166 | ./samhain.build -t init -p none
|
---|
[1] | 167 |
|
---|
[19] | 168 | if test x$? = x0; then
|
---|
| 169 | [ -z "$verbose" ] || log_msg_ok "init...";
|
---|
| 170 | else
|
---|
| 171 | [ -z "$quiet" ] && log_msg_fail "init...";
|
---|
| 172 | return 1
|
---|
| 173 | fi
|
---|
[1] | 174 |
|
---|
| 175 | # Create a password
|
---|
| 176 |
|
---|
| 177 | SHPW=`./yule -G`
|
---|
| 178 | if test x"$SHPW" = x; then
|
---|
[19] | 179 | [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting"
|
---|
| 180 | return 1
|
---|
[1] | 181 | fi
|
---|
| 182 |
|
---|
| 183 | # Set in client
|
---|
| 184 |
|
---|
[19] | 185 | ./samhain_setpwd samhain.build new $SHPW >/dev/null
|
---|
[1] | 186 |
|
---|
[19] | 187 | if test x$? = x0; then
|
---|
| 188 | [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd samhain.build new $SHPW";
|
---|
| 189 | else
|
---|
| 190 | [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd samhain.build new $SHPW";
|
---|
| 191 | return 1
|
---|
| 192 | fi
|
---|
[1] | 193 |
|
---|
[19] | 194 | mv samhain.build.new samhain.new || return 1
|
---|
| 195 |
|
---|
| 196 | rm -f ./.samhain_log*
|
---|
[1] | 197 | rm -f ./.samhain_lock
|
---|
| 198 |
|
---|
| 199 | SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%`
|
---|
| 200 |
|
---|
[19] | 201 | if test x$? = x0; then
|
---|
| 202 | [ -z "$verbose" ] || log_msg_ok "yule -P $SHPW";
|
---|
| 203 | else
|
---|
| 204 | [ -z "$quiet" ] && log_msg_fail "yule -P $SHPW";
|
---|
| 205 | return 1
|
---|
| 206 | fi
|
---|
| 207 |
|
---|
[1] | 208 | echo $SHCLT >> testrc_2
|
---|
| 209 |
|
---|
[19] | 210 | cp ./testrc_2 ./rc.${SH_LOCALHOST}
|
---|
| 211 | mv ./.samhain_file ./file.${SH_LOCALHOST}
|
---|
[1] | 212 |
|
---|
[19] | 213 | ALTHOST=`find_hostname`
|
---|
| 214 | cp ./testrc_2 "./rc.${ALTHOST}"
|
---|
| 215 | cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null
|
---|
[1] | 216 |
|
---|
| 217 | }
|
---|
| 218 |
|
---|
[25] | 219 | MAXTEST=5; export MAXTEST
|
---|
[19] | 220 |
|
---|
| 221 | testrun2a ()
|
---|
| 222 | {
|
---|
| 223 | log_start "RUN FULL CLIENT/SERVER";
|
---|
| 224 | #
|
---|
| 225 | if [ x"$1" = x ]; then
|
---|
| 226 | [ -z "$quiet" ] && log_msg_fail "Missing hostname"
|
---|
[1] | 227 | fi
|
---|
[19] | 228 | #
|
---|
[1] | 229 | SH_LOCALHOST=$1; export SH_LOCALHOST
|
---|
[19] | 230 | #
|
---|
| 231 | testrun2a_internal
|
---|
| 232 | do_test_1_a
|
---|
| 233 | if [ $? -eq 0 ]; then
|
---|
| 234 | [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client download+logging";
|
---|
| 235 | else
|
---|
| 236 | [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client download+logging";
|
---|
| 237 | fi
|
---|
| 238 | #
|
---|
[25] | 239 | SERVER_BUILDOPTS_ORIG="${SERVER_BUILDOPTS}"
|
---|
| 240 | CLIENT_BUILDOPTS_ORIG="${CLIENT_BUILDOPTS}"
|
---|
| 241 | #
|
---|
| 242 | SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} --disable-srp"
|
---|
| 243 | CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --disable-srp"
|
---|
| 244 | #
|
---|
| 245 | testrun2a_internal
|
---|
| 246 | do_test_1_a
|
---|
| 247 | if [ $? -eq 0 ]; then
|
---|
| 248 | [ -z "$quiet" ] && log_ok 2 ${MAXTEST} "SRP disabled";
|
---|
| 249 | else
|
---|
| 250 | [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "SRP disabled";
|
---|
| 251 | fi
|
---|
| 252 | #
|
---|
| 253 | SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} --disable-encrypt"
|
---|
| 254 | CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --disable-encrypt"
|
---|
| 255 | #
|
---|
| 256 | testrun2a_internal
|
---|
| 257 | do_test_1_a
|
---|
| 258 | if [ $? -eq 0 ]; then
|
---|
| 259 | [ -z "$quiet" ] && log_ok 3 ${MAXTEST} "Encryption disabled";
|
---|
| 260 | else
|
---|
| 261 | [ -z "$quiet" ] && log_fail 3 ${MAXTEST} "Encryption disabled";
|
---|
| 262 | fi
|
---|
| 263 | #
|
---|
| 264 | SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} --enable-encrypt=1"
|
---|
| 265 | CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --enable-encrypt=1"
|
---|
| 266 | #
|
---|
| 267 | testrun2a_internal
|
---|
| 268 | do_test_1_a
|
---|
| 269 | if [ $? -eq 0 ]; then
|
---|
| 270 | [ -z "$quiet" ] && log_ok 4 ${MAXTEST} "Encryption (v1)";
|
---|
| 271 | else
|
---|
| 272 | [ -z "$quiet" ] && log_fail 4 ${MAXTEST} "Encryption (v1)";
|
---|
| 273 | fi
|
---|
| 274 | #
|
---|
| 275 | SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG}"
|
---|
| 276 | CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --enable-encrypt=1"
|
---|
| 277 | #
|
---|
| 278 | testrun2a_internal
|
---|
| 279 | do_test_1_a
|
---|
| 280 | if [ $? -eq 0 ]; then
|
---|
| 281 | [ -z "$quiet" ] && log_ok 5 ${MAXTEST} "Encryption backward compat";
|
---|
| 282 | else
|
---|
| 283 | [ -z "$quiet" ] && log_fail 5 ${MAXTEST} "Encryption backward compat";
|
---|
| 284 | fi
|
---|
| 285 | #
|
---|
[19] | 286 | if [ -n "$cleanup" ]; then
|
---|
| 287 | rm -f ./rc.${SH_LOCALHOST}
|
---|
| 288 | rm -f ./file.${SH_LOCALHOST}
|
---|
| 289 | ALTHOST=`find_hostname`
|
---|
| 290 | rm -f "./file.${ALTHOST}"
|
---|
| 291 | rm -f "./rc.${ALTHOST}"
|
---|
| 292 | fi
|
---|
| 293 | #
|
---|
| 294 | log_end "RUN FULL CLIENT/SERVER"
|
---|
| 295 | }
|
---|
[1] | 296 |
|
---|