source: trunk/test/testrun_2a.sh@ 469

Last change on this file since 469 was 467, checked in by katerina, 10 years ago

Fix for ticket #365 (cl option to choose log server).

File size: 8.6 KB
RevLine 
[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]22LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
23RCFILE="$PW_DIR/testrc_2"; export RCFILE
[1]24
[172]25SERVER_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
[467]27CLIENT_BUILDOPTS="--quiet $TRUST --enable-network=client --enable-srp --prefix=$PW_DIR --with-tmp-dir=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$RCFILE --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --enable-suidcheck"; export CLIENT_BUILDOPTS
[1]28
[19]29do_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=$!
[51]40 five_sec_sleep
[1]41
[19]42 [ -z "$verbose" ] || {
43 echo;
[467]44 echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check --bind-address=127.0.0.1 --server-host=localhost";
[19]45 echo;
46 }
47
[467]48 ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 --server-host=localhost >/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
[51]58 five_sec_sleep
[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]98testrun2a_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 #
[44]115 # Limit suid check
116 #
117 BASE="${PW_DIR}"; export BASE
118 #
[1]119 if test x$? = x0; then
[19]120 [ -z "$verbose" ] || log_msg_ok "configure...";
[44]121 $MAKE 'DBGDEF=-DSH_SUIDTESTDIR=\"${BASE}\"' > /dev/null 2>>test_log
[1]122 if test x$? = x0; then
[19]123 [ -z "$verbose" ] || log_msg_ok "make...";
[1]124 else
[19]125 [ -z "$quiet" ] && log_msg_fail "make...";
126 return 1
[1]127 fi
128
129 else
[19]130 [ -z "$quiet" ] && log_msg_fail "configure...";
131 return 1
[1]132 fi
133
134 # save binary and build server
135 #
[19]136 cp samhain samhain.build || return 1
[30]137 $MAKE clean >/dev/null || return 1
[1]138
[19]139 ${TOP_SRCDIR}/configure ${SERVER_BUILDOPTS}
[1]140 #
141 if test x$? = x0; then
[19]142 [ -z "$verbose" ] || log_msg_ok "configure...";
143 $MAKE > /dev/null 2>>test_log
[1]144 if test x$? = x0; then
[19]145 [ -z "$verbose" ] || log_msg_ok "make...";
[1]146 else
[19]147 [ -z "$quiet" ] && log_msg_fail "make...";
148 return 1
[1]149 fi
150
151 else
[19]152 [ -z "$quiet" ] && log_msg_fail "configure...";
153 return 1
[1]154 fi
155
156
[19]157 #####################################################################
158 #
159 #
[1]160 rm -f ./.samhain_file
161 rm -f ./.samhain_log
162 rm -f ./.samhain_lock
163 rm -f ./rc.${SH_LOCALHOST}
164 rm -f ./file.${SH_LOCALHOST}
[25]165 rm -f "./rc.${ALTHOST}"
166 rm -f "./file.${ALTHOST}"
[1]167
168 cp ${SCRIPTDIR}/testrc_2.in testrc_2
169
[19]170 ./samhain.build -t init -p none
[1]171
[19]172 if test x$? = x0; then
173 [ -z "$verbose" ] || log_msg_ok "init...";
174 else
175 [ -z "$quiet" ] && log_msg_fail "init...";
176 return 1
177 fi
[1]178
179 # Create a password
180
181 SHPW=`./yule -G`
182 if test x"$SHPW" = x; then
[19]183 [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting"
184 return 1
[1]185 fi
186
187 # Set in client
188
[19]189 ./samhain_setpwd samhain.build new $SHPW >/dev/null
[1]190
[19]191 if test x$? = x0; then
192 [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd samhain.build new $SHPW";
193 else
194 [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd samhain.build new $SHPW";
195 return 1
196 fi
[1]197
[19]198 mv samhain.build.new samhain.new || return 1
199
200 rm -f ./.samhain_log*
[1]201 rm -f ./.samhain_lock
202
[29]203 SHCLT=`./yule -P $SHPW`
[1]204
[19]205 if test x$? = x0; then
206 [ -z "$verbose" ] || log_msg_ok "yule -P $SHPW";
207 else
208 [ -z "$quiet" ] && log_msg_fail "yule -P $SHPW";
209 return 1
210 fi
211
[29]212 SHCLT1=`echo "${SHCLT}" | sed s%HOSTNAME%${SH_LOCALHOST}%`
213 AHOST=`find_hostname`
214 SHCLT2=`echo "${SHCLT}" | sed s%HOSTNAME%${AHOST}%`
215
[1]216
[29]217 echo $SHCLT1 >> testrc_2
218 echo $SHCLT2 >> testrc_2
219
220
[19]221 cp ./testrc_2 ./rc.${SH_LOCALHOST}
222 mv ./.samhain_file ./file.${SH_LOCALHOST}
[207]223 chmod 644 ./rc.${SH_LOCALHOST}
224 chmod 644 ./file.${SH_LOCALHOST}
[1]225
[19]226 ALTHOST=`find_hostname`
227 cp ./testrc_2 "./rc.${ALTHOST}"
228 cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null
[207]229 chmod 644 ./rc.${ALTHOST}
230 chmod 644 ./file.${ALTHOST}
[226]231
232 echo $SHPW > ./testpw
[1]233}
234
[25]235MAXTEST=5; export MAXTEST
[19]236
237testrun2a ()
238{
239 log_start "RUN FULL CLIENT/SERVER";
240 #
241 if [ x"$1" = x ]; then
242 [ -z "$quiet" ] && log_msg_fail "Missing hostname"
[1]243 fi
[19]244 #
[1]245 SH_LOCALHOST=$1; export SH_LOCALHOST
[19]246 #
247 testrun2a_internal
248 do_test_1_a
249 if [ $? -eq 0 ]; then
250 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client download+logging";
251 else
252 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client download+logging";
253 fi
[460]254 ####### EXIT HERE FOR TESTING ######
[19]255 #
[460]256 #
[25]257 SERVER_BUILDOPTS_ORIG="${SERVER_BUILDOPTS}"
258 CLIENT_BUILDOPTS_ORIG="${CLIENT_BUILDOPTS}"
259 #
[172]260 SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} --disable-srp"; export SERVER_BUILDOPTS
261 CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --disable-srp"; export CLIENT_BUILDOPTS
[25]262 #
263 testrun2a_internal
264 do_test_1_a
265 if [ $? -eq 0 ]; then
266 [ -z "$quiet" ] && log_ok 2 ${MAXTEST} "SRP disabled";
267 else
268 [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "SRP disabled";
269 fi
270 #
[172]271 SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} --disable-encrypt"; export SERVER_BUILDOPTS
272 CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --disable-encrypt"; export CLIENT_BUILDOPTS
[25]273 #
274 testrun2a_internal
275 do_test_1_a
276 if [ $? -eq 0 ]; then
277 [ -z "$quiet" ] && log_ok 3 ${MAXTEST} "Encryption disabled";
278 else
279 [ -z "$quiet" ] && log_fail 3 ${MAXTEST} "Encryption disabled";
280 fi
281 #
[172]282 SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} --enable-encrypt=1"; export SERVER_BUILDOPTS
283 CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --enable-encrypt=1"; export CLIENT_BUILDOPTS
[25]284 #
285 testrun2a_internal
286 do_test_1_a
287 if [ $? -eq 0 ]; then
288 [ -z "$quiet" ] && log_ok 4 ${MAXTEST} "Encryption (v1)";
289 else
290 [ -z "$quiet" ] && log_fail 4 ${MAXTEST} "Encryption (v1)";
291 fi
292 #
[172]293 SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG}"; export SERVER_BUILDOPTS
294 CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --enable-encrypt=1"; export CLIENT_BUILDOPTS
[25]295 #
296 testrun2a_internal
297 do_test_1_a
298 if [ $? -eq 0 ]; then
299 [ -z "$quiet" ] && log_ok 5 ${MAXTEST} "Encryption backward compat";
300 else
301 [ -z "$quiet" ] && log_fail 5 ${MAXTEST} "Encryption backward compat";
302 fi
303 #
[19]304 if [ -n "$cleanup" ]; then
305 rm -f ./rc.${SH_LOCALHOST}
306 rm -f ./file.${SH_LOCALHOST}
307 ALTHOST=`find_hostname`
308 rm -f "./file.${ALTHOST}"
309 rm -f "./rc.${ALTHOST}"
310 fi
311 #
312 log_end "RUN FULL CLIENT/SERVER"
313}
Note: See TracBrowser for help on using the repository browser.