source: trunk/test/testrun_1i.sh@ 568

Last change on this file since 568 was 561, checked in by katerina, 3 years ago

Fix for ticket #451 (signify-openbsd in client/server mode not working).

  • Property svn:executable set to *
File size: 9.2 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
22MAXTEST=4; export MAXTEST
23LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
24RCFILE="$PW_DIR/testrc_1.dyn"; export RCFILE
25
26testrun1b_modrc ()
27{
28 ORIGINAL="\[EOF\]"
29 REPLACEMENT="\[PortCheck\]"
30 ex -s $RCFILE <<EOF
31%s/$ORIGINAL/$REPLACEMENT/g
32wq
33EOF
34
35 echo "PortCheckActive = yes" >>"$RCFILE"
36 echo "PortCheckInterface = 127.0.0.1" >>"$RCFILE"
37}
38
39testrun1b_internal ()
40{
41 BUILDOPTS="$1"
42 #
43 # test standalone compilation
44 #
45 [ -z "$verbose" ] || { echo; echo "${S}Building standalone agent${E}"; echo; }
46 #
47 if test -r "Makefile"; then
48 $MAKE distclean >/dev/null >&1
49 fi
50 #
51 # Bootstrapping
52 #
53 ${TOP_SRCDIR}/configure >/dev/null 2>/dev/null
54 if test x$? = x0; then
55 [ -z "$verbose" ] || log_msg_ok "configure (bootstrap)...";
56 $MAKE > /dev/null 2>&1
57 if test x$? = x0; then
58 [ -z "$verbose" ] || log_msg_ok "make (bootstrap)...";
59 else
60 [ -z "$quiet" ] && log_msg_fail "make (bootstrap)...";
61 return 1
62 fi
63
64 else
65 [ -z "$quiet" ] && log_msg_fail "configure (bootstrap)...";
66 return 1
67 fi
68 #
69 #
70 ${TOP_SRCDIR}/configure ${BUILDOPTS} 2>/dev/null
71 #
72 #
73 if test x$? = x0; then
74 [ -z "$verbose" ] || log_msg_ok "configure...";
75 $MAKE > /dev/null 2>&1
76 if test x$? = x0; then
77 [ -z "$verbose" ] || log_msg_ok "make...";
78 else
79 [ -z "$quiet" ] && log_msg_fail "make...";
80 return 1
81 fi
82
83 else
84 [ -z "$quiet" ] && log_msg_fail "configure...";
85 return 1
86 fi
87
88 cp ${SCRIPTDIR}/testrc_1i.dyn "$RCFILE"
89
90
91 if test x$? = x0; then
92 [ -z "$verbose" ] || log_msg_ok "copy signed config file...";
93 else
94 [ -z "$quiet" ] && log_msg_fail "copy signed config file...";
95 return 1
96 fi
97
98 if test "x$2" = "x"; then
99 :
100 else
101 CONVERT="$2"
102 if test -f "${TOP_SRCDIR}/stealth_template.jpg"; then
103 [ -z "$verbose" ] || log_msg_ok "convert..."
104 "${CONVERT}" +compress "${TOP_SRCDIR}/stealth_template.jpg" stealth_template.ps >/dev/null
105 else
106 [ -z "$quiet" ] && log_msg_fail "cannot find file stealth_template.jpg"
107 return 1
108 fi
109 if [ $? -ne 0 ]; then
110 [ -z "$quiet" ] && log_msg_fail "${CONVERT} +compress ${TOP_SRCDIR}/stealth_template.jpg stealth_template.ps";
111 return 1
112 fi
113
114 [ -z "$verbose" ] || log_msg_ok "hide..."
115 ./samhain_stealth -s stealth_template.ps "$RCFILE" >/dev/null
116 if [ $? -ne 0 ]; then
117 [ -z "$quiet" ] && log_msg_fail "${CONVERT} +compress ${TOP_SRCDIR}/stealth_template.jpg stealth_template.ps";
118 return 1
119 fi
120
121 mv -f stealth_template.ps "$RCFILE"
122 if [ $? -ne 0 ]; then
123 [ -z "$quiet" ] && log_msg_fail "mv -f stealth_template.ps $RCFILE";
124 return 1
125 fi
126
127 fi
128
129 rm -f ./.samhain_file
130 rm -f ./.samhain_log
131 rm -f ./.samhain_lock
132
133 ./samhain -t init -p none -l info
134
135 if test x$? = x0; then
136 [ -z "$verbose" ] || log_msg_ok "init...";
137 else
138 [ -z "$quiet" ] && log_msg_fail "init...";
139 return 1
140 fi
141
142 cp ${SCRIPTDIR}/test1i_file.sig $PW_DIR/.samhain_file
143 if test x$? = x0; then
144 [ -z "$verbose" ] || log_msg_ok "copy signed database file...";
145 else
146 [ -z "$quiet" ] && log_msg_fail "copy signed database file...";
147 return 1
148 fi
149}
150
151testrun1b_nogpg ()
152{
153 BUILDOPTS="$1"
154 #
155 # test standalone compilation
156 #
157 [ -z "$verbose" ] || { echo; echo "${S}Building standalone agent${E}"; echo; }
158 #
159 if test -r "Makefile"; then
160 $MAKE distclean >/dev/null >&1
161 fi
162
163 ${TOP_SRCDIR}/configure ${BUILDOPTS} 2>/dev/null
164 #
165 #
166 if test x$? = x0; then
167 [ -z "$verbose" ] || log_msg_ok "configure...";
168 $MAKE > /dev/null 2>&1
169 if test x$? = x0; then
170 [ -z "$verbose" ] || log_msg_ok "make...";
171 else
172 [ -z "$quiet" ] && log_msg_fail "make...";
173 return 1
174 fi
175
176 else
177 [ -z "$quiet" ] && log_msg_fail "configure...";
178 return 1
179 fi
180
181 rm -f ./.samhain_file
182 rm -f ./.samhain_log
183 rm -f ./.samhain_lock
184
185 cp "${SCRIPTDIR}/testrc_1" "${RCFILE}"
186
187 if test "x$2" = "xmodrc"; then
188 [ -z "$verbose" ] || log_msg_ok "mod rc...";
189 testrun1b_modrc
190 fi
191
192 ./samhain -t init -p none -l info
193
194 if test x$? = x0; then
195 [ -z "$verbose" ] || log_msg_ok "init...";
196 else
197 [ -z "$quiet" ] && log_msg_fail "init...";
198 return 1
199 fi
200
201}
202
203do_test_1b () {
204
205 ./samhain -t check -p none -l info
206
207 if test x$? = x0; then
208 ./samhain -j -L $LOGFILE >"${LOGFILE}.tmp" && mv "${LOGFILE}.tmp" "${LOGFILE}"
209 if [ $? -ne 0 ]; then
210 [ -z "$quiet" ] && log_msg_fail "mv logfile...";
211 return 1
212 fi
213 [ -z "$verbose" ] || log_msg_ok "check...";
214 else
215 [ -z "$quiet" ] && log_msg_fail "check...";
216 return 1
217 fi
218 #
219 tmp=`egrep "Checking.*/etc(>|\")" $LOGFILE 2>/dev/null | wc -l`
220 if [ $tmp -ne 2 ]; then
221 [ -z "$verbose" ] || log_msg_fail "/etc";
222 return 1
223 fi
224 tmp=`egrep "Checking.*(>|\")" $LOGFILE 2>/dev/null | wc -l`
225 if [ $tmp -ne 10 ]; then
226 [ -z "$verbose" ] || log_msg_fail "checking";
227 return 1
228 fi
229 egrep "ADDED" $LOGFILE >/dev/null 2>&1
230 if [ $? -eq 0 ]; then
231 [ -z "$verbose" ] || log_msg_fail "init was incomplete";
232 return 1
233 fi
234 #
235 return 0
236}
237
238testrun1i ()
239{
240 log_start "RUN STANDALONE W/STEALTH W/SIGNIFY"
241 SIGNIFY=`find_path signify-openbsd`
242 if [ -z "$SIGNIFY" ]; then
243 SIGNIFY=`find_path signify`
244 fi
245 if [ -z "$SIGNIFY" ]; then
246 log_skip 1 $MAXTEST 'signify not found in $PATH'
247 log_skip 2 $MAXTEST 'signify not found in $PATH'
248 log_skip 3 $MAXTEST 'signify not found in $PATH'
249 log_skip 4 $MAXTEST 'signify not found in $PATH'
250 else
251 eval "ls ~/.signify/samhain.pub >/dev/null 2>/dev/null"
252 if [ $? -ne 0 ]; then
253 log_skip 1 $MAXTEST 'public key ~/.signify/samhain.pub not present'
254 log_skip 2 $MAXTEST 'public key ~/.signify/samhain.pub not present'
255 log_skip 3 $MAXTEST 'public key ~/.signify/samhain.pub not present'
256 log_skip 4 $MAXTEST 'public key ~/.signify/samhain.pub not present'
257 else
258 #
259 # ------------- first test -------------
260 #
261 BUILDOPTS="--quiet $TRUST --enable-debug --with-signify=${SIGNIFY} --enable-micro-stealth=137 --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file"
262 testrun1b_internal "${BUILDOPTS}"
263 do_test_1b
264 if [ $? -eq 0 ]; then
265 log_ok 1 $MAXTEST 'signify signed config/database files'
266 else
267 log_fail 1 $MAXTEST 'signify signed config/database files'
268 fi
269
270
271 #
272 # ------------- second test -------------
273 #
274 BUILDOPTS="--quiet $TRUST --enable-debug --with-signify=${SIGNIFY} --with-checksum --enable-micro-stealth=137 --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file"
275 testrun1b_internal "${BUILDOPTS}"
276 do_test_1b
277 if [ $? -eq 0 ]; then
278 log_ok 2 $MAXTEST 'signify signed config/database files'
279 else
280 log_fail 2 $MAXTEST 'signify signed config/database files'
281 fi
282
283
284 #
285 # ------------- third test -------------
286 #
287 BUILDOPTS="--quiet $TRUST --enable-debug --with-signify=${SIGNIFY} --with-checksum --with-pubkey-checksum=62F3EAE3CD9BA8849015060750908790B6326015A20AC0DA --enable-micro-stealth=137 --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file"
288 testrun1b_internal "${BUILDOPTS}"
289 do_test_1b
290 if [ $? -eq 0 ]; then
291 log_ok 3 $MAXTEST 'signify signed config/database files'
292 else
293 log_fail 3 $MAXTEST 'signify signed config/database files'
294 fi
295
296
297 #
298 # ------------- fourth test -------------
299 #
300 PRECONV=`find_path convert`
301 "${PRECONV}" --help | grep ImageMagick >/dev/null 2>&1 && \
302 CONVERT="${PRECONV}"
303
304 if [ -z "$CONVERT" ]; then
305 log_skip 2 $MAXTEST 'ImageMagick convert not found in $PATH'
306 else
307 BUILDOPTS="--quiet $TRUST --enable-debug --with-signify=${SIGNIFY} --with-checksum --enable-stealth=137 --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file"
308 testrun1b_internal "${BUILDOPTS}" "$CONVERT"
309 do_test_1b
310 if [ $? -eq 0 ]; then
311 log_ok 4 $MAXTEST 'signify signed config/database files'
312 else
313 log_fail 4 $MAXTEST 'signify signed config/database files'
314 fi
315 fi
316
317 fi
318 fi
319 log_end "RUN STANDALONE W/STEALTH W/SIGNIFY"
320 return 0
321}
322
Note: See TracBrowser for help on using the repository browser.