[1] | 1 | #! /bin/sh
|
---|
| 2 |
|
---|
[19] | 3 | LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
|
---|
| 4 | RCFILE="$PW_DIR/testrc_2"; export RCFILE
|
---|
| 5 | RCFILE_C="$PW_DIR/testrc_1.dyn"; export RCFILE_C
|
---|
[1] | 6 |
|
---|
[19] | 7 | 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] | 8 |
|
---|
[19] | 9 | CLIENT_BUILDOPTS="--quiet $TRUST --enable-micro-stealth=137 --enable-debug --enable-network=client --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER${RCFILE_C} --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] | 10 |
|
---|
[19] | 11 | testrun2b_internal ()
|
---|
| 12 | {
|
---|
| 13 | GPG="$1"
|
---|
[1] | 14 |
|
---|
[19] | 15 | [ -z "$verbose" ] || {
|
---|
| 16 | echo;
|
---|
| 17 | echo Working directory: $PW_DIR; echo MAKE is $MAKE; echo GPG is $GPG;
|
---|
| 18 | echo;
|
---|
| 19 | }
|
---|
[1] | 20 |
|
---|
[19] | 21 | [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; }
|
---|
[1] | 22 |
|
---|
[19] | 23 | if test -r "Makefile"; then
|
---|
| 24 | $MAKE distclean
|
---|
[1] | 25 | fi
|
---|
| 26 |
|
---|
[19] | 27 | ${TOP_SRCDIR}/configure --with-gpg=${GPG} --with-checksum=no ${CLIENT_BUILDOPTS} >/dev/null 2>&1
|
---|
[1] | 28 |
|
---|
[19] | 29 | if test x$? = x0; then
|
---|
| 30 | [ -z "$verbose" ] || log_msg_ok "configure...";
|
---|
| 31 | $MAKE > /dev/null 2>>test_log
|
---|
| 32 | if test x$? = x0; then
|
---|
| 33 | [ -z "$verbose" ] || log_msg_ok "make...";
|
---|
| 34 | else
|
---|
| 35 | [ -z "$quiet" ] && log_msg_fail "make...";
|
---|
| 36 | return 1
|
---|
| 37 | fi
|
---|
[1] | 38 | else
|
---|
[19] | 39 | [ -z "$quiet" ] && log_msg_fail "configure...";
|
---|
| 40 | return 1
|
---|
[1] | 41 | fi
|
---|
[19] | 42 |
|
---|
| 43 | SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ { print NR + 1; exit 0; }' ${SCRIPTDIR}/test.sh`
|
---|
| 44 |
|
---|
| 45 | tail -n "+$SKIP" ${SCRIPTDIR}/test.sh >/dev/null 2>&1
|
---|
| 46 | if [ $? -eq 0 ]; then
|
---|
| 47 | tail -n "+$SKIP" ${SCRIPTDIR}/test.sh | gunzip -c - | tar xf - && \
|
---|
| 48 | mv "./testrc.gpg.asc" "${RCFILE_C}"
|
---|
| 49 | else
|
---|
| 50 | tail "+$SKIP" ${SCRIPTDIR}/test.sh | gunzip -c - | tar xf - && \
|
---|
| 51 | mv "./testrc.gpg.asc" "${RCFILE_C}"
|
---|
| 52 | fi
|
---|
| 53 | if test x$? = x0; then
|
---|
| 54 | [ -z "$verbose" ] || log_msg_ok "extract gpg signed files...";
|
---|
| 55 | else
|
---|
| 56 | [ -z "$quiet" ] && log_msg_fail "extract gpg signed files...";
|
---|
| 57 | return 1
|
---|
| 58 | fi
|
---|
[1] | 59 |
|
---|
[19] | 60 | # save binary and build server
|
---|
[1] | 61 |
|
---|
[19] | 62 | cp samhain samhain.build || return 1
|
---|
| 63 | make clean >/dev/null || return 1
|
---|
| 64 |
|
---|
| 65 | ${TOP_SRCDIR}/configure ${SERVER_BUILDOPTS}
|
---|
[1] | 66 |
|
---|
[19] | 67 | if test x$? = x0; then
|
---|
| 68 | [ -z "$verbose" ] || log_msg_ok "configure...";
|
---|
| 69 | $MAKE > /dev/null 2>>test_log
|
---|
[1] | 70 | if test x$? = x0; then
|
---|
[19] | 71 | [ -z "$verbose" ] || log_msg_ok "make...";
|
---|
[1] | 72 | else
|
---|
[19] | 73 | [ -z "$quiet" ] && log_msg_fail "make...";
|
---|
| 74 | return 1
|
---|
[1] | 75 | fi
|
---|
[19] | 76 |
|
---|
| 77 | else
|
---|
| 78 | [ -z "$quiet" ] && log_msg_fail "configure...";
|
---|
| 79 | return 1
|
---|
| 80 | fi
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 | #####################################################################
|
---|
| 84 | #
|
---|
| 85 | #
|
---|
| 86 | rm -f ./.samhain_file
|
---|
| 87 | rm -f ./.samhain_log
|
---|
| 88 | rm -f ./.samhain_lock
|
---|
| 89 | rm -f ./rc.${SH_LOCALHOST}
|
---|
| 90 | rm -f ./file.${SH_LOCALHOST}
|
---|
| 91 |
|
---|
| 92 | cp ${SCRIPTDIR}/testrc_2.in testrc_2
|
---|
| 93 |
|
---|
| 94 | ./samhain.build -t init -p none
|
---|
| 95 |
|
---|
| 96 | if test x$? = x0; then
|
---|
| 97 | [ -z "$verbose" ] || log_msg_ok "init...";
|
---|
| 98 | else
|
---|
| 99 | [ -z "$quiet" ] && log_msg_fail "init...";
|
---|
| 100 | return 1
|
---|
| 101 | fi
|
---|
| 102 |
|
---|
| 103 | # Create a password
|
---|
[1] | 104 |
|
---|
[19] | 105 | SHPW=`./yule -G`
|
---|
| 106 | if test x"$SHPW" = x; then
|
---|
| 107 | [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting"
|
---|
| 108 | return 1
|
---|
| 109 | fi
|
---|
| 110 |
|
---|
| 111 | # Set in client
|
---|
| 112 |
|
---|
| 113 | ./samhain_setpwd samhain.build new $SHPW >/dev/null
|
---|
| 114 |
|
---|
| 115 | if test x$? = x0; then
|
---|
| 116 | [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd samhain.build new $SHPW";
|
---|
| 117 | else
|
---|
| 118 | [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd samhain.build new $SHPW";
|
---|
| 119 | return 1
|
---|
| 120 | fi
|
---|
| 121 |
|
---|
| 122 | mv samhain.build.new samhain.new || return 1
|
---|
| 123 |
|
---|
| 124 | rm -f ./.samhain_log*
|
---|
| 125 | rm -f ./.samhain_lock
|
---|
| 126 |
|
---|
| 127 | SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%`
|
---|
| 128 |
|
---|
| 129 | if test x$? = x0; then
|
---|
| 130 | [ -z "$verbose" ] || log_msg_ok "yule -P $SHPW";
|
---|
| 131 | else
|
---|
| 132 | [ -z "$quiet" ] && log_msg_fail "yule -P $SHPW";
|
---|
| 133 | return 1
|
---|
| 134 | fi
|
---|
| 135 |
|
---|
| 136 | echo $SHCLT >> testrc_2
|
---|
| 137 |
|
---|
| 138 | cp "${RCFILE_C}" ./rc.${SH_LOCALHOST}
|
---|
| 139 | mv $PW_DIR/.samhain_file.asc ./file.${SH_LOCALHOST}
|
---|
[1] | 140 |
|
---|
[19] | 141 | ALTHOST=`find_hostname`
|
---|
[22] | 142 | cp "${RCFILE_C}" "./rc.${ALTHOST}"
|
---|
[19] | 143 | cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null
|
---|
| 144 | }
|
---|
[1] | 145 |
|
---|
[19] | 146 | MAXTEST=1; export MAXTEST
|
---|
[1] | 147 |
|
---|
[19] | 148 | testrun2b ()
|
---|
| 149 | {
|
---|
| 150 | log_start "RUN FULL CLIENT/SERVER W/GPG";
|
---|
| 151 | #
|
---|
| 152 | if [ x"$1" = x ]; then
|
---|
| 153 | [ -z "$quiet" ] && log_msg_fail "Missing hostname"
|
---|
| 154 | fi
|
---|
| 155 | #
|
---|
| 156 | GPG=`find_path gpg`
|
---|
| 157 | if [ -z "$GPG" ]; then
|
---|
| 158 | log_skip 1 $MAXTEST 'gpg not found in $PATH'
|
---|
| 159 | else
|
---|
| 160 | eval "$GPG" --list-keys 0F571F6C >/dev/null 2>/dev/null
|
---|
| 161 | if [ $? -ne 0 ]; then
|
---|
| 162 | log_skip 1 $MAXTEST 'public PGP key 0x0F571F6C not present'
|
---|
[1] | 163 | else
|
---|
[19] | 164 |
|
---|
| 165 | SH_LOCALHOST=$1; export SH_LOCALHOST
|
---|
| 166 |
|
---|
| 167 | testrun2b_internal "$GPG"
|
---|
[22] | 168 |
|
---|
| 169 | SAVE_VALGRIND="${VALGRIND}"; VALGRIND=''; export VALGRIND
|
---|
[19] | 170 | do_test_1_a
|
---|
[22] | 171 | VALGRIND="${SAVE_VALGRIND}"; export VALGRIND
|
---|
[19] | 172 | if [ $? -eq 0 ]; then
|
---|
| 173 | [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client download+logging w/gpg";
|
---|
| 174 | else
|
---|
| 175 | [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client download+logging w/gpg";
|
---|
| 176 | fi
|
---|
| 177 |
|
---|
| 178 | if [ -n "$cleanup" ]; then
|
---|
| 179 | rm -f ./rc.${SH_LOCALHOST}
|
---|
| 180 | rm -f ./file.${SH_LOCALHOST}
|
---|
| 181 | ALTHOST=`find_hostname`
|
---|
| 182 | rm -f "./file.${ALTHOST}"
|
---|
| 183 | rm -f "./rc.${ALTHOST}"
|
---|
| 184 | fi
|
---|
[1] | 185 | fi
|
---|
[19] | 186 | fi
|
---|
| 187 | log_end "RUN FULL CLIENT/SERVER W/GPG"
|
---|
[1] | 188 | }
|
---|
| 189 |
|
---|