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