[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
|
---|
[22] | 24 | HTML="$PW_DIR/yule.html"; export HTML
|
---|
[1] | 25 |
|
---|
| 26 |
|
---|
[19] | 27 | do_test_1 () {
|
---|
[1] | 28 |
|
---|
[19] | 29 | [ -z "$verbose" ] || {
|
---|
| 30 | echo;
|
---|
| 31 | echo "${S}Start Server${E}: ./yule -l info -p none &";
|
---|
| 32 | echo;
|
---|
| 33 | }
|
---|
[22] | 34 |
|
---|
| 35 | rm -f test_log_valgrind
|
---|
| 36 |
|
---|
[27] | 37 | ${VALGRIND} ./yule.2 -l info -p none >/dev/null 2>>test_log_valgrind &
|
---|
| 38 | PROC_Y2=$!
|
---|
| 39 | sleep 5
|
---|
| 40 |
|
---|
| 41 | [ -z "$verbose" ] || {
|
---|
| 42 | echo;
|
---|
| 43 | echo "${S}Start Server #2${E}: ./yule.2 -l info -p none &";
|
---|
| 44 | echo;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | ${VALGRIND} ./yule -l info -p none -e info --bind-address=127.0.0.1 \
|
---|
| 48 | --server-port=49778 >/dev/null 2>>test_log_valgrind &
|
---|
[19] | 49 | PROC_Y=$!
|
---|
| 50 | sleep 5
|
---|
[1] | 51 |
|
---|
[19] | 52 | [ -z "$verbose" ] || {
|
---|
| 53 | echo;
|
---|
| 54 | echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
|
---|
| 55 | echo;
|
---|
| 56 | }
|
---|
[1] | 57 |
|
---|
[22] | 58 | ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind
|
---|
[19] | 59 | if test x$? = x0; then
|
---|
| 60 | [ -z "$verbose" ] || log_msg_ok "samhain.new -t check";
|
---|
[1] | 61 | else
|
---|
[19] | 62 | [ -z "$quiet" ] && log_msg_fail "samhain.new -t check";
|
---|
| 63 | kill $PROC_Y
|
---|
[27] | 64 | kill $PROC_Y2
|
---|
[19] | 65 | return 1
|
---|
[1] | 66 | fi
|
---|
| 67 |
|
---|
[19] | 68 | kill $PROC_Y
|
---|
[27] | 69 | kill $PROC_Y2
|
---|
[19] | 70 | sleep 5
|
---|
[1] | 71 |
|
---|
[27] | 72 | # cp ${LOGFILE} triple_test
|
---|
| 73 | # cp ${LOGFILE}2 triple_test_2
|
---|
| 74 |
|
---|
| 75 | egrep "START(>|\").*Yule(>|\")" ${LOGFILE}2 >/dev/null 2>&1
|
---|
| 76 | if [ $? -ne 0 ]; then
|
---|
| 77 | [ -z "$verbose" ] || log_msg_fail "Server #2 start";
|
---|
| 78 | return 1
|
---|
| 79 | fi
|
---|
| 80 | egrep "remote_host.*Checking.*/bin" ${LOGFILE}2 >/dev/null 2>&1
|
---|
| 81 | if [ $? -ne 0 ]; then
|
---|
| 82 | [ -z "$verbose" ] || log_msg_fail "Client file check (relayed)";
|
---|
| 83 | return 1
|
---|
| 84 | fi
|
---|
| 85 | egrep "remote_host.*EXIT.*Samhain" ${LOGFILE}2 >/dev/null 2>&1
|
---|
| 86 | if [ $? -ne 0 ]; then
|
---|
| 87 | [ -z "$verbose" ] || log_msg_fail "Client exit (relayed)";
|
---|
| 88 | return 1
|
---|
| 89 | fi
|
---|
| 90 | egrep "EXIT.*Yule.*SIGTERM" ${LOGFILE}2 >/dev/null 2>&1
|
---|
| 91 | if [ $? -ne 0 ]; then
|
---|
| 92 | [ -z "$verbose" ] || log_msg_fail "Server #2 exit";
|
---|
| 93 | return 1
|
---|
| 94 | fi
|
---|
| 95 |
|
---|
| 96 |
|
---|
[19] | 97 | egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
|
---|
| 98 | if [ $? -ne 0 ]; then
|
---|
| 99 | [ -z "$verbose" ] || log_msg_fail "Server start";
|
---|
| 100 | return 1
|
---|
| 101 | fi
|
---|
| 102 | egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1
|
---|
| 103 | if [ $? -ne 0 ]; then
|
---|
| 104 | [ -z "$verbose" ] || log_msg_fail "Client connect";
|
---|
| 105 | return 1
|
---|
| 106 | fi
|
---|
| 107 | egrep "remote_host.*Checking.*/bin" $LOGFILE >/dev/null 2>&1
|
---|
| 108 | if [ $? -ne 0 ]; then
|
---|
| 109 | [ -z "$verbose" ] || log_msg_fail "Client file check";
|
---|
| 110 | return 1
|
---|
| 111 | fi
|
---|
| 112 | egrep "remote_host.*EXIT.*Samhain" $LOGFILE >/dev/null 2>&1
|
---|
| 113 | if [ $? -ne 0 ]; then
|
---|
| 114 | [ -z "$verbose" ] || log_msg_fail "Client exit";
|
---|
| 115 | return 1
|
---|
| 116 | fi
|
---|
| 117 | egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1
|
---|
| 118 | if [ $? -ne 0 ]; then
|
---|
| 119 | [ -z "$verbose" ] || log_msg_fail "Server exit";
|
---|
| 120 | return 1
|
---|
| 121 | fi
|
---|
[1] | 122 |
|
---|
[22] | 123 | [ -z "$VALGRIND" ] || {
|
---|
| 124 | tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
|
---|
| 125 | if [ $tmp -ne 0 ]; then
|
---|
| 126 | [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
|
---|
| 127 | cat test_log_valgrind
|
---|
| 128 | return 1;
|
---|
| 129 | fi;
|
---|
| 130 | }
|
---|
| 131 |
|
---|
[19] | 132 | return 0
|
---|
| 133 | }
|
---|
[1] | 134 |
|
---|
[19] | 135 | do_test_2 () {
|
---|
| 136 |
|
---|
| 137 | ORIGINAL="UseSeparateLogs=no"
|
---|
| 138 | REPLACEMENT="UseSeparateLogs=yes"
|
---|
| 139 | ex $RCFILE <<EOF
|
---|
[30] | 140 | %s/$ORIGINAL/$REPLACEMENT/g
|
---|
| 141 | wq
|
---|
[19] | 142 | EOF
|
---|
| 143 | # :%s is the "ex" substitution command.
|
---|
| 144 | # :wq is write-and-quit.
|
---|
| 145 | [ -z "$verbose" ] || {
|
---|
| 146 | echo;
|
---|
| 147 | echo "${S}Start Server${E}: ./yule -l info -p none &";
|
---|
| 148 | echo;
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | rm -f $LOGFILE
|
---|
[22] | 152 | rm -f test_log_valgrind
|
---|
[19] | 153 |
|
---|
[22] | 154 | ${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind &
|
---|
[19] | 155 | PROC_Y=$!
|
---|
| 156 | sleep 5
|
---|
| 157 |
|
---|
| 158 | [ -z "$verbose" ] || {
|
---|
| 159 | echo;
|
---|
| 160 | echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
|
---|
| 161 | echo;
|
---|
| 162 | }
|
---|
| 163 |
|
---|
[22] | 164 | ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind
|
---|
[19] | 165 | if test x$? = x0; then
|
---|
| 166 | [ -z "$verbose" ] || log_msg_ok "samhain.new -t check";
|
---|
| 167 | else
|
---|
| 168 | [ -z "$quiet" ] && log_msg_fail "samhain.new -t check";
|
---|
| 169 | kill $PROC_Y
|
---|
| 170 | return 1
|
---|
| 171 | fi
|
---|
| 172 |
|
---|
| 173 | kill $PROC_Y
|
---|
| 174 | sleep 5
|
---|
| 175 |
|
---|
| 176 | if [ -f ${LOGFILE}.${SH_LOCALHOST} ]; then
|
---|
| 177 | remhost=${SH_LOCALHOST}
|
---|
| 178 | else
|
---|
| 179 | remhost=`echo $SH_LOCALHOST | sed 's,\..*,,'`
|
---|
| 180 | fi
|
---|
| 181 | if [ -f ${LOGFILE}.${remhost} ]; then
|
---|
| 182 | CLIENTLOG="${LOGFILE}.${remhost}"
|
---|
| 183 | else
|
---|
[30] | 184 | tail -n 1 ${SCRIPTDIR}/test.sh >/dev/null 2>&1
|
---|
| 185 | if [ $? -eq 0 ]; then
|
---|
| 186 | CLIENTLOG=`ls -1 ${LOGFILE}.* 2>/dev/null | tail -n 1`
|
---|
| 187 | else
|
---|
| 188 | CLIENTLOG=`ls -1 ${LOGFILE}.* 2>/dev/null | tail -1`
|
---|
| 189 | fi
|
---|
[19] | 190 | fi
|
---|
| 191 |
|
---|
| 192 | egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
|
---|
| 193 | if [ $? -ne 0 ]; then
|
---|
| 194 | [ -z "$verbose" ] || log_msg_fail "Server start";
|
---|
| 195 | return 1
|
---|
| 196 | fi
|
---|
| 197 | egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1
|
---|
| 198 | if [ $? -ne 0 ]; then
|
---|
| 199 | [ -z "$verbose" ] || log_msg_fail "Client connect";
|
---|
| 200 | return 1
|
---|
| 201 | fi
|
---|
| 202 | egrep "remote_host.*Checking.*/bin" ${CLIENTLOG} >/dev/null 2>&1
|
---|
| 203 | if [ $? -ne 0 ]; then
|
---|
| 204 | [ -z "$verbose" ] || log_msg_fail "Client file check";
|
---|
| 205 | return 1
|
---|
| 206 | fi
|
---|
| 207 | egrep "remote_host.*EXIT.*Samhain" ${CLIENTLOG} >/dev/null 2>&1
|
---|
| 208 | if [ $? -ne 0 ]; then
|
---|
| 209 | [ -z "$verbose" ] || log_msg_fail "Client exit";
|
---|
| 210 | return 1
|
---|
| 211 | fi
|
---|
| 212 | egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1
|
---|
| 213 | if [ $? -ne 0 ]; then
|
---|
| 214 | [ -z "$verbose" ] || log_msg_fail "Server exit";
|
---|
| 215 | return 1
|
---|
| 216 | fi
|
---|
[22] | 217 |
|
---|
| 218 | [ -z "$VALGRIND" ] || {
|
---|
| 219 | tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
|
---|
| 220 | if [ $tmp -ne 0 ]; then
|
---|
| 221 | [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
|
---|
| 222 | cat test_log_valgrind
|
---|
| 223 | return 1;
|
---|
| 224 | fi;
|
---|
| 225 | }
|
---|
[19] | 226 |
|
---|
| 227 | rm -f ${LOGFILE}.${remhost}
|
---|
| 228 | return 0
|
---|
| 229 | }
|
---|
| 230 |
|
---|
| 231 | do_test_3 () {
|
---|
| 232 |
|
---|
| 233 | ORIGINAL_1="ExportSeverity=none"
|
---|
| 234 | REPLACEMENT_1="ExportSeverity=mark"
|
---|
| 235 | ORIGINAL_2="UseSeparateLogs=yes"
|
---|
| 236 | REPLACEMENT_2="UseSeparateLogs=no"
|
---|
| 237 | ORIGINAL_3="LogSeverity=none"
|
---|
| 238 | REPLACEMENT_3="LogSeverity=debug"
|
---|
| 239 | ORIGINAL_4="# SetClientTimeLimit=1800"
|
---|
| 240 | REPLACEMENT_4="SetClientTimeLimit=20"
|
---|
[34] | 241 | # takes too much time if we leave that in
|
---|
| 242 | ORIGINAL_5="dir=1"
|
---|
| 243 | REPLACEMENT_5="#dir=1"
|
---|
[19] | 244 | ex $RCFILE <<EOF
|
---|
[30] | 245 | %s/${ORIGINAL_1}/${REPLACEMENT_1}/g
|
---|
| 246 | %s/${ORIGINAL_2}/${REPLACEMENT_2}/g
|
---|
| 247 | %s/${ORIGINAL_3}/${REPLACEMENT_3}/g
|
---|
| 248 | %s/${ORIGINAL_4}/${REPLACEMENT_4}/g
|
---|
[34] | 249 | %s/${ORIGINAL_5}/${REPLACEMENT_5}/g
|
---|
[30] | 250 | wq
|
---|
[19] | 251 | EOF
|
---|
| 252 | # :%s is the "ex" substitution command.
|
---|
| 253 | # :wq is write-and-quit.
|
---|
| 254 | [ -z "$verbose" ] || {
|
---|
| 255 | echo;
|
---|
| 256 | echo "${S}Start Server${E}: ./yule -p none &";
|
---|
| 257 | echo;
|
---|
| 258 | }
|
---|
| 259 |
|
---|
| 260 | rm -f $LOGFILE
|
---|
[22] | 261 | rm -f test_log_valgrind
|
---|
[19] | 262 |
|
---|
[27] | 263 | ${VALGRIND} ./yule -p none -e none >/dev/null 2>>test_log_valgrind &
|
---|
[19] | 264 | PROC_Y=$!
|
---|
| 265 | sleep 5
|
---|
| 266 |
|
---|
| 267 | [ -z "$verbose" ] || {
|
---|
| 268 | echo;
|
---|
| 269 | echo "${S}Start Client${E}: ./samhain.new -l none -p none -t check";
|
---|
| 270 | echo;
|
---|
| 271 | }
|
---|
| 272 |
|
---|
[22] | 273 | ${VALGRIND} ./samhain.new -t check -p none -l none --forever --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind &
|
---|
[19] | 274 | if test x$? = x0; then
|
---|
| 275 | PROC_S=$!
|
---|
| 276 | # echo "PID is ${PROC_S}"
|
---|
| 277 | [ -z "$verbose" ] || log_msg_ok "samhain.new -t check";
|
---|
| 278 | sleep 5
|
---|
| 279 | # Redirect the shells (un-)helpful job monitoring messages.
|
---|
| 280 | # The 'disown' buildin is not portable.
|
---|
| 281 | { kill -9 ${PROC_S}; sleep 40; } >/dev/null 2>&1
|
---|
| 282 | else
|
---|
| 283 | [ -z "$quiet" ] && log_msg_fail "samhain.new -t check";
|
---|
| 284 | kill $PROC_Y
|
---|
| 285 | return 1
|
---|
| 286 | fi
|
---|
| 287 |
|
---|
| 288 | if [ -t 0 ]; then
|
---|
| 289 | # enable monitor mode again if interactive
|
---|
| 290 | set -m
|
---|
| 291 | fi
|
---|
| 292 |
|
---|
| 293 |
|
---|
| 294 | kill $PROC_Y
|
---|
| 295 | sleep 5
|
---|
| 296 |
|
---|
| 297 | egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
|
---|
| 298 | if [ $? -ne 0 ]; then
|
---|
| 299 | [ -z "$verbose" ] || log_msg_fail "Server start";
|
---|
| 300 | return 1
|
---|
| 301 | fi
|
---|
| 302 | egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1
|
---|
| 303 | if [ $? -ne 0 ]; then
|
---|
| 304 | [ -z "$verbose" ] || log_msg_fail "Client connect";
|
---|
| 305 | return 1
|
---|
| 306 | fi
|
---|
| 307 | egrep "remote_host.*File check completed.*" ${LOGFILE} >/dev/null 2>&1
|
---|
| 308 | if [ $? -ne 0 ]; then
|
---|
| 309 | [ -z "$verbose" ] || log_msg_fail "Client file check";
|
---|
| 310 | return 1
|
---|
| 311 | fi
|
---|
| 312 | egrep "Time limit exceeded" ${LOGFILE} >/dev/null 2>&1
|
---|
| 313 | if [ $? -ne 0 ]; then
|
---|
| 314 | [ -z "$verbose" ] || log_msg_fail "Client dead detection";
|
---|
| 315 | return 1
|
---|
| 316 | fi
|
---|
| 317 | egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1
|
---|
| 318 | if [ $? -ne 0 ]; then
|
---|
| 319 | [ -z "$verbose" ] || log_msg_fail "Server exit";
|
---|
| 320 | return 1
|
---|
| 321 | fi
|
---|
[22] | 322 |
|
---|
| 323 | [ -z "$VALGRIND" ] || {
|
---|
| 324 | tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
|
---|
| 325 | if [ $tmp -ne 0 ]; then
|
---|
| 326 | [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
|
---|
| 327 | cat test_log_valgrind
|
---|
| 328 | return 1;
|
---|
| 329 | fi;
|
---|
| 330 | }
|
---|
[19] | 331 |
|
---|
[22] | 332 | rm -f ${LOGFILE}
|
---|
[19] | 333 | return 0
|
---|
| 334 | }
|
---|
| 335 |
|
---|
[22] | 336 | do_test_4 () {
|
---|
| 337 |
|
---|
| 338 | # don't know what is supported on the test platform, so
|
---|
| 339 | # prepare for both (password and socket credential)
|
---|
| 340 |
|
---|
| 341 | # 'id -u' is posix
|
---|
| 342 | me=`id -u`
|
---|
| 343 |
|
---|
| 344 | ORIGINAL_1="SetSocketAllowUid=0"
|
---|
| 345 | REPLACEMENT_1="SetSocketAllowUid=$me"
|
---|
| 346 | ex $RCFILE <<EOF
|
---|
[30] | 347 | %s/${ORIGINAL_1}/${REPLACEMENT_1}/g
|
---|
| 348 | wq
|
---|
[22] | 349 | EOF
|
---|
| 350 |
|
---|
| 351 | [ -z "$verbose" ] || {
|
---|
| 352 | echo;
|
---|
| 353 | echo "${S}Start Server${E}: ./yule -l info -p none &";
|
---|
| 354 | echo;
|
---|
| 355 | }
|
---|
| 356 |
|
---|
| 357 | rm -f $LOGFILE
|
---|
| 358 | rm -f test_log_valgrind
|
---|
| 359 |
|
---|
[27] | 360 | ${VALGRIND} ./yule -l info -p none -e none \
|
---|
| 361 | >/dev/null 2>>test_log_valgrind &
|
---|
[22] | 362 | PROC_Y=$!
|
---|
| 363 | sleep 5
|
---|
| 364 |
|
---|
| 365 | [ -z "$verbose" ] || {
|
---|
| 366 | echo;
|
---|
| 367 | echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
|
---|
| 368 | echo;
|
---|
| 369 | }
|
---|
| 370 |
|
---|
| 371 | $MAKE yulectl >/dev/null
|
---|
| 372 | if [ $? -ne 0 ]; then
|
---|
| 373 | [ -z "$verbose" ] || log_msg_fail "make yulectl";
|
---|
| 374 | kill $PROC_Y
|
---|
| 375 | return 1
|
---|
| 376 | fi
|
---|
| 377 |
|
---|
| 378 |
|
---|
| 379 | ./yulectl -v -c RELOAD foobar1 >test_log_yulectl 2>/dev/null
|
---|
| 380 |
|
---|
| 381 | if [ $? -ne 0 ]; then
|
---|
| 382 | YULECTL_PASSWORD=samhain; export YULECTL_PASSWORD
|
---|
| 383 | ./yulectl -v -c RELOAD foobar1 >test_log_yulectl
|
---|
| 384 | if [ $? -ne 0 ]; then
|
---|
| 385 | kill ${PROC_Y}
|
---|
| 386 | [ -z "$verbose" ] || log_msg_fail "yulectl";
|
---|
| 387 | return 1
|
---|
| 388 | fi
|
---|
| 389 | fi
|
---|
| 390 |
|
---|
| 391 | ./yulectl -v -c RELOAD foobar2 >test_yulectl_log
|
---|
| 392 |
|
---|
| 393 | if [ $? -ne 0 ]; then
|
---|
| 394 | kill ${PROC_Y}
|
---|
| 395 | [ -z "$verbose" ] || log_msg_fail "yulectl";
|
---|
| 396 | return 1
|
---|
| 397 | fi
|
---|
| 398 |
|
---|
| 399 | ./yulectl -v -c RELOAD foobar3 >test_log_yulectl
|
---|
| 400 |
|
---|
| 401 | if [ $? -ne 0 ]; then
|
---|
| 402 | kill ${PROC_Y}
|
---|
| 403 | [ -z "$verbose" ] || log_msg_fail "yulectl";
|
---|
| 404 | return 1
|
---|
| 405 | fi
|
---|
| 406 |
|
---|
| 407 | ./yulectl -v -c LISTALL dummy >test_log_yulectl
|
---|
| 408 |
|
---|
| 409 | if [ $? -ne 0 ]; then
|
---|
| 410 | kill ${PROC_Y}
|
---|
| 411 | [ -z "$verbose" ] || log_msg_fail "yulectl";
|
---|
| 412 | return 1
|
---|
| 413 | fi
|
---|
| 414 |
|
---|
| 415 | tmp=`cat test_log_yulectl | grep RELOAD | wc -l`
|
---|
| 416 | if [ $tmp -ne 3 ]; then
|
---|
| 417 | kill ${PROC_Y}
|
---|
| 418 | [ -z "$verbose" ] || log_msg_fail "command confirmation";
|
---|
| 419 | return 1
|
---|
| 420 | fi
|
---|
| 421 |
|
---|
| 422 | ./yulectl -v -c CANCEL foobar3 >test_log_yulectl
|
---|
| 423 |
|
---|
| 424 | if [ $? -ne 0 ]; then
|
---|
| 425 | kill ${PROC_Y}
|
---|
| 426 | [ -z "$verbose" ] || log_msg_fail "yulectl";
|
---|
| 427 | return 1
|
---|
| 428 | fi
|
---|
| 429 |
|
---|
| 430 | ./yulectl -v -c LISTALL dummy >test_log_yulectl
|
---|
| 431 |
|
---|
| 432 | if [ $? -ne 0 ]; then
|
---|
| 433 | kill ${PROC_Y}
|
---|
| 434 | [ -z "$verbose" ] || log_msg_fail "yulectl";
|
---|
| 435 | return 1
|
---|
| 436 | fi
|
---|
| 437 |
|
---|
| 438 | tmp=`cat test_log_yulectl | grep RELOAD | wc -l`
|
---|
| 439 | if [ $tmp -ne 2 ]; then
|
---|
| 440 | kill ${PROC_Y}
|
---|
| 441 | [ -z "$verbose" ] || log_msg_fail "command confirmation";
|
---|
| 442 | return 1
|
---|
| 443 | fi
|
---|
| 444 |
|
---|
| 445 | kill ${PROC_Y}
|
---|
[30] | 446 | sleep 2
|
---|
| 447 | kill -9 ${PROC_Y} >/dev/null 2>&1
|
---|
[22] | 448 |
|
---|
| 449 | [ -z "$VALGRIND" ] || {
|
---|
| 450 | tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
|
---|
| 451 | if [ $tmp -ne 0 ]; then
|
---|
| 452 | [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
|
---|
| 453 | cat test_log_valgrind
|
---|
| 454 | return 1;
|
---|
| 455 | fi;
|
---|
| 456 | }
|
---|
| 457 |
|
---|
| 458 | return 0
|
---|
| 459 | }
|
---|
| 460 |
|
---|
| 461 | do_test_5 () {
|
---|
| 462 |
|
---|
| 463 | [ -z "$verbose" ] || {
|
---|
| 464 | echo;
|
---|
| 465 | echo "${S}Start Server${E}: ./yule -l info -p none &";
|
---|
| 466 | echo;
|
---|
| 467 | }
|
---|
| 468 |
|
---|
| 469 | ( cat <<EOF
|
---|
| 470 | <!-- head -->
|
---|
| 471 | <html><head><title>test</title></head>
|
---|
| 472 | <body>
|
---|
| 473 | Current time: %T <br>
|
---|
| 474 | <table>
|
---|
| 475 | <!-- ehead -->
|
---|
| 476 | EOF
|
---|
| 477 | ) >head.html
|
---|
| 478 |
|
---|
| 479 | ( cat <<EOF
|
---|
| 480 | <!-- foot -->
|
---|
| 481 | </table>
|
---|
| 482 | </body>
|
---|
| 483 | <!-- efoot -->
|
---|
| 484 | EOF
|
---|
| 485 | ) >foot.html
|
---|
| 486 |
|
---|
| 487 | ( cat <<EOF
|
---|
| 488 | <!-- entry -->
|
---|
| 489 | <tr>
|
---|
| 490 | <td>%H</td>
|
---|
| 491 | <td>%S</td>
|
---|
| 492 | <td>%T</td>
|
---|
| 493 | </tr>
|
---|
| 494 | <!-- eentry -->
|
---|
| 495 | EOF
|
---|
| 496 | ) >entry.html
|
---|
| 497 |
|
---|
[27] | 498 | ${VALGRIND} ./yule -l info -p none -e none \
|
---|
| 499 | >/dev/null 2>>test_log_valgrind &
|
---|
[22] | 500 | PROC_Y=$!
|
---|
| 501 | sleep 5
|
---|
| 502 |
|
---|
| 503 | egrep '<!-- head -->' $HTML >/dev/null 2>&1
|
---|
| 504 | if [ $? -ne 0 ]; then
|
---|
[27] | 505 | # rm -f head.html; rm -f foot.html; rm -f entry.html;
|
---|
[22] | 506 | kill $PROC_Y
|
---|
[27] | 507 | [ -z "$verbose" ] || log_msg_fail "head.html (1)";
|
---|
[22] | 508 | return 1
|
---|
| 509 | fi
|
---|
| 510 |
|
---|
| 511 | egrep '<!-- foot -->' $HTML >/dev/null 2>&1
|
---|
| 512 | if [ $? -ne 0 ]; then
|
---|
| 513 | rm -f head.html; rm -f foot.html; rm -f entry.html;
|
---|
| 514 | kill $PROC_Y
|
---|
[27] | 515 | [ -z "$verbose" ] || log_msg_fail "foot.html (1)";
|
---|
[22] | 516 | return 1
|
---|
| 517 | fi
|
---|
| 518 |
|
---|
| 519 | [ -z "$verbose" ] || {
|
---|
| 520 | echo;
|
---|
| 521 | echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
|
---|
| 522 | echo;
|
---|
| 523 | }
|
---|
| 524 |
|
---|
| 525 | ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind
|
---|
| 526 | if test x$? = x0; then
|
---|
| 527 | [ -z "$verbose" ] || log_msg_ok "samhain.new -t check";
|
---|
| 528 | else
|
---|
| 529 | kill $PROC_Y
|
---|
| 530 | [ -z "$quiet" ] && log_msg_fail "samhain.new -t check";
|
---|
| 531 | return 1
|
---|
| 532 | fi
|
---|
| 533 |
|
---|
| 534 | kill $PROC_Y
|
---|
| 535 | sleep 5
|
---|
| 536 |
|
---|
| 537 | # rm -f head.html; rm -f foot.html; rm -f entry.html;
|
---|
| 538 |
|
---|
| 539 | egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
|
---|
| 540 | if [ $? -ne 0 ]; then
|
---|
| 541 | [ -z "$verbose" ] || log_msg_fail "Server start";
|
---|
| 542 | return 1
|
---|
| 543 | fi
|
---|
| 544 | egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1
|
---|
| 545 | if [ $? -ne 0 ]; then
|
---|
| 546 | [ -z "$verbose" ] || log_msg_fail "Client connect";
|
---|
| 547 | return 1
|
---|
| 548 | fi
|
---|
| 549 | egrep "remote_host.*Checking.*/bin" $LOGFILE >/dev/null 2>&1
|
---|
| 550 | if [ $? -ne 0 ]; then
|
---|
| 551 | [ -z "$verbose" ] || log_msg_fail "Client file check";
|
---|
| 552 | return 1
|
---|
| 553 | fi
|
---|
| 554 | egrep "remote_host.*EXIT.*Samhain" $LOGFILE >/dev/null 2>&1
|
---|
| 555 | if [ $? -ne 0 ]; then
|
---|
| 556 | [ -z "$verbose" ] || log_msg_fail "Client exit";
|
---|
| 557 | return 1
|
---|
| 558 | fi
|
---|
| 559 | egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1
|
---|
| 560 | if [ $? -ne 0 ]; then
|
---|
| 561 | [ -z "$verbose" ] || log_msg_fail "Server exit";
|
---|
| 562 | return 1
|
---|
| 563 | fi
|
---|
| 564 |
|
---|
| 565 | egrep '<!-- head -->' $HTML >/dev/null 2>&1
|
---|
| 566 | if [ $? -ne 0 ]; then
|
---|
| 567 | [ -z "$verbose" ] || log_msg_fail "head.html";
|
---|
| 568 | return 1
|
---|
| 569 | fi
|
---|
| 570 | egrep '<!-- ehead -->' $HTML >/dev/null 2>&1
|
---|
| 571 | if [ $? -ne 0 ]; then
|
---|
[27] | 572 | [ -z "$verbose" ] || log_msg_fail "end head.html";
|
---|
[22] | 573 | return 1
|
---|
| 574 | fi
|
---|
| 575 |
|
---|
| 576 | egrep '<!-- entry -->' $HTML >/dev/null 2>&1
|
---|
| 577 | if [ $? -ne 0 ]; then
|
---|
| 578 | [ -z "$verbose" ] || log_msg_fail "entry.html";
|
---|
| 579 | return 1
|
---|
| 580 | fi
|
---|
| 581 | egrep '<!-- eentry -->' $HTML >/dev/null 2>&1
|
---|
| 582 | if [ $? -ne 0 ]; then
|
---|
[27] | 583 | [ -z "$verbose" ] || log_msg_fail "end entry.html";
|
---|
[22] | 584 | return 1
|
---|
| 585 | fi
|
---|
| 586 |
|
---|
| 587 | egrep '<!-- foot -->' $HTML >/dev/null 2>&1
|
---|
| 588 | if [ $? -ne 0 ]; then
|
---|
| 589 | [ -z "$verbose" ] || log_msg_fail "foot.html";
|
---|
| 590 | return 1
|
---|
| 591 | fi
|
---|
| 592 | egrep '<!-- efoot -->' $HTML >/dev/null 2>&1
|
---|
| 593 | if [ $? -ne 0 ]; then
|
---|
[27] | 594 | [ -z "$verbose" ] || log_msg_fail "end foot.html";
|
---|
[22] | 595 | return 1
|
---|
| 596 | fi
|
---|
| 597 |
|
---|
| 598 | [ -z "$VALGRIND" ] || {
|
---|
| 599 | tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
|
---|
| 600 | if [ $tmp -ne 0 ]; then
|
---|
| 601 | [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
|
---|
| 602 | cat test_log_valgrind
|
---|
| 603 | return 1;
|
---|
| 604 | fi;
|
---|
| 605 | }
|
---|
| 606 |
|
---|
| 607 | return 0
|
---|
| 608 | }
|
---|
| 609 |
|
---|
| 610 |
|
---|
[19] | 611 | testrun2_internal ()
|
---|
[1] | 612 | {
|
---|
[19] | 613 | [ -z "$verbose" ] || {
|
---|
| 614 | echo;
|
---|
| 615 | echo Working directory: $PW_DIR; echo MAKE is $MAKE;
|
---|
| 616 | echo;
|
---|
| 617 | }
|
---|
[1] | 618 | #
|
---|
| 619 | #
|
---|
[19] | 620 | [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; }
|
---|
[1] | 621 | #
|
---|
| 622 | if test -r "Makefile"; then
|
---|
| 623 | $MAKE distclean
|
---|
| 624 | fi
|
---|
| 625 | #
|
---|
[19] | 626 | ${TOP_SRCDIR}/configure --quiet $TRUST --enable-debug --enable-network=client --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-encrypt=2
|
---|
[1] | 627 | #
|
---|
| 628 | if test x$? = x0; then
|
---|
[19] | 629 | [ -z "$verbose" ] || log_msg_ok "configure...";
|
---|
| 630 | $MAKE > /dev/null 2>>test_log
|
---|
[1] | 631 | if test x$? = x0; then
|
---|
[19] | 632 | [ -z "$verbose" ] || log_msg_ok "make...";
|
---|
[1] | 633 | else
|
---|
[19] | 634 | [ -z "$quiet" ] && log_msg_fail "make...";
|
---|
| 635 | return 1
|
---|
[1] | 636 | fi
|
---|
| 637 |
|
---|
| 638 | else
|
---|
[19] | 639 | [ -z "$quiet" ] && log_msg_fail "configure...";
|
---|
| 640 | return 1
|
---|
[1] | 641 | fi
|
---|
| 642 |
|
---|
[27] | 643 | # save binary and build server2
|
---|
[1] | 644 | #
|
---|
[19] | 645 | cp samhain samhain.build || return 1
|
---|
[30] | 646 | $MAKE clean >/dev/null || return 1
|
---|
[1] | 647 |
|
---|
[27] | 648 | ${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}2 --with-log-file=${LOGFILE}2 --with-pid-file=$PW_DIR/.samhain_lock2 --with-html-file=${HTML}2 --with-state-dir=$PW_DIR --enable-encrypt=2 --with-port=49778
|
---|
[1] | 649 | #
|
---|
| 650 | if test x$? = x0; then
|
---|
[19] | 651 | [ -z "$verbose" ] || log_msg_ok "configure...";
|
---|
| 652 | $MAKE > /dev/null 2>>test_log
|
---|
[1] | 653 | if test x$? = x0; then
|
---|
[19] | 654 | [ -z "$verbose" ] || log_msg_ok "make...";
|
---|
[1] | 655 | else
|
---|
[19] | 656 | [ -z "$quiet" ] && log_msg_fail "make...";
|
---|
| 657 | return 1
|
---|
[1] | 658 | fi
|
---|
| 659 |
|
---|
| 660 | else
|
---|
[19] | 661 | [ -z "$quiet" ] && log_msg_fail "configure...";
|
---|
| 662 | return 1
|
---|
[1] | 663 | fi
|
---|
| 664 |
|
---|
[27] | 665 | # save binary and build server
|
---|
| 666 | #
|
---|
| 667 | cp yule yule.2 || return 1
|
---|
[30] | 668 | $MAKE clean >/dev/null || return 1
|
---|
[19] | 669 |
|
---|
[27] | 670 | ${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-html-file=$HTML --with-state-dir=$PW_DIR --enable-encrypt=2
|
---|
| 671 | #
|
---|
| 672 | if test x$? = x0; then
|
---|
| 673 | [ -z "$verbose" ] || log_msg_ok "configure...";
|
---|
| 674 | $MAKE > /dev/null 2>>test_log
|
---|
| 675 | if test x$? = x0; then
|
---|
| 676 | [ -z "$verbose" ] || log_msg_ok "make...";
|
---|
| 677 | else
|
---|
| 678 | [ -z "$quiet" ] && log_msg_fail "make...";
|
---|
| 679 | return 1
|
---|
| 680 | fi
|
---|
| 681 |
|
---|
| 682 | else
|
---|
| 683 | [ -z "$quiet" ] && log_msg_fail "configure...";
|
---|
| 684 | return 1
|
---|
| 685 | fi
|
---|
| 686 |
|
---|
| 687 |
|
---|
[1] | 688 | #####################################################################
|
---|
| 689 | #
|
---|
| 690 | #
|
---|
| 691 | rm -f ./.samhain_file
|
---|
| 692 | rm -f ./.samhain_log
|
---|
| 693 | rm -f ./.samhain_lock
|
---|
| 694 |
|
---|
| 695 | cp ${SCRIPTDIR}/testrc_2.in testrc_2
|
---|
| 696 |
|
---|
[19] | 697 | ./samhain.build -t init -p none
|
---|
[1] | 698 |
|
---|
[19] | 699 | if test x$? = x0; then
|
---|
| 700 | [ -z "$verbose" ] || log_msg_ok "init...";
|
---|
| 701 | else
|
---|
| 702 | [ -z "$quiet" ] && log_msg_fail "init...";
|
---|
| 703 | return 1
|
---|
| 704 | fi
|
---|
[1] | 705 |
|
---|
| 706 | # Create a password
|
---|
| 707 |
|
---|
| 708 | SHPW=`./yule -G`
|
---|
| 709 | if test x"$SHPW" = x; then
|
---|
[19] | 710 | [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting"
|
---|
| 711 | return 1
|
---|
[1] | 712 | fi
|
---|
| 713 |
|
---|
| 714 | # Set in client
|
---|
| 715 |
|
---|
[19] | 716 | ./samhain_setpwd samhain.build new $SHPW >/dev/null
|
---|
[1] | 717 |
|
---|
[19] | 718 | if test x$? = x0; then
|
---|
| 719 | [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd samhain.build new $SHPW";
|
---|
| 720 | else
|
---|
| 721 | [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd samhain.build new $SHPW";
|
---|
| 722 | return 1
|
---|
| 723 | fi
|
---|
[1] | 724 |
|
---|
[19] | 725 | mv samhain.build.new samhain.new || return 1
|
---|
| 726 |
|
---|
[27] | 727 | # Set in server
|
---|
[1] | 728 |
|
---|
[27] | 729 | ./samhain_setpwd yule new $SHPW >/dev/null
|
---|
| 730 |
|
---|
| 731 | if test x$? = x0; then
|
---|
| 732 | [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd yule new $SHPW";
|
---|
| 733 | else
|
---|
| 734 | [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd yule new $SHPW";
|
---|
| 735 | return 1
|
---|
| 736 | fi
|
---|
| 737 |
|
---|
| 738 | mv yule.new yule || return 1
|
---|
| 739 |
|
---|
| 740 | #
|
---|
| 741 |
|
---|
| 742 | rm -f ./.samhain_log*
|
---|
| 743 | rm -f ./.samhain_lock*
|
---|
| 744 |
|
---|
[29] | 745 | SHCLT=`./yule -P $SHPW`
|
---|
[1] | 746 |
|
---|
[19] | 747 | if test x$? = x0; then
|
---|
| 748 | [ -z "$verbose" ] || log_msg_ok "yule -P $SHPW";
|
---|
| 749 | else
|
---|
| 750 | [ -z "$quiet" ] && log_msg_fail "yule -P $SHPW";
|
---|
| 751 | return 1
|
---|
| 752 | fi
|
---|
| 753 |
|
---|
[29] | 754 | SHCLT1=`echo "${SHCLT}" | sed s%HOSTNAME%${SH_LOCALHOST}%`
|
---|
| 755 | AHOST=`find_hostname`
|
---|
| 756 | SHCLT2=`echo "${SHCLT}" | sed s%HOSTNAME%${AHOST}%`
|
---|
| 757 |
|
---|
| 758 |
|
---|
| 759 | echo $SHCLT1 >> testrc_2
|
---|
| 760 | echo $SHCLT2 >> testrc_2
|
---|
[27] | 761 | cp testrc_2 testrc_22
|
---|
[1] | 762 |
|
---|
[19] | 763 | do_test_1
|
---|
| 764 | if [ $? -eq 0 ]; then
|
---|
| 765 | [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client logging";
|
---|
| 766 | else
|
---|
| 767 | [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client logging";
|
---|
| 768 | fi
|
---|
[1] | 769 |
|
---|
[19] | 770 | do_test_2
|
---|
| 771 | if [ $? -eq 0 ]; then
|
---|
[22] | 772 | [ -z "$quiet" ] && log_ok 2 ${MAXTEST} "Client logging, separate logfiles";
|
---|
[19] | 773 | else
|
---|
[22] | 774 | [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "Client logging, separate logfiles";
|
---|
[19] | 775 | fi
|
---|
[1] | 776 |
|
---|
[19] | 777 | do_test_3
|
---|
| 778 | if [ $? -eq 0 ]; then
|
---|
| 779 | [ -z "$quiet" ] && log_ok 3 ${MAXTEST} "Dead client detection";
|
---|
[1] | 780 | else
|
---|
[19] | 781 | [ -z "$quiet" ] && log_fail 3 ${MAXTEST} "Dead client detection";
|
---|
[1] | 782 | fi
|
---|
[19] | 783 |
|
---|
[22] | 784 | do_test_4
|
---|
| 785 | if [ $? -eq 0 ]; then
|
---|
| 786 | [ -z "$quiet" ] && log_ok 4 ${MAXTEST} "Server command socket";
|
---|
| 787 | else
|
---|
| 788 | [ -z "$quiet" ] && log_fail 4 ${MAXTEST} "Server command socket";
|
---|
| 789 | fi
|
---|
| 790 |
|
---|
| 791 | do_test_5
|
---|
| 792 | if [ $? -eq 0 ]; then
|
---|
| 793 | [ -z "$quiet" ] && log_ok 5 ${MAXTEST} "Server status file";
|
---|
| 794 | else
|
---|
| 795 | [ -z "$quiet" ] && log_fail 5 ${MAXTEST} "Server status file";
|
---|
| 796 | fi
|
---|
| 797 |
|
---|
[19] | 798 | return $?
|
---|
[1] | 799 | }
|
---|
| 800 |
|
---|
[22] | 801 | MAXTEST=5; export MAXTEST
|
---|
[19] | 802 |
|
---|
| 803 | testrun2 ()
|
---|
| 804 | {
|
---|
| 805 | log_start "RUN CLIENT/SERVER"
|
---|
| 806 |
|
---|
| 807 | if [ x"$1" = x ]; then
|
---|
| 808 | [ -z "$quiet" ] && log_msg_fail "Missing hostname"
|
---|
[1] | 809 | fi
|
---|
[19] | 810 | #
|
---|
[1] | 811 | SH_LOCALHOST=$1; export SH_LOCALHOST
|
---|
[19] | 812 | #
|
---|
| 813 | testrun2_internal
|
---|
| 814 | #
|
---|
| 815 | log_end "RUN CLIENT/SERVER"
|
---|
[1] | 816 |
|
---|
[19] | 817 | return 0
|
---|
| 818 | }
|
---|
[1] | 819 |
|
---|