Changeset 19 for trunk/test/testrun_1b.sh
- Timestamp:
- Feb 12, 2006, 10:49:56 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/testrun_1b.sh
r1 r19 2 2 3 3 4 # The following two are the ANSI sequences for start and end embolden 5 case $TERM in 6 vt*|ansi*|con*|xterm*|linux*|screen*) 7 S=[1m 8 E=[m 9 ;; 10 *) 11 S= 12 E= 13 ;; 14 esac 4 MAXTEST=2; export MAXTEST 5 LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE 6 RCFILE="$PW_DIR/testrc_1.dyn"; export RCFILE 15 7 16 PW_DIR=`pwd` 17 18 if test x$UID != x; then 19 TRUST="--with-trusted=0,2,$UID" 20 else 21 TRUST="--with-trusted=0,2" 22 fi 23 24 echo; echo "${S}__ STARTING TEST RUN STEALTH W/GPG STANDALONE __${E}"; echo; 25 echo Working directory: $PW_DIR 26 27 MAKE=`which gmake` 28 if test "x$?" = x1 ; then 29 MAKE="make -s" 30 else 31 MAKE=`which gmake | sed -e "s%\([a-z:]\) .*%\1%g"` 32 if test "x$MAKE" = x; then 33 MAKE="make -s" 34 elif test "x$MAKE" = xno; then 35 MAKE="make -s" 36 else 37 if test "x$MAKE" = "xwhich:"; then 38 MAKE="make -s" 39 else 40 MAKE="gmake -s" 41 gmake -v >/dev/null 2>&1 || MAKE="make -s" 42 fi 43 fi 44 fi 45 echo MAKE is $MAKE 46 47 # $GPG_PATH _must_ be an absolute path 48 # 49 if test x${GPG_PATH} = x; then 50 GPG_PATH=`which gpg | sed -e "s%\([a-z:]\) .*%\1%g"` 51 fi 52 53 if test x${GPG_PATH} = x; then 54 echo "ERROR: gpg (GnuPG) not found" 55 exit 56 else 57 GPG_OK=`echo ${GPG_PATH} | sed -e "s%\(/.*\)%OK%g"` 58 if test x${GPG_OK} = xOK; then 59 echo "GPG_PATH is ${GPG_PATH}" 60 else 61 echo "ERROR: GPG_PATH (${GPG_PATH}) is _not_ an absolute path." 62 echo 63 echo " Apparently the command 'which gpg' did not yield an absolute path." 64 echo " You can fix the problem by setting the environment variable GPG_PATH" 65 echo " to the absolute path to gpg (GnuPG) and start the test again." 66 exit 67 fi 68 fi 69 70 echo 71 72 testrun1 () 8 testrun1b_internal () 73 9 { 10 BUILDOPTS="$1" 74 11 # 75 12 # test standalone compilation 76 13 # 77 echo "${S}Building standalone agent${E}"; echo;14 [ -z "$verbose" ] || { echo; echo "${S}Building standalone agent${E}"; echo; } 78 15 # 79 16 if test -r "Makefile"; then 80 $MAKE distclean 17 $MAKE distclean >/dev/null 81 18 fi 82 19 # 83 GPG_HASH=`${GPG_PATH} --load-extension tiger --print-md TIGER192 ${GPG_PATH}`84 20 # 85 echo GPG_HASH is ${GPG_HASH}21 ${TOP_SRCDIR}/configure ${BUILDOPTS} >/dev/null 2>/dev/null 86 22 # 87 ${TOP_SRCDIR}/configure --quiet $TRUST --enable-debug --with-gpg=${GPG_PATH} --enable-micro-stealth=137 --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/testrc_1.signed --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file88 #89 # --with-prelude --enable-xml-log90 # --with-checksum="${GPG_HASH}"91 23 # 92 24 if test x$? = x0; then 93 echo "configure completed, exit status 0"; echo;25 [ -z "$verbose" ] || log_msg_ok "configure..."; 94 26 $MAKE > /dev/null 95 27 if test x$? = x0; then 96 echo "$MAKE completed, exit status $?"; echo;28 [ -z "$verbose" ] || log_msg_ok "make..."; 97 29 else 98 echo "${S}ERROR:${E} make failed, exit status $?"; echo;99 exit30 [ -z "$quiet" ] && log_msg_fail "make..."; 31 return 1 100 32 fi 101 33 102 34 else 103 echo "${S}ERROR:${E} configure failed, exit status $?"; echo;104 exit35 [ -z "$quiet" ] && log_msg_fail "configure..."; 36 return 1 105 37 fi 106 38 107 cp $PW_DIR/test/testrc_1 $PW_DIR/testrc_1.signed 108 echo "--- You need to sign the config file testrc_1.signed now ---" 109 echo 110 ${GPG_PATH} -a --clearsign $PW_DIR/testrc_1.signed 111 mv $PW_DIR/testrc_1.signed.asc $PW_DIR/testrc_1.signed 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 112 55 113 56 rm -f ./.samhain_file … … 115 58 rm -f ./.samhain_lock 116 59 117 ./samhain -t init 60 ./samhain -t init -p none -l info 118 61 119 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 120 68 121 echo 122 echo "--- You need to sign the database .samhain_file now ---" 123 echo 124 ${GPG_PATH} -a --clearsign --not-dash-escaped $PW_DIR/.samhain_file 125 mv $PW_DIR/.samhain_file.asc $PW_DIR/.samhain_file 126 127 ./samhain -t check 128 if test x$? = x0; then 129 echo "${S}check completed${E}" 130 else 131 echo "${S}ERROR:${E} -- check -- failed, exit status $?" 132 echo 133 exit 134 fi 135 else 136 echo "${S}ERROR:${E} -- init -- failed, exit status $?"; echo; 137 exit 138 fi 139 69 mv $PW_DIR/.samhain_file.asc $PW_DIR/.samhain_file 140 70 } 141 71 72 do_test_1b () { 142 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 } 143 99 144 testrun1 100 do_test_1b_2 () { 145 101 102 rm -f $PW_DIR/test_log_prelude 146 103 147 echo; echo "${S}__ END TEST RUN STANDALONE __${E}"; echo; 104 ( "$PM" --textmod -l $PW_DIR/test_log_prelude >/dev/null 2>&1 )& 105 PID=$! 148 106 149 exit 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 } 150 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
Note:
See TracChangeset
for help on using the changeset viewer.