1 | #! /bin/sh
|
---|
2 |
|
---|
3 |
|
---|
4 | MAXTEST=2; export MAXTEST
|
---|
5 | LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
|
---|
6 | RCFILE="$PW_DIR/testrc_1.dyn"; export RCFILE
|
---|
7 |
|
---|
8 | testrun1b_internal ()
|
---|
9 | {
|
---|
10 | BUILDOPTS="$1"
|
---|
11 | #
|
---|
12 | # test standalone compilation
|
---|
13 | #
|
---|
14 | [ -z "$verbose" ] || { echo; echo "${S}Building standalone agent${E}"; echo; }
|
---|
15 | #
|
---|
16 | if test -r "Makefile"; then
|
---|
17 | $MAKE distclean >/dev/null
|
---|
18 | fi
|
---|
19 | #
|
---|
20 | #
|
---|
21 | ${TOP_SRCDIR}/configure ${BUILDOPTS} >/dev/null 2>/dev/null
|
---|
22 | #
|
---|
23 | #
|
---|
24 | if test x$? = x0; then
|
---|
25 | [ -z "$verbose" ] || log_msg_ok "configure...";
|
---|
26 | $MAKE > /dev/null
|
---|
27 | if test x$? = x0; then
|
---|
28 | [ -z "$verbose" ] || log_msg_ok "make...";
|
---|
29 | else
|
---|
30 | [ -z "$quiet" ] && log_msg_fail "make...";
|
---|
31 | return 1
|
---|
32 | fi
|
---|
33 |
|
---|
34 | else
|
---|
35 | [ -z "$quiet" ] && log_msg_fail "configure...";
|
---|
36 | return 1
|
---|
37 | fi
|
---|
38 |
|
---|
39 | SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ { print NR + 1; exit 0; }' ${SCRIPTDIR}/test.sh`
|
---|
40 |
|
---|
41 | tail -n "+$SKIP" ${SCRIPTDIR}/test.sh >/dev/null 2>&1
|
---|
42 | if [ $? -eq 0 ]; then
|
---|
43 | tail -n "+$SKIP" ${SCRIPTDIR}/test.sh | gunzip -c - | tar xf - && \
|
---|
44 | mv "./testrc.gpg.asc" "$RCFILE"
|
---|
45 | else
|
---|
46 | tail "+$SKIP" ${SCRIPTDIR}/test.sh | gunzip -c - | tar xf - && \
|
---|
47 | mv "./testrc.gpg.asc" "$RCFILE"
|
---|
48 | fi
|
---|
49 | if test x$? = x0; then
|
---|
50 | [ -z "$verbose" ] || log_msg_ok "extract gpg signed files...";
|
---|
51 | else
|
---|
52 | [ -z "$quiet" ] && log_msg_fail "extract gpg signed files...";
|
---|
53 | return 1
|
---|
54 | fi
|
---|
55 |
|
---|
56 | rm -f ./.samhain_file
|
---|
57 | rm -f ./.samhain_log
|
---|
58 | rm -f ./.samhain_lock
|
---|
59 |
|
---|
60 | ./samhain -t init -p none -l info
|
---|
61 |
|
---|
62 | if test x$? = x0; then
|
---|
63 | [ -z "$verbose" ] || log_msg_ok "init...";
|
---|
64 | else
|
---|
65 | [ -z "$quiet" ] && log_msg_fail "init...";
|
---|
66 | return 1
|
---|
67 | fi
|
---|
68 |
|
---|
69 | mv $PW_DIR/.samhain_file.asc $PW_DIR/.samhain_file
|
---|
70 | }
|
---|
71 |
|
---|
72 | do_test_1b () {
|
---|
73 |
|
---|
74 | ./samhain -t check -p none -l info
|
---|
75 |
|
---|
76 | if test x$? = x0; then
|
---|
77 | ./samhain -j -L $LOGFILE >"${LOGFILE}.tmp" && mv "${LOGFILE}.tmp" "${LOGFILE}"
|
---|
78 | if [ $? -ne 0 ]; then
|
---|
79 | [ -z "$quiet" ] && log_msg_fail "mv logfile...";
|
---|
80 | return 1
|
---|
81 | fi
|
---|
82 | [ -z "$verbose" ] || log_msg_ok "check...";
|
---|
83 | else
|
---|
84 | [ -z "$quiet" ] && log_msg_fail "check...";
|
---|
85 | return 1
|
---|
86 | fi
|
---|
87 | #
|
---|
88 | tmp=`egrep "Checking.*/etc(>|\")" $LOGFILE 2>/dev/null | wc -l`
|
---|
89 | if [ $tmp -ne 2 ]; then
|
---|
90 | [ -z "$verbose" ] || log_msg_fail "/etc";
|
---|
91 | fi
|
---|
92 | tmp=`egrep "Checking.*(>|\")" $LOGFILE 2>/dev/null | wc -l`
|
---|
93 | if [ $tmp -ne 2 ]; then
|
---|
94 | [ -z "$verbose" ] || log_msg_fail "checking";
|
---|
95 | fi
|
---|
96 | #
|
---|
97 | return 0
|
---|
98 | }
|
---|
99 |
|
---|
100 | do_test_1b_2 () {
|
---|
101 |
|
---|
102 | rm -f $PW_DIR/test_log_prelude
|
---|
103 |
|
---|
104 | ( "$PM" --textmod -l $PW_DIR/test_log_prelude >/dev/null 2>&1 )&
|
---|
105 | PID=$!
|
---|
106 |
|
---|
107 | ./samhain -t check -p none -l info --set-prelude-severity=info >/dev/null
|
---|
108 |
|
---|
109 | if test x$? = x0; then
|
---|
110 | ./samhain -j -L $LOGFILE >"${LOGFILE}.tmp" && mv "${LOGFILE}.tmp" "${LOGFILE}"
|
---|
111 | if [ $? -ne 0 ]; then
|
---|
112 | [ -z "$quiet" ] && log_msg_fail "mv logfile...";
|
---|
113 | kill $PID
|
---|
114 | return 1
|
---|
115 | fi
|
---|
116 | [ -z "$verbose" ] || log_msg_ok "check...";
|
---|
117 | else
|
---|
118 | [ -z "$quiet" ] && log_msg_fail "check...";
|
---|
119 | kill $PID
|
---|
120 | return 1
|
---|
121 | fi
|
---|
122 | #
|
---|
123 | tmp=`egrep 'File original:.*name=etc.*path=/etc' test_log_prelude 2>/dev/null | wc -l`
|
---|
124 | if [ $tmp -ne 1 ]; then
|
---|
125 | [ -z "$verbose" ] || log_msg_fail "/etc";
|
---|
126 | fi
|
---|
127 | tmp=`egrep 'Classification text: Checking' test_log_prelude 2>/dev/null | wc -l`
|
---|
128 | if [ $tmp -ne 1 ]; then
|
---|
129 | [ -z "$verbose" ] || log_msg_fail "checking";
|
---|
130 | fi
|
---|
131 | tmp=`egrep 'Classification text: Checking' test_log_prelude 2>/dev/null | wc -l`
|
---|
132 | if [ $tmp -ne 1 ]; then
|
---|
133 | [ -z "$verbose" ] || log_msg_fail "checking";
|
---|
134 | fi
|
---|
135 | #
|
---|
136 | kill $PID
|
---|
137 | return 0
|
---|
138 | }
|
---|
139 |
|
---|
140 | testrun1b ()
|
---|
141 | {
|
---|
142 | log_start "RUN STANDALONE W/STEALTH W/GPG"
|
---|
143 | GPG=`find_path gpg`
|
---|
144 | if [ -z "$GPG" ]; then
|
---|
145 | log_skip 1 $MAXTEST 'gpg not found in $PATH'
|
---|
146 | log_skip 2 $MAXTEST 'gpg not found in $PATH'
|
---|
147 | else
|
---|
148 | eval "$GPG" --list-keys 0F571F6C >/dev/null 2>/dev/null
|
---|
149 | if [ $? -ne 0 ]; then
|
---|
150 | log_skip 1 $MAXTEST 'public PGP key 0x0F571F6C not present'
|
---|
151 | log_skip 2 $MAXTEST 'public PGP key 0x0F571F6C not present'
|
---|
152 | else
|
---|
153 | 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"
|
---|
154 | testrun1b_internal "${BUILDOPTS}"
|
---|
155 | do_test_1b
|
---|
156 | if [ $? -eq 0 ]; then
|
---|
157 | log_ok 1 $MAXTEST 'gpg signed config/database files'
|
---|
158 | else
|
---|
159 | log_fail 1 $MAXTEST 'gpg signed config/database files'
|
---|
160 | fi
|
---|
161 | PM=`find_path prelude-manager`
|
---|
162 | if [ -z "$PM" ]; then
|
---|
163 | log_skip 2 $MAXTEST 'prelude-manager not found in $PATH'
|
---|
164 | elif [ -z "$doall" ]; then
|
---|
165 | log_skip 2 $MAXTEST 'logging to prelude (or use --really-all)'
|
---|
166 | else
|
---|
167 | 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"
|
---|
168 | testrun1b_internal "${BUILDOPTS}"
|
---|
169 | do_test_1b_2
|
---|
170 | if [ $? -eq 0 ]; then
|
---|
171 | log_ok 2 $MAXTEST 'logging to prelude'
|
---|
172 | else
|
---|
173 | log_fail 2 $MAXTEST 'logging to prelude'
|
---|
174 | fi
|
---|
175 | fi
|
---|
176 | fi
|
---|
177 | fi
|
---|
178 | log_end "RUN STANDALONE W/STEALTH W/GPG"
|
---|
179 | return 0
|
---|
180 | }
|
---|
181 |
|
---|