source: trunk/test/testrun_2e.sh@ 566

Last change on this file since 566 was 550, checked in by katerina, 5 years ago

Fix for ticket #442 (support for OpenBSD signify).

  • Property svn:executable set to *
File size: 7.6 KB
Line 
1#! /bin/sh
2
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
22LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
23RCFILE="$PW_DIR/testrc_2"; export RCFILE
24
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 --enable-debug=gdb"; export SERVER_BUILDOPTS
26
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-debug"; export CLIENT_BUILDOPTS
28
29do_test_2_e () {
30
31 [ -z "$verbose" ] || {
32 echo;
33 echo "${S}Start Server${E}: ./yule -l info -p none &";
34 echo;
35 }
36 rm -f test_log_valgrind
37
38 # SetSocketAllowUid=$(id -u)
39 #
40 if test -f /usr/xpg4/bin/id; then
41 MY_ID=$(/usr/xpg4/bin/id -u)
42 else
43 MY_ID=$(id -u)
44 fi
45 #
46 sed -i -e "s/SetSocketAllowUid=0/SetSocketAllowUid=${MY_ID}/g" $RCFILE
47
48 # Start server
49 #
50 ${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind &
51 PROC_Y=$!
52 five_sec_sleep
53
54 ./yulectl -c LIST >/dev/null 2>&1
55 if [ $? -ne 0 ]; then
56 [ -z "$verbose" ] || log_msg_fail "./yulectl -c LIST (1)";
57 kill $PROC_Y
58 return 1
59 fi
60 NR=$( ./yulectl -c LIST | wc -l )
61 if [ $NR -ne 0 ]; then
62 [ -z "$verbose" ] || log_msg_fail "./yulectl -c LIST (2)";
63 kill $PROC_Y
64 return 1
65 fi
66
67 ./yulectl -c SCAN localhost.localdomain
68 if [ $? -ne 0 ]; then
69 [ -z "$verbose" ] || log_msg_fail "./yulectl -c SCAN";
70 kill $PROC_Y
71 return 1
72 fi
73
74 UUID=$(uuidgen)
75 ./yulectl -c DELTA:$UUID localhost.localdomain
76 if [ $? -ne 0 ]; then
77 [ -z "$verbose" ] || log_msg_fail "./yulectl -c DELTA:$UUID";
78 kill $PROC_Y
79 return 1
80 fi
81
82 ./yulectl -c RELOAD localhost.localdomain
83 if [ $? -ne 0 ]; then
84 [ -z "$verbose" ] || log_msg_fail "./yulectl -c RELOAD";
85 kill $PROC_Y
86 return 1
87 fi
88
89 ./yulectl -c LIST >/dev/null 2>&1
90 if [ $? -ne 0 ]; then
91 [ -z "$verbose" ] || log_msg_fail "./yulectl -c LIST (3)";
92 kill $PROC_Y
93 return 1
94 fi
95 NR=$( ./yulectl -c LIST | wc -l )
96 if [ $NR -ne 3 ]; then
97 [ -z "$verbose" ] || log_msg_fail "./yulectl -c LIST (4)";
98 kill $PROC_Y
99 return 1
100 fi
101
102 { ./yulectl -c LIST | head -n 1 | grep SCAN; } >/dev/null 2>&1
103 if [ $? -ne 0 ]; then
104 [ -z "$verbose" ] || log_msg_fail "./yulectl -c LIST (5)";
105 kill $PROC_Y
106 return 1
107 fi
108 { ./yulectl -c LIST | tail -n 1 | grep RELOAD; } >/dev/null 2>&1
109 if [ $? -ne 0 ]; then
110 [ -z "$verbose" ] || log_msg_fail "./yulectl -c LIST (6)";
111 kill $PROC_Y
112 return 1
113 fi
114 { ./yulectl -c LIST | tail -n 2 | head -n 1| grep "DELTA:$UUID"; } >/dev/null 2>&1
115 if [ $? -ne 0 ]; then
116 [ -z "$verbose" ] || log_msg_fail "./yulectl -c LIST (7)";
117 kill $PROC_Y
118 return 1
119 fi
120
121 ./yulectl -c CANCEL localhost.localdomain
122 if [ $? -ne 0 ]; then
123 [ -z "$verbose" ] || log_msg_fail "./yulectl -c CANCEL";
124 kill $PROC_Y
125 return 1
126 fi
127
128 ./yulectl -c LIST >/dev/null 2>&1
129 if [ $? -ne 0 ]; then
130 [ -z "$verbose" ] || log_msg_fail "./yulectl -c LIST (8)";
131 kill $PROC_Y
132 return 1
133 fi
134 NR=$( ./yulectl -c LIST | wc -l )
135 if [ $NR -ne 0 ]; then
136 [ -z "$verbose" ] || log_msg_fail "./yulectl -c LIST (9)";
137 kill $PROC_Y
138 return 1
139 fi
140
141 kill $PROC_Y
142 return 0
143}
144
145testrun2e_internal ()
146{
147 [ -z "$verbose" ] || {
148 echo;
149 echo Working directory: $PW_DIR; echo MAKE is $MAKE;
150 echo;
151 }
152 #
153 #
154 [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; }
155 #
156 if test -r "Makefile"; then
157 $MAKE distclean
158 fi
159 #
160 ${TOP_SRCDIR}/configure ${CLIENT_BUILDOPTS}
161 #
162 if test x$? = x0; then
163 [ -z "$verbose" ] || log_msg_ok "configure...";
164 $MAKE > /dev/null 2>>test_log
165 if test x$? = x0; then
166 [ -z "$verbose" ] || log_msg_ok "make...";
167 else
168 [ -z "$quiet" ] && log_msg_fail "make...";
169 return 1
170 fi
171
172 else
173 [ -z "$quiet" ] && log_msg_fail "configure...";
174 return 1
175 fi
176
177 # save binary and build server
178 #
179 cp samhain samhain.build || return 1
180 $MAKE clean >/dev/null || return 1
181
182 ${TOP_SRCDIR}/configure ${SERVER_BUILDOPTS}
183 #
184 if test x$? = x0; then
185 [ -z "$verbose" ] || log_msg_ok "configure...";
186 $MAKE > /dev/null 2>>test_log
187 if test x$? = x0; then
188 [ -z "$verbose" ] || log_msg_ok "make...";
189 else
190 [ -z "$quiet" ] && log_msg_fail "make...";
191 return 1
192 fi
193
194 else
195 [ -z "$quiet" ] && log_msg_fail "configure...";
196 return 1
197 fi
198
199
200 #####################################################################
201 #
202 #
203 rm -f ./.samhain_file
204 rm -f ./.samhain_log
205 rm -f ./.samhain_lock
206 rm -f ./rc.${SH_LOCALHOST}
207 rm -f ./file.${SH_LOCALHOST}
208 rm -f "./rc.${ALTHOST}"
209 rm -f "./file.${ALTHOST}"
210
211 cp ${SCRIPTDIR}/testrc_2.in testrc_2
212
213 ./samhain.build -t init -p none
214
215 if test x$? = x0; then
216 [ -z "$verbose" ] || log_msg_ok "init...";
217 else
218 [ -z "$quiet" ] && log_msg_fail "init...";
219 return 1
220 fi
221
222 # Create a password
223
224 SHPW=`./yule -G`
225 if test x"$SHPW" = x; then
226 [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting"
227 return 1
228 fi
229
230 # Set in client
231
232 ./samhain_setpwd samhain.build new $SHPW >/dev/null
233
234 if test x$? = x0; then
235 [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd samhain.build new $SHPW";
236 else
237 [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd samhain.build new $SHPW";
238 return 1
239 fi
240
241 mv samhain.build.new samhain.new || return 1
242
243 rm -f ./.samhain_log*
244 rm -f ./.samhain_lock
245
246 SHCLT=`./yule -P $SHPW`
247
248 if test x$? = x0; then
249 [ -z "$verbose" ] || log_msg_ok "yule -P $SHPW";
250 else
251 [ -z "$quiet" ] && log_msg_fail "yule -P $SHPW";
252 return 1
253 fi
254
255 SHCLT1=`echo "${SHCLT}" | sed s%HOSTNAME%${SH_LOCALHOST}%`
256 AHOST=`find_hostname`
257 SHCLT2=`echo "${SHCLT}" | sed s%HOSTNAME%${AHOST}%`
258
259 echo $SHCLT1 >> testrc_2
260 echo $SHCLT2 >> testrc_2
261
262 cp ./testrc_2 ./rc.${SH_LOCALHOST}
263 mv ./.samhain_file ./file.${SH_LOCALHOST}
264 chmod 644 ./rc.${SH_LOCALHOST}
265 chmod 644 ./file.${SH_LOCALHOST}
266
267 ALTHOST=`find_hostname`
268 cp ./testrc_2 "./rc.${ALTHOST}"
269 cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null
270 chmod 644 ./rc.${ALTHOST}
271 chmod 644 ./file.${ALTHOST}
272
273 echo $SHPW > ./testpw
274}
275
276MAXTEST=1; export MAXTEST
277
278testrun2e ()
279{
280 log_start "RUN SERVER W/YULECTL";
281 #
282 if [ x"$1" = x ]; then
283 [ -z "$quiet" ] && log_msg_fail "Missing hostname"
284 fi
285 #
286 SH_LOCALHOST=$1; export SH_LOCALHOST
287 #
288 testrun2e_internal
289 do_test_2_e
290 if [ $? -eq 0 ]; then
291 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Server w/yulectl";
292 else
293 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Server w/yulectl";
294 fi
295 ####### EXIT HERE FOR TESTING ######
296 #
297 #
298 log_end "RUN SERVER W/YULECTL"
299}
Note: See TracBrowser for help on using the repository browser.