source: trunk/test/testrun_1b.sh@ 138

Last change on this file since 138 was 100, checked in by rainer, 17 years ago

Release 2.3.3; minor testscript and typo fixes.

File size: 8.3 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#
[1]21
[52]22MAXTEST=3; export MAXTEST
[19]23LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
24RCFILE="$PW_DIR/testrc_1.dyn"; export RCFILE
[1]25
[19]26testrun1b_internal ()
[1]27{
[19]28 BUILDOPTS="$1"
[1]29 #
30 # test standalone compilation
31 #
[19]32 [ -z "$verbose" ] || { echo; echo "${S}Building standalone agent${E}"; echo; }
[1]33 #
34 if test -r "Makefile"; then
[22]35 $MAKE distclean >/dev/null >&1
[1]36 fi
37 #
38 #
[19]39 ${TOP_SRCDIR}/configure ${BUILDOPTS} >/dev/null 2>/dev/null
[1]40 #
41 #
42 if test x$? = x0; then
[19]43 [ -z "$verbose" ] || log_msg_ok "configure...";
[22]44 $MAKE > /dev/null 2>&1
[1]45 if test x$? = x0; then
[19]46 [ -z "$verbose" ] || log_msg_ok "make...";
[1]47 else
[19]48 [ -z "$quiet" ] && log_msg_fail "make...";
49 return 1
[1]50 fi
51
52 else
[19]53 [ -z "$quiet" ] && log_msg_fail "configure...";
54 return 1
[1]55 fi
56
[19]57 SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ { print NR + 1; exit 0; }' ${SCRIPTDIR}/test.sh`
[1]58
[19]59 tail -n "+$SKIP" ${SCRIPTDIR}/test.sh >/dev/null 2>&1
60 if [ $? -eq 0 ]; then
61 tail -n "+$SKIP" ${SCRIPTDIR}/test.sh | gunzip -c - | tar xf - && \
62 mv "./testrc.gpg.asc" "$RCFILE"
63 else
64 tail "+$SKIP" ${SCRIPTDIR}/test.sh | gunzip -c - | tar xf - && \
65 mv "./testrc.gpg.asc" "$RCFILE"
66 fi
67 if test x$? = x0; then
68 [ -z "$verbose" ] || log_msg_ok "extract gpg signed files...";
69 else
70 [ -z "$quiet" ] && log_msg_fail "extract gpg signed files...";
71 return 1
72 fi
73
[52]74 if test "x$2" = "x"; then
75 :
76 else
77 CONVERT="$2"
78 if test -f "${TOP_SRCDIR}/stealth_template.jpg"; then
79 [ -z "$verbose" ] || log_msg_ok "convert..."
80 "${CONVERT}" +compress "${TOP_SRCDIR}/stealth_template.jpg" stealth_template.ps >/dev/null
81 else
82 [ -z "$quiet" ] && log_msg_fail "cannot find file stealth_template.jpg"
83 return 1
84 fi
85 if [ $? -ne 0 ]; then
86 [ -z "$quiet" ] && log_msg_fail "${CONVERT} +compress ${TOP_SRCDIR}/stealth_template.jpg stealth_template.ps";
87 return 1
88 fi
89
90 [ -z "$verbose" ] || log_msg_ok "hide..."
91 ./samhain_stealth -s stealth_template.ps "$RCFILE" >/dev/null
92 if [ $? -ne 0 ]; then
93 [ -z "$quiet" ] && log_msg_fail "${CONVERT} +compress ${TOP_SRCDIR}/stealth_template.jpg stealth_template.ps";
94 return 1
95 fi
96
97 mv -f stealth_template.ps "$RCFILE"
98 if [ $? -ne 0 ]; then
99 [ -z "$quiet" ] && log_msg_fail "mv -f stealth_template.ps $RCFILE";
100 return 1
101 fi
102
103 fi
104
[1]105 rm -f ./.samhain_file
106 rm -f ./.samhain_log
107 rm -f ./.samhain_lock
108
[19]109 ./samhain -t init -p none -l info
[1]110
111 if test x$? = x0; then
[19]112 [ -z "$verbose" ] || log_msg_ok "init...";
113 else
114 [ -z "$quiet" ] && log_msg_fail "init...";
115 return 1
116 fi
[1]117
[19]118 mv $PW_DIR/.samhain_file.asc $PW_DIR/.samhain_file
119}
[1]120
[19]121do_test_1b () {
122
123 ./samhain -t check -p none -l info
124
125 if test x$? = x0; then
126 ./samhain -j -L $LOGFILE >"${LOGFILE}.tmp" && mv "${LOGFILE}.tmp" "${LOGFILE}"
127 if [ $? -ne 0 ]; then
128 [ -z "$quiet" ] && log_msg_fail "mv logfile...";
129 return 1
[1]130 fi
[19]131 [ -z "$verbose" ] || log_msg_ok "check...";
132 else
133 [ -z "$quiet" ] && log_msg_fail "check...";
134 return 1
135 fi
136 #
137 tmp=`egrep "Checking.*/etc(>|\")" $LOGFILE 2>/dev/null | wc -l`
138 if [ $tmp -ne 2 ]; then
139 [ -z "$verbose" ] || log_msg_fail "/etc";
[60]140 return 1
[19]141 fi
142 tmp=`egrep "Checking.*(>|\")" $LOGFILE 2>/dev/null | wc -l`
[60]143 if [ $tmp -ne 8 ]; then
[19]144 [ -z "$verbose" ] || log_msg_fail "checking";
[60]145 return 1
[19]146 fi
[60]147 egrep "ADDED" $LOGFILE >/dev/null 2>&1
148 if [ $? -eq 0 ]; then
149 [ -z "$verbose" ] || log_msg_fail "init was incomplete";
150 return 1
151 fi
[19]152 #
153 return 0
[1]154}
155
[19]156do_test_1b_2 () {
[1]157
[19]158 rm -f $PW_DIR/test_log_prelude
[1]159
[20]160 "$PM" --textmod -l $PW_DIR/test_log_prelude --listen 127.0.0.1:5500 >/dev/null 2>&1 &
[19]161 PID=$!
[1]162
[51]163 five_sec_sleep
[20]164
165 ./samhain -t check -p none -l info --set-prelude-severity=info --prelude --server-addr 127.0.0.1:5500 >/dev/null
[19]166
167 if test x$? = x0; then
168 ./samhain -j -L $LOGFILE >"${LOGFILE}.tmp" && mv "${LOGFILE}.tmp" "${LOGFILE}"
169 if [ $? -ne 0 ]; then
170 [ -z "$quiet" ] && log_msg_fail "mv logfile...";
171 kill $PID
172 return 1
173 fi
174 [ -z "$verbose" ] || log_msg_ok "check...";
175 else
176 [ -z "$quiet" ] && log_msg_fail "check...";
177 kill $PID
178 return 1
179 fi
180 #
181 tmp=`egrep 'File original:.*name=etc.*path=/etc' test_log_prelude 2>/dev/null | wc -l`
[81]182 if [ $tmp -lt 1 ]; then
[19]183 [ -z "$verbose" ] || log_msg_fail "/etc";
184 fi
185 tmp=`egrep 'Classification text: Checking' test_log_prelude 2>/dev/null | wc -l`
[81]186 if [ $tmp -lt 1 ]; then
[19]187 [ -z "$verbose" ] || log_msg_fail "checking";
188 fi
189 tmp=`egrep 'Classification text: Checking' test_log_prelude 2>/dev/null | wc -l`
[81]190 if [ $tmp -lt 1 ]; then
[19]191 [ -z "$verbose" ] || log_msg_fail "checking";
192 fi
193 #
194 kill $PID
195 return 0
196}
[1]197
[19]198testrun1b ()
199{
200 log_start "RUN STANDALONE W/STEALTH W/GPG"
201 GPG=`find_path gpg`
202 if [ -z "$GPG" ]; then
203 log_skip 1 $MAXTEST 'gpg not found in $PATH'
204 log_skip 2 $MAXTEST 'gpg not found in $PATH'
[100]205 log_skip 3 $MAXTEST 'gpg not found in $PATH'
[19]206 else
207 eval "$GPG" --list-keys 0F571F6C >/dev/null 2>/dev/null
208 if [ $? -ne 0 ]; then
209 log_skip 1 $MAXTEST 'public PGP key 0x0F571F6C not present'
210 log_skip 2 $MAXTEST 'public PGP key 0x0F571F6C not present'
[100]211 log_skip 3 $MAXTEST 'public PGP key 0x0F571F6C not present'
[19]212 else
[52]213 #
214 # ------------- first test -------------
215 #
[19]216 BUILDOPTS="--quiet $TRUST --enable-debug --with-gpg=${GPG} --with-checksum=no --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"
[52]217 testrun1b_internal "${BUILDOPTS}"
[19]218 do_test_1b
219 if [ $? -eq 0 ]; then
220 log_ok 1 $MAXTEST 'gpg signed config/database files'
221 else
222 log_fail 1 $MAXTEST 'gpg signed config/database files'
223 fi
[52]224
225
226 #
227 # ------------- second test -------------
228 #
229 PRECONV=`find_path convert`
230 "${PRECONV}" --help | grep ImageMagick >/dev/null 2>&1 && \
231 CONVERT="${PRECONV}"
232
233 if [ -z "$CONVERT" ]; then
234 log_skip 2 $MAXTEST 'ImageMagick convert not found in $PATH'
235 else
236 BUILDOPTS="--quiet $TRUST --enable-debug --with-gpg=${GPG} --with-checksum=no --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"
237 testrun1b_internal "${BUILDOPTS}" "$CONVERT"
238 do_test_1b
239 if [ $? -eq 0 ]; then
240 log_ok 2 $MAXTEST 'gpg signed config/database files'
241 else
242 log_fail 2 $MAXTEST 'gpg signed config/database files'
243 fi
244 fi
245
246
247 #
248 # ------------- third test -------------
249 #
[97]250 if test -f /usr/local/lib/libprelude.so
[96]251 then
252 LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
253 export LD_LIBRARY_PATH
254 fi
255 #
[19]256 PM=`find_path prelude-manager`
257 if [ -z "$PM" ]; then
[52]258 log_skip 3 $MAXTEST 'prelude-manager not found in $PATH'
[19]259 elif [ -z "$doall" ]; then
[52]260 log_skip 3 $MAXTEST 'logging to prelude (or use --really-all)'
[19]261 else
262 BUILDOPTS="--quiet $TRUST --enable-debug --with-prelude --with-gpg=${GPG} --with-checksum=no --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"
[20]263 testrun1b_internal "${BUILDOPTS} CFLAGS=-DSH_NOFAILOVER=1"
[19]264 do_test_1b_2
265 if [ $? -eq 0 ]; then
[52]266 log_ok 3 $MAXTEST 'logging to prelude'
[19]267 else
[52]268 log_fail 3 $MAXTEST 'logging to prelude'
[19]269 fi
270 fi
271 fi
272 fi
273 log_end "RUN STANDALONE W/STEALTH W/GPG"
274 return 0
275}
[1]276
Note: See TracBrowser for help on using the repository browser.