source: trunk/test/testrun_1b.sh@ 29

Last change on this file since 29 was 27, checked in by rainer, 19 years ago

Support for server-to-server relay and more user policies

File size: 6.0 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=2; export MAXTEST
23LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
24RCFILE="$PW_DIR/testrc_1.dyn"; export RCFILE
25
26testrun1b_internal ()
27{
28 BUILDOPTS="$1"
29 #
30 # test standalone compilation
31 #
32 [ -z "$verbose" ] || { echo; echo "${S}Building standalone agent${E}"; echo; }
33 #
34 if test -r "Makefile"; then
35 $MAKE distclean >/dev/null >&1
36 fi
37 #
38 #
39 ${TOP_SRCDIR}/configure ${BUILDOPTS} >/dev/null 2>/dev/null
40 #
41 #
42 if test x$? = x0; then
43 [ -z "$verbose" ] || log_msg_ok "configure...";
44 $MAKE > /dev/null 2>&1
45 if test x$? = x0; then
46 [ -z "$verbose" ] || log_msg_ok "make...";
47 else
48 [ -z "$quiet" ] && log_msg_fail "make...";
49 return 1
50 fi
51
52 else
53 [ -z "$quiet" ] && log_msg_fail "configure...";
54 return 1
55 fi
56
57 SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ { print NR + 1; exit 0; }' ${SCRIPTDIR}/test.sh`
58
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
74 rm -f ./.samhain_file
75 rm -f ./.samhain_log
76 rm -f ./.samhain_lock
77
78 ./samhain -t init -p none -l info
79
80 if test x$? = x0; then
81 [ -z "$verbose" ] || log_msg_ok "init...";
82 else
83 [ -z "$quiet" ] && log_msg_fail "init...";
84 return 1
85 fi
86
87 mv $PW_DIR/.samhain_file.asc $PW_DIR/.samhain_file
88}
89
90do_test_1b () {
91
92 ./samhain -t check -p none -l info
93
94 if test x$? = x0; then
95 ./samhain -j -L $LOGFILE >"${LOGFILE}.tmp" && mv "${LOGFILE}.tmp" "${LOGFILE}"
96 if [ $? -ne 0 ]; then
97 [ -z "$quiet" ] && log_msg_fail "mv logfile...";
98 return 1
99 fi
100 [ -z "$verbose" ] || log_msg_ok "check...";
101 else
102 [ -z "$quiet" ] && log_msg_fail "check...";
103 return 1
104 fi
105 #
106 tmp=`egrep "Checking.*/etc(>|\")" $LOGFILE 2>/dev/null | wc -l`
107 if [ $tmp -ne 2 ]; then
108 [ -z "$verbose" ] || log_msg_fail "/etc";
109 fi
110 tmp=`egrep "Checking.*(>|\")" $LOGFILE 2>/dev/null | wc -l`
111 if [ $tmp -ne 2 ]; then
112 [ -z "$verbose" ] || log_msg_fail "checking";
113 fi
114 #
115 return 0
116}
117
118do_test_1b_2 () {
119
120 rm -f $PW_DIR/test_log_prelude
121
122 "$PM" --textmod -l $PW_DIR/test_log_prelude --listen 127.0.0.1:5500 >/dev/null 2>&1 &
123 PID=$!
124
125 sleep 5
126
127 ./samhain -t check -p none -l info --set-prelude-severity=info --prelude --server-addr 127.0.0.1:5500 >/dev/null
128
129 if test x$? = x0; then
130 ./samhain -j -L $LOGFILE >"${LOGFILE}.tmp" && mv "${LOGFILE}.tmp" "${LOGFILE}"
131 if [ $? -ne 0 ]; then
132 [ -z "$quiet" ] && log_msg_fail "mv logfile...";
133 kill $PID
134 return 1
135 fi
136 [ -z "$verbose" ] || log_msg_ok "check...";
137 else
138 [ -z "$quiet" ] && log_msg_fail "check...";
139 kill $PID
140 return 1
141 fi
142 #
143 tmp=`egrep 'File original:.*name=etc.*path=/etc' test_log_prelude 2>/dev/null | wc -l`
144 if [ $tmp -ne 1 ]; then
145 [ -z "$verbose" ] || log_msg_fail "/etc";
146 fi
147 tmp=`egrep 'Classification text: Checking' test_log_prelude 2>/dev/null | wc -l`
148 if [ $tmp -ne 1 ]; then
149 [ -z "$verbose" ] || log_msg_fail "checking";
150 fi
151 tmp=`egrep 'Classification text: Checking' test_log_prelude 2>/dev/null | wc -l`
152 if [ $tmp -ne 1 ]; then
153 [ -z "$verbose" ] || log_msg_fail "checking";
154 fi
155 #
156 kill $PID
157 return 0
158}
159
160testrun1b ()
161{
162 log_start "RUN STANDALONE W/STEALTH W/GPG"
163 GPG=`find_path gpg`
164 if [ -z "$GPG" ]; then
165 log_skip 1 $MAXTEST 'gpg not found in $PATH'
166 log_skip 2 $MAXTEST 'gpg not found in $PATH'
167 else
168 eval "$GPG" --list-keys 0F571F6C >/dev/null 2>/dev/null
169 if [ $? -ne 0 ]; then
170 log_skip 1 $MAXTEST 'public PGP key 0x0F571F6C not present'
171 log_skip 2 $MAXTEST 'public PGP key 0x0F571F6C not present'
172 else
173 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"
174 testrun1b_internal "${BUILDOPTS}"
175 do_test_1b
176 if [ $? -eq 0 ]; then
177 log_ok 1 $MAXTEST 'gpg signed config/database files'
178 else
179 log_fail 1 $MAXTEST 'gpg signed config/database files'
180 fi
181 PM=`find_path prelude-manager`
182 if [ -z "$PM" ]; then
183 log_skip 2 $MAXTEST 'prelude-manager not found in $PATH'
184 elif [ -z "$doall" ]; then
185 log_skip 2 $MAXTEST 'logging to prelude (or use --really-all)'
186 else
187 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"
188 testrun1b_internal "${BUILDOPTS} CFLAGS=-DSH_NOFAILOVER=1"
189 do_test_1b_2
190 if [ $? -eq 0 ]; then
191 log_ok 2 $MAXTEST 'logging to prelude'
192 else
193 log_fail 2 $MAXTEST 'logging to prelude'
194 fi
195 fi
196 fi
197 fi
198 log_end "RUN STANDALONE W/STEALTH W/GPG"
199 return 0
200}
201
Note: See TracBrowser for help on using the repository browser.