1 | #! /bin/sh
|
---|
2 |
|
---|
3 | LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
|
---|
4 | RCFILE="$PW_DIR/testrc_2"; export RCFILE
|
---|
5 |
|
---|
6 | SERVER_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"; export SERVER_BUILDOPTS
|
---|
7 |
|
---|
8 | CLIENT_BUILDOPTS="--quiet $TRUST --enable-debug --enable-network=client --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$RCFILE --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=localhost --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock"; export CLIENT_BUILDOPTS
|
---|
9 |
|
---|
10 | do_test_1_a () {
|
---|
11 |
|
---|
12 | [ -z "$verbose" ] || {
|
---|
13 | echo;
|
---|
14 | echo "${S}Start Server${E}: ./yule -l info -p none &";
|
---|
15 | echo;
|
---|
16 | }
|
---|
17 | ./yule -l info -p none >/dev/null 2>&1 &
|
---|
18 | PROC_Y=$!
|
---|
19 | sleep 5
|
---|
20 |
|
---|
21 | [ -z "$verbose" ] || {
|
---|
22 | echo;
|
---|
23 | echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
|
---|
24 | echo;
|
---|
25 | }
|
---|
26 |
|
---|
27 | ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>&1
|
---|
28 | if test x$? = x0; then
|
---|
29 | [ -z "$verbose" ] || log_msg_ok "samhain.new -t check";
|
---|
30 | else
|
---|
31 | [ -z "$quiet" ] && log_msg_fail "samhain.new -t check";
|
---|
32 | kill $PROC_Y
|
---|
33 | return 1
|
---|
34 | fi
|
---|
35 |
|
---|
36 | kill $PROC_Y
|
---|
37 | sleep 5
|
---|
38 |
|
---|
39 | egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
|
---|
40 | if [ $? -ne 0 ]; then
|
---|
41 | [ -z "$verbose" ] || log_msg_fail "Server start";
|
---|
42 | return 1
|
---|
43 | fi
|
---|
44 | egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1
|
---|
45 | if [ $? -ne 0 ]; then
|
---|
46 | [ -z "$verbose" ] || log_msg_fail "Client connect";
|
---|
47 | return 1
|
---|
48 | fi
|
---|
49 | egrep "Checking.*/etc" $LOGFILE >/dev/null 2>&1
|
---|
50 | if [ $? -ne 0 ]; then
|
---|
51 | [ -z "$verbose" ] || log_msg_fail "Client file check";
|
---|
52 | return 1
|
---|
53 | fi
|
---|
54 | egrep "EXIT.*Samhain" $LOGFILE >/dev/null 2>&1
|
---|
55 | if [ $? -ne 0 ]; then
|
---|
56 | [ -z "$verbose" ] || log_msg_fail "Client exit";
|
---|
57 | return 1
|
---|
58 | fi
|
---|
59 | egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1
|
---|
60 | if [ $? -ne 0 ]; then
|
---|
61 | [ -z "$verbose" ] || log_msg_fail "Server exit";
|
---|
62 | return 1
|
---|
63 | fi
|
---|
64 |
|
---|
65 |
|
---|
66 | return 0
|
---|
67 | }
|
---|
68 |
|
---|
69 | testrun2a_internal ()
|
---|
70 | {
|
---|
71 | [ -z "$verbose" ] || {
|
---|
72 | echo;
|
---|
73 | echo Working directory: $PW_DIR; echo MAKE is $MAKE;
|
---|
74 | echo;
|
---|
75 | }
|
---|
76 | #
|
---|
77 | #
|
---|
78 | [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; }
|
---|
79 | #
|
---|
80 | if test -r "Makefile"; then
|
---|
81 | $MAKE distclean
|
---|
82 | fi
|
---|
83 | #
|
---|
84 | ${TOP_SRCDIR}/configure ${CLIENT_BUILDOPTS}
|
---|
85 | #
|
---|
86 | if test x$? = x0; then
|
---|
87 | [ -z "$verbose" ] || log_msg_ok "configure...";
|
---|
88 | $MAKE > /dev/null 2>>test_log
|
---|
89 | if test x$? = x0; then
|
---|
90 | [ -z "$verbose" ] || log_msg_ok "make...";
|
---|
91 | else
|
---|
92 | [ -z "$quiet" ] && log_msg_fail "make...";
|
---|
93 | return 1
|
---|
94 | fi
|
---|
95 |
|
---|
96 | else
|
---|
97 | [ -z "$quiet" ] && log_msg_fail "configure...";
|
---|
98 | return 1
|
---|
99 | fi
|
---|
100 |
|
---|
101 | # save binary and build server
|
---|
102 | #
|
---|
103 | cp samhain samhain.build || return 1
|
---|
104 | make clean >/dev/null || return 1
|
---|
105 |
|
---|
106 | ${TOP_SRCDIR}/configure ${SERVER_BUILDOPTS}
|
---|
107 | #
|
---|
108 | if test x$? = x0; then
|
---|
109 | [ -z "$verbose" ] || log_msg_ok "configure...";
|
---|
110 | $MAKE > /dev/null 2>>test_log
|
---|
111 | if test x$? = x0; then
|
---|
112 | [ -z "$verbose" ] || log_msg_ok "make...";
|
---|
113 | else
|
---|
114 | [ -z "$quiet" ] && log_msg_fail "make...";
|
---|
115 | return 1
|
---|
116 | fi
|
---|
117 |
|
---|
118 | else
|
---|
119 | [ -z "$quiet" ] && log_msg_fail "configure...";
|
---|
120 | return 1
|
---|
121 | fi
|
---|
122 |
|
---|
123 |
|
---|
124 | #####################################################################
|
---|
125 | #
|
---|
126 | #
|
---|
127 | rm -f ./.samhain_file
|
---|
128 | rm -f ./.samhain_log
|
---|
129 | rm -f ./.samhain_lock
|
---|
130 | rm -f ./rc.${SH_LOCALHOST}
|
---|
131 | rm -f ./file.${SH_LOCALHOST}
|
---|
132 |
|
---|
133 | cp ${SCRIPTDIR}/testrc_2.in testrc_2
|
---|
134 |
|
---|
135 | ./samhain.build -t init -p none
|
---|
136 |
|
---|
137 | if test x$? = x0; then
|
---|
138 | [ -z "$verbose" ] || log_msg_ok "init...";
|
---|
139 | else
|
---|
140 | [ -z "$quiet" ] && log_msg_fail "init...";
|
---|
141 | return 1
|
---|
142 | fi
|
---|
143 |
|
---|
144 | # Create a password
|
---|
145 |
|
---|
146 | SHPW=`./yule -G`
|
---|
147 | if test x"$SHPW" = x; then
|
---|
148 | [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting"
|
---|
149 | return 1
|
---|
150 | fi
|
---|
151 |
|
---|
152 | # Set in client
|
---|
153 |
|
---|
154 | ./samhain_setpwd samhain.build new $SHPW >/dev/null
|
---|
155 |
|
---|
156 | if test x$? = x0; then
|
---|
157 | [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd samhain.build new $SHPW";
|
---|
158 | else
|
---|
159 | [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd samhain.build new $SHPW";
|
---|
160 | return 1
|
---|
161 | fi
|
---|
162 |
|
---|
163 | mv samhain.build.new samhain.new || return 1
|
---|
164 |
|
---|
165 | rm -f ./.samhain_log*
|
---|
166 | rm -f ./.samhain_lock
|
---|
167 |
|
---|
168 | SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%`
|
---|
169 |
|
---|
170 | if test x$? = x0; then
|
---|
171 | [ -z "$verbose" ] || log_msg_ok "yule -P $SHPW";
|
---|
172 | else
|
---|
173 | [ -z "$quiet" ] && log_msg_fail "yule -P $SHPW";
|
---|
174 | return 1
|
---|
175 | fi
|
---|
176 |
|
---|
177 | echo $SHCLT >> testrc_2
|
---|
178 |
|
---|
179 | cp ./testrc_2 ./rc.${SH_LOCALHOST}
|
---|
180 | mv ./.samhain_file ./file.${SH_LOCALHOST}
|
---|
181 |
|
---|
182 | ALTHOST=`find_hostname`
|
---|
183 | cp ./testrc_2 "./rc.${ALTHOST}"
|
---|
184 | cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null
|
---|
185 |
|
---|
186 | }
|
---|
187 |
|
---|
188 | MAXTEST=1; export MAXTEST
|
---|
189 |
|
---|
190 | testrun2a ()
|
---|
191 | {
|
---|
192 | log_start "RUN FULL CLIENT/SERVER";
|
---|
193 | #
|
---|
194 | if [ x"$1" = x ]; then
|
---|
195 | [ -z "$quiet" ] && log_msg_fail "Missing hostname"
|
---|
196 | fi
|
---|
197 | #
|
---|
198 | SH_LOCALHOST=$1; export SH_LOCALHOST
|
---|
199 | #
|
---|
200 | testrun2a_internal
|
---|
201 | #
|
---|
202 | do_test_1_a
|
---|
203 | if [ $? -eq 0 ]; then
|
---|
204 | [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client download+logging";
|
---|
205 | else
|
---|
206 | [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client download+logging";
|
---|
207 | fi
|
---|
208 | #
|
---|
209 | if [ -n "$cleanup" ]; then
|
---|
210 | rm -f ./rc.${SH_LOCALHOST}
|
---|
211 | rm -f ./file.${SH_LOCALHOST}
|
---|
212 | ALTHOST=`find_hostname`
|
---|
213 | rm -f "./file.${ALTHOST}"
|
---|
214 | rm -f "./rc.${ALTHOST}"
|
---|
215 | fi
|
---|
216 | #
|
---|
217 | log_end "RUN FULL CLIENT/SERVER"
|
---|
218 | }
|
---|
219 |
|
---|