source: trunk/test/testrun_1e.sh@ 81

Last change on this file since 81 was 67, checked in by katerina, 18 years ago

Add/delete files for samhain 2.3

  • Property svn:executable set to *
File size: 3.9 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
22BUILDOPTS="--quiet $TRUST --enable-xml-log --enable-port-check --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file"
23export BUILDOPTS
24
25MAXTEST=2; export MAXTEST
26
27PORTPOLICY_2="
28[ReadOnly]
29file=${BASE}
30[PortCheck]
31PortCheckActive = yes
32PortCheckUDP = no
33"
34
35chk_portdata_2 () {
36 one_sec_sleep
37
38 egrep 'CRIT.*POLICY \[ServiceNew\]' $LOGFILE >/dev/null 2>&1
39 if [ $? -eq 0 ]; then
40
41 [ -z "$verbose" ] || log_msg_fail "Open ports";
42 return 1
43 fi
44}
45
46refine_portpolicy_2 ()
47{
48 cat "$LOGFILE" | grep ServiceNew | sed 's/.*port //' | awk '{ print $1 }' | \
49 while read line; do
50 echo "PortCheckOptional=$line" >>"${RCFILE}"
51 done
52}
53
54PORTPOLICY_1="
55[ReadOnly]
56file=${BASE}
57[PortCheck]
58PortCheckActive = yes
59PortCheckUDP = no
60"
61
62chk_portdata_1 () {
63 one_sec_sleep
64
65 egrep 'CRIT.*POLICY \[ServiceNew\]' $LOGFILE >/dev/null 2>&1
66 if [ $? -eq 0 ]; then
67
68 [ -z "$verbose" ] || log_msg_fail "Open ports";
69 return 1
70 fi
71}
72
73refine_portpolicy_1 ()
74{
75 cat "$LOGFILE" | grep ServiceNew | sed 's/.*port //' | awk '{ print $1 }' | \
76 while read line; do
77 echo "PortCheckRequired=$line" >>"${RCFILE}"
78 done
79}
80
81prep_portpolicy ()
82{
83 test -f "${RCFILE}" || touch "${RCFILE}"
84 eval echo '"$'"PORTPOLICY_$1"'"' >>"${RCFILE}"
85}
86
87testrun_internal_1e ()
88{
89 [ -z "$verbose" ] || echo Working directory: $PW_DIR
90 [ -z "$verbose" ] || { echo MAKE is $MAKE; echo; }
91
92 #
93 # test standalone compilation
94 #
95 [ -z "$verbose" ] || { echo; echo "${S}Building standalone agent${E}"; echo; }
96
97 if test -r "Makefile"; then
98 $MAKE distclean >/dev/null
99 fi
100
101 tcount=1
102 ${TOP_SRCDIR}/configure ${BUILDOPTS}
103
104 #
105 if test x$? = x0; then
106 [ -z "$verbose" ] || log_msg_ok "configure...";
107 $MAKE >/dev/null 2>&1
108 if test x$? = x0; then
109 [ -z "$verbose" ] || log_msg_ok "make...";
110 else
111 [ -z "$quiet" ] && log_msg_fail "make...";
112 return 1
113 fi
114
115 else
116 [ -z "$quiet" ] && log_msg_fail "configure...";
117 return 1
118 fi
119
120 [ -z "$verbose" ] || { echo; echo "${S}Running test suite${E}"; echo; }
121
122 POLICY=`eval echo '"$'"PORTPOLICY_$tcount"'"'`
123
124 until [ -z "$POLICY" ]
125 do
126 prep_init
127 check_err $? ${tcount}; errval=$?
128 if [ $errval -eq 0 ]; then
129 prep_testdata
130 check_err $? ${tcount}; errval=$?
131 fi
132 if [ $errval -eq 0 ]; then
133 prep_portpolicy ${tcount}
134 check_err $? ${tcount}; errval=$?
135 fi
136 if [ $errval -eq 0 ]; then
137 run_init
138 check_err $? ${tcount}; errval=$?
139 fi
140 #
141 if [ $errval -eq 0 ]; then
142 eval refine_portpolicy_${tcount}
143 check_err $? ${tcount}; errval=$?
144 fi
145 #
146 rm -f "$LOGFILE"
147 #
148 if [ $errval -eq 0 ]; then
149 run_check
150 check_err $? ${tcount}; errval=$?
151 fi
152 if [ $errval -eq 0 ]; then
153 eval chk_portdata_${tcount}
154 check_err $? ${tcount}; errval=$?
155 fi
156 #
157 if [ $errval -eq 0 ]; then
158 [ -z "$quiet" ] && log_ok ${tcount} ${MAXTEST};
159 fi
160 let "tcount = tcount + 1" >/dev/null
161 POLICY=`eval echo '"$'"PORTPOLICY_$tcount"'"'`
162 done
163
164 return 0
165}
166
167testrun1e ()
168{
169 log_start "RUN STANDALONE W/PORTCHECK"
170 testrun_internal_1e
171 log_end "RUN STANDALONE W/PORTCHECK"
172 return 0
173}
174
175
Note: See TracBrowser for help on using the repository browser.