Changeset 19
- Timestamp:
- Feb 12, 2006, 10:49:56 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile.in
r18 r19 307 307 308 308 CLEANFILES = encode config_xor.h depend-gen sh_ks.h sh_ks_xor.h kern_head \ 309 internal.h sh_MK.h trustfile sstrip samhain mkhdr encode \309 internal.h sh_MK.h trustfile sstrip samhain mkhdr encode cutest \ 310 310 yule samhain_setpwd samhain_stealth samhainrc yulectl samhain_hide.ko 311 311 -
trunk/configure.ac
r18 r19 617 617 [ --enable-message-queue[[=MODE]] enable SysV message queue [[MODE=0700]]], 618 618 [ 619 if test "x${enable_message_queue}" = xyes; then 619 if test "x${ac_cv_header_sys_msg_h}" = "xyes"; then 620 if test "x${enable_message_queue}" = xyes; then 621 AC_DEFINE(WITH_MESSAGE_QUEUE) 622 AC_DEFINE_UNQUOTED(MESSAGE_QUEUE_MODE, 0700) 623 elif test "x${enable_message_queue}" != xno; then 624 echo "${enableval}" | grep ['[^0123456789]'] >/dev/null 2>&1 && 625 AC_MSG_ERROR([--enable-message-queue: MODE must be numeric]) 626 echo "${enableval}" | \ 627 grep ['0[0123456789][0123456789][0123456789]'] >/dev/null 2>&1 || 628 AC_MSG_ERROR([--enable-message-queue: MODE must be an octal (0nnn) number]) 620 629 AC_DEFINE(WITH_MESSAGE_QUEUE) 621 AC_DEFINE_UNQUOTED(MESSAGE_QUEUE_MODE, 0700) 622 elif test "x${enable_message_queue}" != xno; then 623 echo "${enableval}" | grep ['[^0123456789]'] >/dev/null 2>&1 && 624 AC_MSG_ERROR([--enable-message-queue: MODE must be numeric]) 625 echo "${enableval}" | \ 626 grep ['0[0123456789][0123456789][0123456789]'] >/dev/null 2>&1 || 627 AC_MSG_ERROR([--enable-message-queue: MODE must be an octal (0nnn) number]) 628 AC_DEFINE(WITH_MESSAGE_QUEUE) 629 AC_DEFINE_UNQUOTED(MESSAGE_QUEUE_MODE, ${enable_message_queue}) 630 AC_DEFINE_UNQUOTED(MESSAGE_QUEUE_MODE, ${enable_message_queue}) 631 fi 632 else 633 echo 634 echo "**********************************************" 635 echo 636 AC_MSG_WARN([sys/msg.h missing, --enable-message-queue disabled]) 637 echo 638 echo "**********************************************" 639 echo 630 640 fi 631 641 ] … … 871 881 AC_CHECK_PROG(HAVE_MYSQL_CONFIG, mysql_config, yes, no) 872 882 if test "$HAVE_MYSQL_CONFIG" = "yes"; then 873 echo "mysql_config found"883 # echo "mysql_config found" 874 884 sh_mysql_libs="`mysql_config --libs`" 875 885 # echo ${sh_mysql_libs} … … 880 890 # echo $LIBS 881 891 LIBS="$LIBS ${sh_mysql_libs}" 882 echo $LIBS892 # echo $LIBS 883 893 sh_mysql_cflags="`mysql_config --cflags`" 884 894 sh_mysql_cflags="`eval echo ${sh_mysql_cflags}`" -
trunk/docs/FAQ.html
r1 r19 129 129 <br><center><h2>Rainer Wichmann</h2></center> 130 130 <hr> 131 <p><i>FAQ Revised: Saturday 17 September 2005 09:10:07</i></p>131 <p><i>FAQ Revised: Tuesday 31 January 2006 21:28:35</i></p> 132 132 <hr><h2>Table of Contents</h2> 133 133 <dl> … … 149 149 <li><a href="#Build and install6">2.7. --enable-xml-log has no effect</a></li> 150 150 <li><a href="#Build and install7">2.8. ./install-sh: strip: not found (Solaris)</a></li> 151 <li><a href="#Build and install8">2.9. What is sh_tiger1.s?</a></li> 151 152 </ul></dd> 152 153 <dt><b>3. File checking</b></dt> … … 208 209 <li><a href="#Database2">7.3. I don't want the client TIMESTAMP messages in the SQL database</a></li> 209 210 <li><a href="#Database3">7.4. What does the log_ref field mean ?</a></li> 211 <li><a href="#Database4">7.5. How can I check what is in the database ?</a></li> 210 212 </ul></dd> 211 213 </dl> … … 373 375 <dt><b><a name="Build and install7">2.8. ./install-sh: strip: not found (Solaris)</a></b></dt> 374 376 <dd>Install the SUNWbtool package.<br><br></dd> 377 <dt><b><a name="Build and install8">2.9. What is sh_tiger1.s?</a></b></dt> 378 <dd>This is a precompiled assembly file for the i386 architecture 379 generated from sh_tiger1.c using gcc 3.4.0 with the following options, 380 that were found to generate the fastest code: 381 <pre> 382 -O1 -fno-delayed-branch -fexpensive-optimizations -fstrength-reduce 383 -fpeephole2 -fschedule-insns2 -fregmove -frename-registers -fweb 384 -momit-leaf-frame-pointer -funroll-loops 385 </pre> 386 These options were determined using 387 <a href="http://www.coyotegulch.com/products/acovea/">acovea</a> 5.1.1 388 by Scott Robert Ladd. The file is provided as precompiled assembly 389 because different versions of gcc can have very different performance, 390 require different options to compile optimal code, and 391 it would be impossible to maintain a library of optimal compile options 392 for every version of gcc.<br><br></dd> 375 393 </dl> 376 394 <hr><h2>3. File checking</h2> … … 743 761 744 762 2.) In your client or server configuration file, you are using 745 the option for a cust um message header, but without paying attention763 the option for a custom message header, but without paying attention 746 764 to preserving the XML format. 747 765 </pre></div><br><br></dd> … … 793 811 number of the corresponding client message). Zero indicates a message 794 812 by the server itself (e.g. the server's start message).<br><br></dd> 813 <dt><b><a name="Database4">7.5. How can I check what is in the database ?</a></b></dt> 814 <dd>Use a command line client to login to the database and query it: 815 <div class="block"><pre> 816 sh$ mysql -u <user_name> -p <database_name> 817 Enter password: **** 818 mysql> SELECT log_index,log_ref,log_host,log_sev,log_msg,path FROM <table_name> WHERE entry_status = 'NEW' ORDER BY log_index; 819 .... 820 mysql> \q 821 </pre></div><br><br></dd> 795 822 </dl> 796 823 <hr> -
trunk/include/samhain.h
r18 r19 292 292 if ((skey != NULL) && skey->mlock_failed == SL_FALSE){ \ 293 293 (void) sl_set_suid(); \ 294 if (sh_unix_mlock( a, b) < 0) skey->mlock_failed = SL_TRUE; \294 if (sh_unix_mlock(FIL__, __LINE__, a, b) < 0) skey->mlock_failed = SL_TRUE; \ 295 295 (void) sl_unset_suid(); } 296 296 #else -
trunk/include/sh_tiger.h
r1 r19 18 18 */ 19 19 /*@owned@*/ char * sh_tiger_hash (char * filename, TigerType what, 20 unsigned longLength);20 UINT64 Length); 21 21 22 22 /* NEW Thu Oct 18 19:59:08 CEST 2001 … … 24 24 int sh_tiger_hashtype (char * c); 25 25 char * sh_tiger_generic_hash (char * filename, TigerType what, 26 unsigned longLength, int timeout);26 UINT64 Length, int timeout); 27 27 28 28 UINT32 * sh_tiger_hash_uint32 (char * filename, 29 29 TigerType what, 30 unsigned longLength);30 UINT64 Length); 31 31 32 32 /* get the type of hash function used … … 38 38 */ 39 39 /*@owned@*/ char * sh_tiger_hash_gpg (char * filename, TigerType what, 40 unsigned longLength);40 UINT64 Length); 41 41 #endif -
trunk/include/sh_unix.h
r10 r19 79 79 /* device num */ 80 80 #define MODI_RDEV (1 << 11) 81 /* size may grow */ 82 #define MODI_SGROW (1 << 12) 83 /* use prelink */ 84 #define MODI_PREL (1 << 13) 81 85 82 86 #define MASK_ALLIGNORE_ 0 … … 86 90 #define MASK_LOGFILES_ (MASK_ATTRIBUTES_|MODI_HLN|MODI_LNK|MODI_INO) 87 91 extern unsigned long mask_LOGFILES; 88 #define MASK_LOGGROW_ (MASK_LOGFILES_|MODI_SIZ )92 #define MASK_LOGGROW_ (MASK_LOGFILES_|MODI_SIZ|MODI_SGROW|MODI_CHK) 89 93 extern unsigned long mask_LOGGROW; 90 94 #define MASK_READONLY_ (MASK_LOGFILES_|MODI_CHK|MODI_SIZ|MODI_MTM|MODI_CTM) … … 95 99 extern unsigned long mask_USER0; 96 100 extern unsigned long mask_USER1; 97 /* like READONLY, but without MTM,CTM,SIZ,INO )98 */ 99 #define MASK_PRELINK_ (MASK_ATTRIBUTES_|MODI_HLN|MODI_LNK|MODI_CHK )101 /* like READONLY, but without MTM,CTM,SIZ,INO, abd with PREL) 102 */ 103 #define MASK_PRELINK_ (MASK_ATTRIBUTES_|MODI_HLN|MODI_LNK|MODI_CHK|MODI_PREL) 100 104 extern unsigned long mask_PRELINK; 101 105 … … 134 138 /* mlock utilities 135 139 */ 136 int sh_unix_mlock( void * addr, size_t len);140 int sh_unix_mlock(char * file, int line, void * addr, size_t len); 137 141 int sh_unix_munlock(void * addr, size_t len); 138 142 int sh_unix_count_mlock(); -
trunk/src/cutest_sh_tiger0.c
r17 r19 233 233 CuAssertTrue(tc, result == 0); 234 234 235 236 235 } 236 237 /* test checksum of file upto some given length 238 */ 239 void Test_tiger_file_with_length(CuTest *tc) { 240 241 SL_TICKET rval_open; 242 FILE * fp; 243 int result; 244 char * actual; 245 char * expected; 246 247 char * teststring = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996.\n"; 248 int testlen = strlen(teststring); 249 250 init(); 251 252 fp = fopen("cutest_foo", "w"); 253 CuAssertPtrNotNull(tc, fp); 254 255 result = fprintf(fp, "%s", teststring); 256 CuAssertTrue(tc, result >= 0); 257 result = fprintf(fp, "%s", teststring); 258 CuAssertTrue(tc, result >= 0); 259 260 result = fclose(fp); 261 CuAssertTrue(tc, result == 0); 262 263 result = sh_tiger_hashtype("TIGER192"); 264 CuAssertTrue(tc, result == 0); 265 266 /* same as GnuPG 1.0.6 (gpg --load-extension tiger --print-md TIGER192) 267 */ 268 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, testlen, 0); 269 expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8"; 270 CuAssertStrEquals(tc, expected, actual); 271 272 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 2*testlen, 0); 273 expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90"; 274 CuAssertStrEquals(tc, expected, actual); 275 276 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 0, 0); 277 expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90"; 278 CuAssertStrEquals(tc, expected, actual); 279 280 fp = fopen("cutest_foo", "a"); 281 CuAssertPtrNotNull(tc, fp); 282 result = fprintf(fp, "%s", teststring); 283 CuAssertTrue(tc, result >= 0); 284 result = fclose(fp); 285 CuAssertTrue(tc, result == 0); 286 287 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, testlen, 0); 288 expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8"; 289 CuAssertStrEquals(tc, expected, actual); 290 291 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 2*testlen, 0); 292 expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90"; 293 CuAssertStrEquals(tc, expected, actual); 294 295 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 3*testlen, 0); 296 expected = "D0EE1A9956CAB22D84B51A5E0C093B724828C6A1F9CBDB7F"; 297 CuAssertStrEquals(tc, expected, actual); 298 299 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 0, 0); 300 expected = "D0EE1A9956CAB22D84B51A5E0C093B724828C6A1F9CBDB7F"; 301 CuAssertStrEquals(tc, expected, actual); 302 303 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 5, 0); 304 expected = "9F00F599072300DD276ABB38C8EB6DEC37790C116F9D2BDF"; 305 CuAssertStrEquals(tc, expected, actual); 306 307 /* same results as GNU md5sum */ 308 309 result = sh_tiger_hashtype("MD5"); 310 CuAssertTrue(tc, result == 0); 311 312 rval_open = sl_open_fastread ("cutest_foo", SL_YESPRIV); 313 CuAssertTrue(tc, rval_open >= 0); 314 tiger_fd = rval_open; 315 316 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, testlen, 0); 317 expected = "11E7E7EA486136273606BEE57C71F34B0000000000000000"; 318 CuAssertStrEquals(tc, expected, actual); 319 320 result = sl_rewind(rval_open); 321 CuAssertTrue(tc, rval_open >= 0); 322 323 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 2*testlen, 0); 324 expected = "D49DAD474095D467E2E5EFCB2DC23A770000000000000000"; 325 CuAssertStrEquals(tc, expected, actual); 326 327 result = sl_rewind(rval_open); 328 CuAssertTrue(tc, rval_open >= 0); 329 330 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 3*testlen, 0); 331 expected = "00A1F1C5EDDCCFC430D3862FDA94593E0000000000000000"; 332 CuAssertStrEquals(tc, expected, actual); 333 334 result = sl_rewind(rval_open); 335 CuAssertTrue(tc, rval_open >= 0); 336 337 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 0, 0); 338 expected = "00A1F1C5EDDCCFC430D3862FDA94593E0000000000000000"; 339 CuAssertStrEquals(tc, expected, actual); 340 341 /* same result as gpg --print-md SHA1 342 */ 343 344 result = sh_tiger_hashtype("SHA1"); 345 CuAssertTrue(tc, result == 0); 346 347 result = sl_rewind(rval_open); 348 CuAssertTrue(tc, rval_open >= 0); 349 350 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, testlen, 0); 351 expected = "F37DB4344CCD140EE315179E9A27512FB4704F0F00000000"; 352 CuAssertStrEquals(tc, expected, actual); 353 354 result = sl_rewind(rval_open); 355 CuAssertTrue(tc, rval_open >= 0); 356 357 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 2*testlen, 0); 358 expected = "D2AD5FC366452D81400BAC31F96269DEEF314BC200000000"; 359 CuAssertStrEquals(tc, expected, actual); 360 361 result = sl_rewind(rval_open); 362 CuAssertTrue(tc, rval_open >= 0); 363 364 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 3*testlen, 0); 365 expected = "FAA937EF3389C7E786EB0F1006D049D7AEA7B7B600000000"; 366 CuAssertStrEquals(tc, expected, actual); 367 368 result = sl_rewind(rval_open); 369 CuAssertTrue(tc, rval_open >= 0); 370 371 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 0, 0); 372 expected = "FAA937EF3389C7E786EB0F1006D049D7AEA7B7B600000000"; 373 CuAssertStrEquals(tc, expected, actual); 374 375 result = sl_close(rval_open); 376 CuAssertTrue(tc, result == 0); 377 378 result = remove("cutest_foo"); 379 CuAssertTrue(tc, result == 0); 380 } -
trunk/src/cutest_sh_tools.c
r17 r19 4 4 #include <string.h> 5 5 #include "CuTest.h" 6 #include "samhain.h" 6 7 #include "sh_tools.h" 7 8 -
trunk/src/make-tests.sh
r17 r19 6 6 # Author: Asim Jalis 7 7 # Date: 01/08/2003 8 9 # Modified to return non-zero if any test has failed 10 # Rainer Wichmann, 29. Jan 2006 11 # ...and to print to stderr if any test has failed 12 # Rainer Wichmann, 31. Jan 2006 8 13 9 14 if test $# -eq 0 ; then FILES=*.c ; else FILES=$* ; fi … … 26 31 ' 27 32 28 voidRunAllTests(void)33 int RunAllTests(void) 29 34 { 30 35 CuString *output = CuStringNew(); … … 43 48 CuSuiteSummary(suite, output); 44 49 CuSuiteDetails(suite, output); 45 printf("%s\n", output->buffer); 50 if (suite->failCount > 0) 51 fprintf(stderr, "%s\n", output->buffer); 52 else 53 fprintf(stdout, "%s\n", output->buffer); 54 return suite->failCount; 46 55 } 47 56 48 57 int main(void) 49 58 { 50 RunAllTests(); 51 return 0; 59 int retval; 60 retval = RunAllTests(); 61 return (retval == 0) ? 0 : 1; 52 62 } 53 63 ' -
trunk/src/samhain.c
r18 r19 1752 1752 } 1753 1753 1754 if (sig_suspend_switch == 1) /* SIGUSR2 */1754 if (sig_suspend_switch > 0) /* SIGUSR2 */ 1755 1755 { 1756 1756 TPT((0, FIL__, __LINE__, _("msg=<Suspend switch.>\n"))); … … 1762 1762 sh_global_suspend_flag = 1; 1763 1763 } 1764 sig_suspend_switch = 0;1764 --sig_suspend_switch; 1765 1765 --sig_raised; --sig_urgent; 1766 1766 } -
trunk/src/sh_err_log.c
r1 r19 755 755 if (skey->mlock_failed == SL_FALSE) 756 756 { 757 if ( (-1) == sh_unix_mlock( log_msg.msg,757 if ( (-1) == sh_unix_mlock( FIL__, __LINE__, log_msg.msg, 758 758 (size_t)(2*KEY_LEN + status + 32) ) ) 759 759 { -
trunk/src/sh_files.c
r8 r19 590 590 if (0 == strncmp(myword, _("HLN"), 3)) 591 591 sh_files_set_mask (mask, MODI_HLN, act); 592 /* size may grow */ 593 if (0 == strncmp(myword, _("GROW"), 3)) 594 sh_files_set_mask (mask, MODI_SGROW, act); 595 /* use prelink */ 596 if (0 == strncmp(myword, _("PRE"), 3)) 597 sh_files_set_mask (mask, MODI_PREL, act); 592 598 593 599 } … … 1010 1016 ++dcount; 1011 1017 } 1012 ptr->checked = S_TRUE; 1018 ptr->checked = S_TRUE; 1019 ptr->childs_checked = S_TRUE; 1013 1020 } 1014 1021 … … 1425 1432 1426 1433 dirstack_t * dst_ptr; 1434 dirstack_t * tmp_ptr; 1427 1435 1428 1436 int hardlink_num = 0; … … 1645 1653 file_class_next = dst_ptr->class; 1646 1654 checked_flag = dst_ptr->checked; 1647 cchecked_flag = dst_ptr->childs_checked; 1655 /* not set, hence always FALSE */ 1656 /* cchecked_flag = dst_ptr->childs_checked; */ 1648 1657 } 1649 1658 … … 1708 1717 cchecked_flag = -1; 1709 1718 1710 dst_ptr = (dirstack_t *) zAVLSearch(zdirListOne, tmpcat);1711 1712 if ( dst_ptr)1719 tmp_ptr = (dirstack_t *) zAVLSearch(zdirListOne, tmpcat); 1720 1721 if (tmp_ptr) 1713 1722 { 1714 1723 TPT((0, FIL__, __LINE__, 1715 1724 _("msg=<%s -> recursion depth %d\n>"), 1716 dst_ptr->name, dst_ptr->rdepth));1717 rdepth_next = dst_ptr->rdepth;1718 class_next = dst_ptr->class;1725 tmp_ptr->name, tmp_ptr->rdepth)); 1726 rdepth_next = tmp_ptr->rdepth; 1727 class_next = tmp_ptr->class; 1719 1728 /* 28. Aug 2001 reversed 1720 1729 */ 1721 cchecked_flag = dst_ptr->childs_checked;1722 checked_flag = dst_ptr->checked;1730 cchecked_flag = tmp_ptr->childs_checked; 1731 checked_flag = tmp_ptr->checked; 1723 1732 } 1724 1733 1725 1734 if (checked_flag == -1) 1726 1735 { 1727 dst_ptr = (dirstack_t *) zAVLSearch(zdirListTwo, tmpcat);1728 1729 if ( dst_ptr)1736 tmp_ptr = (dirstack_t *) zAVLSearch(zdirListTwo, tmpcat); 1737 1738 if (tmp_ptr) 1730 1739 { 1731 1740 TPT((0, FIL__, __LINE__, 1732 1741 _("msg=<%s -> recursion depth %d\n>"), 1733 dst_ptr->name, dst_ptr->rdepth));1734 rdepth_next = dst_ptr->rdepth;1735 class_next = dst_ptr->class;1742 tmp_ptr->name, tmp_ptr->rdepth)); 1743 rdepth_next = tmp_ptr->rdepth; 1744 class_next = tmp_ptr->class; 1736 1745 /* 28. Aug 2001 reversed 1737 1746 */ 1738 cchecked_flag = dst_ptr->childs_checked;1739 checked_flag = dst_ptr->checked;1747 cchecked_flag = tmp_ptr->childs_checked; 1748 checked_flag = tmp_ptr->checked; 1740 1749 } 1741 1750 } … … 1745 1754 sh_files_checkdir (class_next, rdepth_next, tmpcat, 1746 1755 dirlist->sh_d_name); 1747 dst_ptr->childs_checked = S_TRUE; 1756 tmp_ptr->childs_checked = S_TRUE; 1757 /* 1758 * 04. Feb 2006 avoid double checking 1759 */ 1760 tmp_ptr->checked = S_TRUE; 1748 1761 } 1749 1762 else if (checked_flag == -1) … … 1768 1781 1769 1782 dirlist = dirlist->next; 1783 1784 if (dst_ptr) 1785 dst_ptr->childs_checked = S_TRUE; 1770 1786 1771 1787 } while (dirlist != NULL); … … 1820 1836 */ 1821 1837 char fullpath[PATH_MAX]; 1822 char fileHash[ KEY_LEN + 1];1838 char fileHash[2*(KEY_LEN + 1)]; 1823 1839 int status; 1824 1840 file_type theFile; -
trunk/src/sh_forward.c
r12 r19 4995 4995 } 4996 4996 4997 if (sig_suspend_switch == 1) /* SIGUSR2 */4997 if (sig_suspend_switch > 0) /* SIGUSR2 */ 4998 4998 { 4999 4999 TPT((0, FIL__, __LINE__, _("msg=<Suspend switch.>\n"))); … … 5005 5005 sh_global_suspend_flag = 1; 5006 5006 } 5007 sig_suspend_switch = 0;5007 --sig_suspend_switch; 5008 5008 --sig_raised; --sig_urgent; 5009 5009 } … … 5171 5171 tcurrent = (unsigned long) time (NULL); 5172 5172 5173 /* check for time limit exceeded 5174 */ 5175 if ((tcurrent - tchkold) > (unsigned int) 3 ) 5176 { 5177 tchkold = tcurrent; 5178 client_time_check(/* all_clients */); 5179 } 5180 5181 /* seed / re-seed the PRNG if required 5182 */ 5183 (void) taus_seed(); 5184 5173 5185 /* select() timeout handling. 5174 5186 */ … … 5246 5258 } 5247 5259 } 5248 5249 /* check for time limit exceeded 5250 */ 5251 if ((tcurrent - tchkold) > (unsigned int) 3 ) 5252 { 5253 tchkold = tcurrent; 5254 client_time_check(/* all_clients */); 5255 } 5256 tcurrent = tcurrent; 5257 5258 /* seed / re-seed the PRNG if required 5259 */ 5260 (void) taus_seed(); 5261 5260 /* continue */ 5262 5261 } 5263 5262 /* notreached */ -
trunk/src/sh_hash.c
r18 r19 2485 2485 2486 2486 if ( (fileHash != NULL) && (p->theFile.checksum != NULL) && 2487 (strncmp (fileHash, p->theFile.checksum, 50) != 0) &&2487 (strncmp (fileHash, p->theFile.checksum, KEY_LEN) != 0) && 2488 2488 (theFile->check_mask & MODI_CHK) != 0) 2489 2489 { 2490 modi_mask |= MODI_CHK; 2491 change_code[0] = 'C'; 2492 TPT ((0, FIL__, __LINE__, _("mod=<checksum>"))); 2490 if ((theFile->check_mask & MODI_SGROW) == 0) 2491 { 2492 modi_mask |= MODI_CHK; 2493 change_code[0] = 'C'; 2494 TPT ((0, FIL__, __LINE__, _("mod=<checksum>"))); 2495 } 2496 else 2497 { 2498 if (0 != strncmp (&fileHash[KEY_LEN + 1], 2499 p->theFile.checksum, KEY_LEN)) 2500 { 2501 modi_mask |= MODI_CHK; 2502 change_code[0] = 'C'; 2503 TPT ((0, FIL__, __LINE__, _("mod=<checksum>"))); 2504 } 2505 else 2506 { 2507 p->theFile.size = theFile->size; 2508 sl_strlcpy(p->theFile.checksum, fileHash, KEY_LEN+1); 2509 } 2510 } 2493 2511 } 2494 2512 … … 2621 2639 (theFile->check_mask & MODI_SIZ) != 0) 2622 2640 { 2623 if (class == SH_LEVEL_LOGGROW && theFile->size < (off_t) p->theFile.size) 2641 if ((theFile->check_mask & MODI_SGROW) == 0 || 2642 theFile->size < (off_t) p->theFile.size) 2624 2643 { 2625 2644 modi_mask |= MODI_SIZ; 2626 2645 change_code[9] = 'S'; 2627 2646 TPT ((0, FIL__, __LINE__, _("mod=<size>"))); 2628 } 2629 else if (class != SH_LEVEL_LOGGROW) 2630 { 2631 modi_mask |= MODI_SIZ; 2632 change_code[9] = 'S'; 2633 TPT ((0, FIL__, __LINE__, _("mod=<size>"))); 2634 } 2647 } 2635 2648 } 2636 2649 change_code[10] = '\0'; -
trunk/src/sh_suidchk.c
r1 r19 417 417 418 418 file_type theFile; 419 char fileHash[ KEY_LEN + 1];419 char fileHash[2*(KEY_LEN + 1)]; 420 420 421 421 SL_ENTER(_("sh_suidchk_check_internal")); -
trunk/src/sh_tiger0.c
r18 r19 104 104 static 105 105 word64 * sh_tiger_hash_val (char * filename, TigerType what, 106 unsigned longLength, int timeout)106 UINT64 Length, int timeout) 107 107 #else 108 108 static 109 109 sh_word32 * sh_tiger_hash_val (char * filename, TigerType what, 110 unsigned longLength, int timeout)110 UINT64 Length, int timeout) 111 111 #endif 112 112 { … … 117 117 char * tmp; 118 118 sh_byte * bptr; 119 sh_byte bbuf[64]; 119 sh_byte bbuf[64]; 120 UINT64 bcount = 0; 120 121 121 122 static int lockflag = SL_FALSE; … … 178 179 179 180 #if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK) 180 if ( lockflag == SL_FALSE && skey->mlock_failed == SL_FALSE)181 if ((lockflag == SL_FALSE) && (skey->mlock_failed == SL_FALSE)) 181 182 { 182 if ( (-1) == sh_unix_mlock((char *)buffer,(PRIV_MAX)*sizeof(sh_byte))) 183 lockflag = SL_TRUE; 184 if ( (-1) == sh_unix_mlock(FIL__, __LINE__, 185 (char *)buffer, 186 (PRIV_MAX)*sizeof(sh_byte))) 183 187 skey->mlock_failed = SL_TRUE; 184 lockflag = SL_TRUE;185 188 } 186 189 #else 187 190 if (lockflag == SL_FALSE && skey->mlock_failed == SL_FALSE) 188 191 { 192 lockflag = SL_TRUE; 189 193 skey->mlock_failed = SL_TRUE; 190 lockflag = SL_TRUE;191 194 } 192 195 #endif … … 229 232 230 233 SL_RETURN( NULL, _("sh_tiger_hash_val")); 234 } 235 236 if (Length > 0) 237 { 238 bcount += count; 239 if (bcount > Length) 240 count = count - (bcount - Length); 241 count = (count < 0) ? 0 : count; 231 242 } 232 243 … … 382 393 if (what == TIGER_DATA && filename != NULL) 383 394 { 384 tiger(TIGER_CAST filename, 395 tiger(TIGER_CAST filename, (sh_word32) Length, res); 385 396 SL_RETURN(res, _("sh_tiger_hash_val")); 386 397 } … … 692 703 resulting message digest number will be written into the 16 bytes 693 704 beginning at RESBLOCK. */ 694 static int md5_stream(char * filename, void *resblock, int timeout) 705 static int md5_stream(char * filename, void *resblock, 706 UINT64 Length, int timeout) 695 707 { 696 708 /* Important: BLOCKSIZE must be a multiple of 64. */ … … 702 714 char * tmp; 703 715 uid_t euid; 716 UINT64 bcount = 0; 704 717 705 718 unsigned long pages_read; … … 762 775 } 763 776 777 if (Length > 0) 778 { 779 bcount += n; 780 if (bcount > Length) 781 n = n - (bcount - Length); 782 n = (n < 0) ? 0 : n; 783 } 784 764 785 sum += n; 765 786 } … … 807 828 static 808 829 char * sh_tiger_md5_hash (char * filename, TigerType what, 809 unsigned longLength, int timeout)810 { 811 int cnt = (int) Length;830 UINT64 Length, int timeout) 831 { 832 int cnt; 812 833 static char out[KEY_LEN+1]; 813 834 unsigned char md5buffer[16]; … … 822 843 } 823 844 824 (void) md5_stream (filename, md5buffer, timeout);845 (void) md5_stream (filename, md5buffer, Length, timeout); 825 846 826 847 /*@-bufferoverflowhigh -usedef@*/ … … 1202 1223 resulting message digest number will be written into the 16 bytes 1203 1224 beginning at RESBLOCK. */ 1204 static int sha1_stream(char * filename, void *resblock, int timeout) 1225 static int sha1_stream(char * filename, void *resblock, 1226 UINT64 Length, int timeout) 1205 1227 { 1206 1228 /* Important: BLOCKSIZE must be a multiple of 64. */ … … 1212 1234 char * tmp; 1213 1235 uid_t euid; 1236 UINT64 bcount = 0; 1214 1237 1215 1238 unsigned long pages_read; … … 1275 1298 } 1276 1299 1300 if (Length > 0) 1301 { 1302 bcount += n; 1303 if (bcount > Length) 1304 n = n - (bcount - Length); 1305 n = (n < 0) ? 0 : n; 1306 } 1307 1277 1308 sum += n; 1278 1309 } … … 1322 1353 1323 1354 static char * sh_tiger_sha1_hash (char * filename, TigerType what, 1324 unsigned longLength, int timeout)1355 UINT64 Length, int timeout) 1325 1356 { 1326 1357 int cnt = (int) Length; /* fix compiler warning */ … … 1337 1368 } 1338 1369 1339 (void) sha1_stream (filename, sha1buffer, timeout);1370 (void) sha1_stream (filename, sha1buffer, Length, timeout); 1340 1371 1341 1372 /*@-bufferoverflowhigh -usedef@*/ … … 1388 1419 1389 1420 static char * sh_tiger_hash_internal (char * filename, TigerType what, 1390 unsigned longLength, int timeout);1421 UINT64 Length, int timeout); 1391 1422 1392 1423 char * sh_tiger_hash (char * filename, TigerType what, 1393 unsigned longLength)1424 UINT64 Length) 1394 1425 { 1395 1426 return sh_tiger_hash_internal (filename, what, Length, 0); … … 1397 1428 1398 1429 char * sh_tiger_generic_hash (char * filename, TigerType what, 1399 unsigned longLength, int timeout)1430 UINT64 Length, int timeout) 1400 1431 { 1401 1432 #ifdef USE_SHA1 … … 1414 1445 1415 1446 static char * sh_tiger_hash_internal (char * filename, TigerType what, 1416 unsigned longLength, int timeout)1447 UINT64 Length, int timeout) 1417 1448 { 1418 1449 #if defined(TIGER_64_BIT) … … 1423 1454 static char out[KEY_LEN+1]; 1424 1455 1425 SL_ENTER( _("sh_tiger_hash "));1456 SL_ENTER( _("sh_tiger_hash_internal")); 1426 1457 1427 1458 res = sh_tiger_hash_val (filename, what, Length, timeout); … … 1451 1482 /*@+bufferoverflowhigh@*/ 1452 1483 out[KEY_LEN] = '\0'; 1453 SL_RETURN( out, _("sh_tiger_hash "));1484 SL_RETURN( out, _("sh_tiger_hash_internal")); 1454 1485 1455 1486 } 1456 1487 1457 1488 SL_RETURN( _("000000000000000000000000000000000000000000000000"), 1458 _("sh_tiger_hash "));1489 _("sh_tiger_hash_internal")); 1459 1490 } 1460 1491 1461 1492 char * sh_tiger_hash_gpg (char * filename, TigerType what, 1462 unsigned longLength)1493 UINT64 Length) 1463 1494 { 1464 1495 size_t len; … … 1530 1561 UINT32 * sh_tiger_hash_uint32 (char * filename, 1531 1562 TigerType what, 1532 unsigned longLength)1563 UINT64 Length) 1533 1564 { 1534 1565 #if defined(TIGER_64_BIT) -
trunk/src/sh_unix.c
r18 r19 573 573 if (mysignal == SIGUSR2) 574 574 { 575 sig_suspend_switch = 1;575 ++sig_suspend_switch; 576 576 ++sig_urgent; 577 577 } … … 1582 1582 if (skey->mlock_failed == SL_FALSE) 1583 1583 { 1584 if ( (-1) == sh_unix_mlock( (char *) skey, sizeof (sh_key_t)) ) 1584 if ( (-1) == sh_unix_mlock( FIL__, __LINE__, 1585 (char *) skey, sizeof (sh_key_t)) ) 1585 1586 { 1586 1587 skey->mlock_failed = SL_TRUE; … … 2754 2755 #include "sh_ignore.h" 2755 2756 2757 int sh_unix_checksum_size (char * filename, struct stat * fbuf, 2758 char * fileHash, int alert_timeout) 2759 { 2760 file_type tmpFile; 2761 int status; 2762 2763 SL_ENTER(_("sh_unix_checksum_size")); 2764 2765 /* lookup file in database */ 2766 status = sh_hash_get_it (filename, &tmpFile); 2767 if (status != 0) { 2768 goto out; 2769 } 2770 2771 /* if last < current get checksum */ 2772 if (tmpFile.size < fbuf->st_size) 2773 { 2774 strcpy(fileHash, /* known to fit */ 2775 sh_tiger_generic_hash (filename, TIGER_FD, tmpFile.size, 2776 alert_timeout)); 2777 2778 /* return */ 2779 SL_RETURN( 0, _("sh_unix_checksum_size")); 2780 } 2781 2782 out: 2783 strcpy(fileHash, /* known to fit */ 2784 _("000000000000000000000000000000000000000000000000")); 2785 SL_RETURN( -1, _("sh_unix_checksum_size")); 2786 } 2787 2756 2788 int sh_unix_getinfo (int level, char * filename, file_type * theFile, 2757 2789 char * fileHash, int policy) … … 2891 2923 _("000000000000000000000000000000000000000000000000")); 2892 2924 } 2893 else if ( policy == SH_LEVEL_PRELINK&&2925 else if ((theFile->check_mask & MODI_PREL) != 0 && 2894 2926 S_TRUE == sh_prelink_iself(rval_open, fbuf.st_size, 2895 2927 alert_timeout)) … … 2906 2938 sh_tiger_generic_hash (theFile->fullpath, TIGER_FD, 0, 2907 2939 alert_timeout)); 2940 if ((theFile->check_mask & MODI_SGROW) != 0) 2941 { 2942 sl_rewind(rval_open); 2943 tiger_fd = rval_open; 2944 sh_unix_checksum_size (theFile->fullpath, &fbuf, 2945 &fileHash[KEY_LEN + 1], 2946 alert_timeout); 2947 } 2908 2948 } 2909 2949 } … … 2939 2979 alert_timeout), 2940 2980 KEY_LEN + 1); 2981 if ((theFile->check_mask & MODI_SGROW) != 0) 2982 { 2983 sl_rewind(rval_open); 2984 tiger_fd = rval_open; 2985 sh_unix_checksum_size (theFile->fullpath, &fbuf, 2986 &fileHash[KEY_LEN + 1], 2987 alert_timeout); 2988 } 2941 2989 } 2942 2990 } … … 3648 3696 unsigned long page_start; 3649 3697 int page_refcount; 3698 char file[64]; 3699 int line; 3650 3700 struct sh_page_lt * next; 3651 3701 } sh_page_l; … … 3691 3741 3692 3742 #if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK) 3693 int sh_unix_mlock ( void * in_addr, size_t len)3743 int sh_unix_mlock (char * file, int line, void * in_addr, size_t len) 3694 3744 { 3695 3745 int num_pages; … … 3755 3805 page_list->page_start = addr; 3756 3806 page_list->page_refcount = 1; 3807 sl_strlcpy(page_list->file, file, 64); 3808 page_list->line = line; 3757 3809 status = mlock( (void *) addr, pagesize); 3758 3810 if (status != 0) … … 3929 3981 while (page_list != NULL) 3930 3982 { 3983 #ifdef WITH_TPT 3984 sl_snprintf(str, 128, _("file: %s line: %d page: %d"), 3985 page_list->file, page_list->line, i+1); 3986 sh_error_handle(SH_ERR_INFO, FIL__, __LINE__, i, MSG_E_SUBGEN, 3987 str, _("sh_unix_count_mlock")); 3988 #endif 3931 3989 page_list = page_list->next; 3932 3990 ++i; 3933 3991 } 3934 s printf(str, _("%d pages locked"), i); /* known to fit */3992 sl_snprintf(str, 128, _("%d pages locked"), i); 3935 3993 sh_error_handle(SH_ERR_INFO, FIL__, __LINE__, i, MSG_E_SUBGEN, 3936 3994 str, _("sh_unix_count_mlock")); -
trunk/test/test.sh
r1 r19 1 1 #! /bin/sh 2 2 3 isok=`test -t 1 2>&1 | wc -c` 4 if [ "$isok" -eq 0 ]; then 5 test -t 1 6 isok=$? 7 fi 3 8 4 9 # 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 10 if [ x"$isok" = x0 ]; then 11 case $TERM in 12 vt*|ansi*|con*|xterm*|linux*|screen*|rxvt*) 13 S='[1;30m' 14 R=[31m 15 G=[32m 16 B=[36m 17 E=[m 18 ;; 19 *) 20 S= 21 R= 22 G= 23 B= 24 E= 25 ;; 26 esac 27 fi 28 29 30 usage() { 31 echo "test.sh [options] <test_number> [hostname]" 32 echo " [-q|--quiet|-v|--verbose] [-s|--stoponerr] [--no-cleanup]" 33 echo " [--srcdir=top_srcdir] [--color=always|never|auto]" 34 echo 35 echo " ${S}test.sh 1${E} -- Compile with many different options" 36 echo " ${S}test.sh 2${E} -- Hash function (testrc_1)" 37 echo " ${S}test.sh 3${E} -- Standalone init/check" 38 echo " ${S}test.sh 4${E} -- Microstealth init/check" 39 echo " ${S}test.sh 5${E} -- External program call (testrc_1ext.in)" 40 echo " ${S}test.sh 6${E} -- Controlling the daemon" 41 echo " ${S}test.sh 7${E} -- GnuPG signed files / prelude log" 42 43 echo " ${S}test.sh 10${E} -- Test c/s init/check (testrc_2.in)" 44 echo " ${S}test.sh 11${E} -- Test full c/s init/check (testrc_2.in)" 45 echo " ${S}test.sh 12${E} -- Test full c/s w/gpg (testrc_2.in)" 46 echo " ${S}test.sh 13${E} -- Test full c/s w/mysql (testrc_2.in)" 47 echo " ${S}test.sh 14${E} -- Test full c/s w/postgres (testrc_2.in)" 48 echo " ${S}test.sh all${E} -- All except 12+" 49 50 echo 51 echo "Scripts used by tests (located in ${SCRIPTDIR}):" 52 echo " (1) testcompile.sh (2) testhash.sh (3) testrun_1.sh (4) testrun_1a.sh" 53 echo " (5) testext.sh (6) testtimesrv.sh (7) testrun_1b.sh (10) testrun_2.sh" 54 echo " (11) testrun_2a.sh (12) testrun_2b.sh (13) testrun_2c.sh (14) testrun_2d.sh" 55 } 56 57 # 58 # Option parsing 59 # 60 verbose= 61 quiet= 62 stoponerr= 63 color=auto 64 cleanup=on 65 doall= 66 67 while [ $# -gt 0 ] 68 do 69 case "$1" in 70 -h|--help) usage; exit 0;; 71 -v|--verbose) verbose=on; quiet= ;; 72 -q|--quiet) quiet=on; verbose= ;; 73 -s|--stoponerr) stoponerr=on;; 74 --no-cleanup) cleanup= ;; 75 --really-all) doall=on;; 76 --srcdir=*) TOP_SRCDIR=`echo $1 | sed s,--srcdir=,,`; export TOP_SRCDIR;; 77 --color=*) 78 arg=`echo $1 | sed s,--color=,,` 79 case $arg in 80 auto) ;; 81 never|none|no) 82 S= 83 R= 84 G= 85 B= 86 E= 87 ;; 88 always|yes) 89 S='[1;30m' 90 R=[31m 91 G=[32m 92 G=[36m 93 E=[m 94 ;; 95 *) echo "Invalid argument $1"; exit 1;; 96 esac 97 ;; 98 -*) echo "Invalid argument $1"; exit 1;; 99 *) break;; 100 esac 101 shift 102 done 103 104 export verbose 105 export quiet 106 export stoponerr 107 export cleanup 108 export doall 109 export S; export R; export G; export B; export E; 15 110 16 111 SCRIPTDIR=. 17 112 113 # 114 # 'make test' will copy the 'test' subdirectory and replace TEST_SRCDIR 115 # 18 116 TEST_SRCDIR="XXXSRCXXX"; 19 117 if test "x${TOP_SRCDIR}" = x; then … … 41 139 export TOP_SRCDIR 42 140 else 43 echo "Please set the environment variable TOP_SRCDIR tothe"141 echo "Please use --srcdir=DIR, where DIR should be the" 44 142 echo "top directory in the samhain source tree." 45 143 exit 1 … … 47 145 fi 48 146 else 49 # called by make 50 if test -f "${TOP_SRCDIR}/src/samhain.c"; then 51 SCRIPTDIR=test 52 else 53 if test -f "../${TOP_SRCDIR}/src/samhain.c"; then 54 cd ..; SCRIPTDIR=test 147 # called by make, or with --srcdir=TOP_SRCDIR 148 if test -f "${TOP_SRCDIR}/src/samhain.c"; then 149 SCRIPTDIR="${TOP_SRCDIR}/test" 150 elif test -f "../${TOP_SRCDIR}/src/samhain.c"; then 151 cd ..; SCRIPTDIR="${TOP_SRCDIR}/test" 152 else 153 echo "Please use --srcdir=DIR, where DIR should be the" 154 echo "top directory in the samhain source tree." 155 exit 1 156 fi 157 fi 158 159 export SCRIPTDIR 160 161 PW_DIR=`pwd`; export PW_DIR 162 # 163 # 164 # 165 if test x$UID != x; then 166 TRUST="--with-trusted=0,2,$UID" 167 else 168 TRUST="--with-trusted=0,2,500" 169 fi 170 export TRUST 171 # 172 # find a good 'make' 173 # 174 MAKE=`which gmake` 175 if test "x$?" = x1 ; then 176 MAKE="make -s" 177 else 178 MAKE=`which gmake | sed -e "s%\([a-z:]\) .*%\1%g"` 179 if test "x$MAKE" = x; then 180 MAKE="make -s" 181 elif test "x$MAKE" = xno; then 182 MAKE="make -s" 183 else 184 if test "x$MAKE" = "xwhich:"; then 185 MAKE="make -s" 55 186 else 56 echo "Please set the environment variable TOP_SRCDIR to the" 57 echo "top directory in the samhain source tree." 58 exit 1 187 MAKE="gmake -s" 188 gmake -v >/dev/null 2>&1 || MAKE="make -s" 59 189 fi 60 190 fi 61 191 fi 62 63 export SCRIPTDIR 64 65 PW_DIR=`pwd`; export PW_DIR 192 export MAKE 193 194 failcount=0 195 okcount=0 196 skipcount=0 197 global_count=0 198 last_count=0 199 200 # args: #test, #total, status, optional msg 201 log_msg () 202 { 203 if [ x"$COLUMNS" != x ]; then 204 TERMWIDTH=$COLUMNS 205 elif [ x"$COLS" != x ]; then 206 TERMWIDTH=$COLS 207 else 208 TERMWIDTH=80 209 fi 210 cols=66; 211 # 212 if [ $1 -eq 0 ]; then 213 msg=" ${4}" 214 else 215 if [ ${1} -eq 1 ]; then 216 global_count=${last_count} 217 fi 218 let "v = $1 + global_count" >/dev/null 219 last_count=${v} 220 dd=''; if [ $v -lt 10 ]; then dd=" "; fi 221 dt=''; if [ $2 -lt 10 ]; then dt=" "; fi 222 if [ -z "$4" ]; then 223 msg=" test ${dd}${v}/${dt}${2}" 224 else 225 msg=" test ${dd}${v}/${dt}${2} ${4}" 226 fi 227 fi 228 # 229 if [ x"$3" = xfailure ]; then 230 ccode=$R 231 elif [ x"$3" = xsuccess ]; then 232 ccode=$G 233 else 234 ccode=$B 235 fi 236 if [ -z "${R}" ]; then 237 echo " [${3}] ${msg}" 238 else 239 # len=${#...} is not bourne shell 240 # also, need to account for terminal control sequences 241 len=`echo "$msg" | awk '/1;30m/ { print length()-10; }; !/1;30m/ { print length();}'` 242 let "cols = cols - len" >/dev/null 243 moveto='['$cols'C' 244 echo "${msg}${moveto}${ccode}[${3}]${E}" 245 fi 246 } 247 248 log_fail () { 249 log_msg "$1" "$2" failure "$3"; 250 let "failcount = failcount + 1" >/dev/null; 251 test -z "$stoponerr" || exit 1; 252 } 253 log_ok () { 254 log_msg "$1" "$2" success "$3"; 255 let "okcount = okcount + 1" >/dev/null; 256 } 257 log_skip () { 258 log_msg "$1" "$2" skipped "$3"; 259 let "skipcount = skipcount + 1" >/dev/null; 260 } 261 262 log_msg_fail () { log_msg 0 0 failure "$1"; } 263 log_msg_ok () { log_msg 0 0 success "$1"; } 264 log_msg_skip () { log_msg 0 0 skipped "$1"; } 265 266 log_start () { 267 if [ -z "$quiet" ]; then 268 echo; 269 echo "${S}__ START TEST ${1} __${E}"; 270 echo; 271 fi 272 } 273 log_end () { 274 if [ -n "$verbose" ]; then 275 echo; 276 echo "${S}__ END TEST ${1} __${E}"; 277 echo; 278 fi 279 } 280 281 do_cleanup () { 282 rm -f testrc_1.dyn 283 rm -f testrc_2 284 rm -f ./.samhain_file 285 rm -f ./.samhain_log* 286 rm -f ./.samhain_lock 287 test -d testrun_data && chmod -R 0700 testrun_data 288 rm -rf testrun_data 289 rm -f test_log_db 290 rm -f test_log_prelude 291 } 292 293 print_summary () 294 { 295 let "gcount = okcount + skipcount + failcount" >/dev/null; 296 [ -z "$quiet" ] && { 297 echo 298 echo "__ ${S}Tests: ${gcount} Ok: ${okcount} Skipped: ${skipcount} Failed: ${failcount}${E}" 299 } 300 if [ $failcount -eq 0 ]; then 301 [ -z "$quiet" ] && { echo "__ ${G}All tests passed successfully.${E}"; echo; } 302 elif [ $failcount -eq 1 ]; then 303 [ -z "$quiet" ] && { echo "__ ${R}There was 1 failure.${E}"; echo; } 304 else 305 [ -z "$quiet" ] && { echo "__ ${R}There were $failcount failures.${E}"; echo; } 306 fi 307 [ -z "$cleanup" ] || do_cleanup; 308 } 309 310 find_path () { ( 311 save_IFS=$IFS; IFS=: 312 313 for dir in $PATH; do 314 IFS=$as_save_IFS 315 test -z "$dir" && dir=. 316 if test -f "$dir/$1"; then 317 echo "$dir/$1"; 318 break; 319 fi 320 done 321 IFS=${save_IFS}; 322 ); } 323 324 find_hostname () { 325 tmp=`hostname -f 2>/dev/null` 326 if [ $? -ne 0 ]; then 327 tmp=`hostname 2>/dev/null` 328 fi 329 if [ -z "$tmp" ]; then 330 tmp="localhost" 331 fi 332 echo "$tmp" 333 } 334 335 rm -f ./test_log 336 337 # first one is hostname, others are aliases 338 # 339 hostname=`cat /etc/hosts | egrep "^ *127.0.0.1" | awk '{ print $2 }'` 340 if [ x"$hostname" = xlocalhost ]; then 341 hostname="127.0.0.1" 342 fi 66 343 67 344 if test x$1 = x1; then 68 exec ${SCRIPTDIR}/testcompile.sh 345 . ${SCRIPTDIR}/testcompile.sh 346 testcompile 347 print_summary 348 exit $? 69 349 fi 70 350 if test x$1 = x2; then 71 exec ${SCRIPTDIR}/testhash.sh 351 . ${SCRIPTDIR}/testhash.sh 352 testhash 353 print_summary 354 exit $? 72 355 fi 73 356 if test x$1 = x3; then 74 exec ${SCRIPTDIR}/testrun_1.sh 357 . ${SCRIPTDIR}/testrun_1.sh 358 testrun1 359 print_summary 360 exit $? 75 361 fi 76 362 if test x$1 = x4; then 77 exec ${SCRIPTDIR}/testrun_1a.sh 363 . ${SCRIPTDIR}/testrun_1.sh 364 . ${SCRIPTDIR}/testrun_1a.sh 365 testrun1a 366 print_summary 367 exit $? 78 368 fi 79 369 if test x$1 = x5; then 80 exec ${SCRIPTDIR}/testext.sh 370 . ${SCRIPTDIR}/testext.sh 371 testext0 372 print_summary 373 exit $? 81 374 fi 82 375 if test x$1 = x6; then 83 exec ${SCRIPTDIR}/testtimesrv.sh 376 . ${SCRIPTDIR}/testtimesrv.sh 377 testtime0 378 print_summary 379 exit $? 84 380 fi 85 381 if test x$1 = x7; then 86 exec ${SCRIPTDIR}/testrun_1b.sh 382 . ${SCRIPTDIR}/testrun_1b.sh 383 testrun1b 384 print_summary 385 exit $? 87 386 fi 88 387 if test x$1 = x10; then 89 exec ${SCRIPTDIR}/testrun_2.sh $2 388 . ${SCRIPTDIR}/testrun_2.sh 389 testrun2 $hostname 390 print_summary 391 exit $? 90 392 fi 91 393 if test x$1 = x11; then 92 exec ${SCRIPTDIR}/testrun_2a.sh $2 394 . ${SCRIPTDIR}/testrun_2a.sh 395 testrun2a $hostname 396 print_summary 397 exit $? 93 398 fi 94 399 if test x$1 = x12; then 95 exec ${SCRIPTDIR}/testrun_2b.sh $2 400 . ${SCRIPTDIR}/testrun_2a.sh 401 . ${SCRIPTDIR}/testrun_2b.sh 402 testrun2b $hostname 403 print_summary 404 exit $? 96 405 fi 97 406 if test x$1 = x13; then 98 exec ${SCRIPTDIR}/testrun_2c.sh $2 407 . ${SCRIPTDIR}/testrun_2a.sh 408 . ${SCRIPTDIR}/testrun_2c.sh 409 testrun2c $hostname 410 print_summary 411 exit $? 99 412 fi 100 413 if test x$1 = x14; then 101 exec ${SCRIPTDIR}/testrun_2d.sh $2 414 . ${SCRIPTDIR}/testrun_2a.sh 415 . ${SCRIPTDIR}/testrun_2d.sh 416 testrun2d $hostname 417 print_summary 418 exit $? 102 419 fi 103 420 if test x$1 = xall; then 104 ${SCRIPTDIR}/testcompile.sh 105 ${SCRIPTDIR}/testhash.sh 106 ${SCRIPTDIR}/testrun_1.sh 107 ${SCRIPTDIR}/testrun_1a.sh 108 ${SCRIPTDIR}/testext.sh 109 ${SCRIPTDIR}/testtimesrv.sh 110 ${SCRIPTDIR}/testrun_1b.sh 111 ${SCRIPTDIR}/testrun_2.sh $2 112 ${SCRIPTDIR}/testrun_2a.sh $2 113 fi 114 115 echo "Usage (in brackets: config files used):" 116 echo 117 echo " ${S}test.sh 1${E} -- Compilation with many different options" 118 echo " ${S}test.sh 2${E} -- Hash function" 119 echo " ${S}test.sh 3${E} -- Standalone init/check (testrc_1)" 120 echo " ${S}test.sh 4${E} -- Microstealth init/check (testrc_1)" 121 echo " ${S}test.sh 5${E} -- External program call (testrc_1ext.in)" 122 echo " ${S}test.sh 6${E} -- Timeserver option (testrc_1)" 123 echo " ${S}test.sh 7${E} -- GnuPG signed files (testrc_1)" 124 # 125 # 126 # 127 echo " ${S}test.sh 10 hostname${E} -- Test c/s init/check (testrc_2.in)" 128 echo " ${S}test.sh 11 hostname${E} -- Test full c/s init/check (testrc_2.in)" 129 echo " ${S}test.sh 12 hostname${E} -- Test full c/s w/gpg (testrc_2.in)" 130 echo " ${S}test.sh 13 hostname${E} -- Test full c/s w/mysql (testrc_2.in)" 131 echo " ${S}test.sh 14 hostname${E} -- Test c/s w/syslog logging(testrc_2.in)" 132 echo " ${S}test.sh a hostname${E} -- All except 7,12+" 133 134 echo 135 echo "Scripts used: (1) ./testcompile.sh (2) ./testhash.sh (3) ./testrun_1.sh" 136 echo " (4) ./testrun_1a.sh (5) ./testext.sh (6) ./testtimesrv.sh" 137 echo " (7) ./testrun_1b.sh (10) ./testrun_2.sh (11) ./testrun_2a.sh" 138 echo " (12) ./testrun_2b.sh (13) ./testrun_2c.sh (14) ./testrun_2d.sh" 139 421 TEST_MAX=0 422 . ${SCRIPTDIR}/testcompile.sh 423 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 424 . ${SCRIPTDIR}/testhash.sh 425 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 426 . ${SCRIPTDIR}/testrun_1.sh 427 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 428 . ${SCRIPTDIR}/testrun_1a.sh 429 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 430 . ${SCRIPTDIR}/testext.sh 431 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 432 . ${SCRIPTDIR}/testtimesrv.sh 433 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 434 . ${SCRIPTDIR}/testrun_1b.sh 435 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 436 . ${SCRIPTDIR}/testrun_2.sh 437 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 438 . ${SCRIPTDIR}/testrun_2a.sh 439 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 440 . ${SCRIPTDIR}/testrun_2b.sh 441 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 442 . ${SCRIPTDIR}/testrun_2c.sh 443 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 444 . ${SCRIPTDIR}/testrun_2d.sh 445 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 446 # 447 # ${SCRIPTDIR}/testtimesrv.sh 448 # ${SCRIPTDIR}/testrun_1b.sh 449 # ${SCRIPTDIR}/testrun_2.sh $2 450 # ${SCRIPTDIR}/testrun_2a.sh $2 451 # 452 MAXTEST=${TEST_MAX}; export MAXTEST 453 testcompile 454 testhash 455 # 456 . ${SCRIPTDIR}/testrun_1.sh 457 MAXTEST=${TEST_MAX}; export MAXTEST 458 testrun1 459 # 460 . ${SCRIPTDIR}/testrun_1a.sh 461 MAXTEST=${TEST_MAX}; export MAXTEST 462 testrun1a 463 # 464 testext0 465 # 466 . ${SCRIPTDIR}/testtimesrv.sh 467 MAXTEST=${TEST_MAX}; export MAXTEST 468 testtime0 469 # 470 . ${SCRIPTDIR}/testrun_1b.sh 471 MAXTEST=${TEST_MAX}; export MAXTEST 472 testrun1b 473 # 474 . ${SCRIPTDIR}/testrun_2.sh 475 MAXTEST=${TEST_MAX}; export MAXTEST 476 testrun2 $hostname 477 # 478 . ${SCRIPTDIR}/testrun_2a.sh 479 MAXTEST=${TEST_MAX}; export MAXTEST 480 testrun2a $hostname 481 # 482 . ${SCRIPTDIR}/testrun_2b.sh 483 MAXTEST=${TEST_MAX}; export MAXTEST 484 testrun2b $hostname 485 # 486 . ${SCRIPTDIR}/testrun_2c.sh 487 MAXTEST=${TEST_MAX}; export MAXTEST 488 testrun2c $hostname 489 # 490 . ${SCRIPTDIR}/testrun_2d.sh 491 MAXTEST=${TEST_MAX}; export MAXTEST 492 testrun2d $hostname 493 # 494 print_summary 495 exit 0 496 fi 497 498 usage; 499 500 exit 1; 501 502 __ARCHIVE_FOLLOWS__ 503 -tæCíMoÓ0Ç#@HøÄ 504 »Å 4Ñ&m×I9€MõeëËÆ6U(MÝÖ[bwv²®ù|ïÀW$Ä°ç§ÝºŠMHlÈ?µµý÷ËóØqþõ÷ëû1;Ê¥ 505 Ò©TXjyuÒÖŠíiUM*Ìh©LBMiPéÕËI'JÀ}Aš0ÄÎ?g£ÍÌÊG!ÙŒUªÂek6JV5oÂJŸÑ0¬ü€m>X¢¡*õMÑÊsÇ 506 ¢î"\§$u¡Ee 507 úî"{cè0 508 âÜî#ÀŠáû 509 wñ6èaéqä;BÏï"â7P8Ë·Áq%[Õ 510 QHZTª#»[#î8ªi¿ "ðšj1:€/:é(õ ešJ ê'5Þp]}d32§! õ±f¢×1éÑRµÅ¡LgMLTlì 511 ÷ù!Ïi1wOiAË 512 513 Ü4ج`îŽi#1LDõÃŒr¶ØCºPC±qLIY,àêÚD,S: 514 J« ù 515 ÀuMä¡År¹p 516 517 xMáúdÑð Ö 518 mpÆ-2úÑZE`G·dW%bóðUmÅË{Àæ])óde`íšÞØxüŽÕ 519 ìK¹lòùú\¶³j®»:îÌuÞ=7°aäz+k[]gñ|Ü#<ëÄë 520 ³X±¶ë{ZE:ÞÊe§ æ«æYé]÷+xÄží 521 õ= 522 ßÊKú 523 žÈÿjêØÿµt* 524 úFÓ€ÿ_Wãÿï?Ÿ}÷|1Š1ïÜæï»âçåIûÅí\XÞW£åiöO¡þ{ÊáÁÁ·ß÷wŠúöËá÷¯ûáGyý(?ÞŒúüíø|c_ìå/xÍøÀi ßØsÉra×Îhc'Ckt©±# 525 Œ9ÂMàá%Ô£úd®3l-ÑÂvŒ±¶±. 526 <7êÍKH$D"H$D"H$D"H$ 527 ø ?:v( -
trunk/test/testcompile.sh
r1 r19 1 1 #! /bin/sh 2 2 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 15 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 COMPILE __${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 46 #echo MAKE is $MAKE 47 #echo 3 MAXTEST=28; export MAXTEST 48 4 49 5 testmake () 50 6 { 51 7 fail=0 52 8 if test x$1 = x0; then 53 echo "PASS: configure ${TEST}";54 $MAKE > /dev/null 2>> test_log9 [ -z "$verbose" ] || log_msg_ok "configure... $TEST"; 10 $MAKE cutest > /dev/null 2>> test_log 55 11 if test x$? = x0; then 56 echo "PASS: $MAKE ${TEST}";12 [ -z "$verbose" ] || log_msg_ok "make cutest... $TEST"; 57 13 else 58 echo "FAIL: $MAKE ${TEST} (see ./test_log)"; 14 [ -z "$quiet" ] && log_msg_fail "make cutest... $TEST"; 15 fail=1 59 16 fi 60 17 else 61 echo "FAIL: configure ${TEST} (see ./test_log)"; 62 fi 18 [ -z "$quiet" ] && log_msg_fail "configure... $TEST"; 19 if [ x"$3" = xskip ]; then 20 [ -z "$quiet" ] && log_skip $2 ${MAXTEST} "$TEST"; 21 fi 22 fail=1 23 fi 24 if [ $fail -eq 1 ]; then 25 [ -z "$quiet" ] && log_fail $2 ${MAXTEST} "$TEST"; 26 return 1 27 fi 28 [ -z "$quiet" ] && log_ok $2 ${MAXTEST} "$TEST"; 29 return 0 63 30 } 64 31 65 32 testcompile () 66 33 { 67 rm -f ./test_log 34 log_start "COMPILE" 35 36 num=0 37 numfail=0 68 38 69 39 # … … 78 48 ${TOP_SRCDIR}/configure --quiet --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test --enable-suidcheck > /dev/null 2>> test_log 79 49 # 80 testmake $? 50 let "num = num + 1" >/dev/null 51 testmake $? $num || let "numfail = numfail + 1" >/dev/null 81 52 82 53 # … … 91 62 ${TOP_SRCDIR}/configure --quiet --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test --enable-mounts-check --enable-userfiles > /dev/null 2>> test_log 92 63 # 93 testmake $? 64 let "num = num + 1" >/dev/null 65 testmake $? $num || let "numfail = numfail + 1" >/dev/null 94 66 95 67 … … 105 77 ${TOP_SRCDIR}/configure --quiet --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test --enable-message-queue --with-timeserver=127.0.0.1 > /dev/null 2>> test_log 106 78 # 107 testmake $? 79 let "num = num + 1" >/dev/null 80 testmake $? $num || let "numfail = numfail + 1" >/dev/null 108 81 109 82 # … … 118 91 ${TOP_SRCDIR}/configure --quiet --prefix=$PW_DIR --enable-nocl="owl" --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 119 92 # 120 testmake $? 93 let "num = num + 1" >/dev/null 94 testmake $? $num || let "numfail = numfail + 1" >/dev/null 121 95 122 96 # … … 131 105 ${TOP_SRCDIR}/configure --quiet --enable-debug --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 132 106 # 133 testmake $? 107 let "num = num + 1" >/dev/null 108 testmake $? $num || let "numfail = numfail + 1" >/dev/null 134 109 135 110 # … … 138 113 TEST="${S}standalone agent w/gpg${E}" 139 114 # 140 if test -r "Makefile"; then 141 $MAKE clean 142 fi 143 # 144 ${TOP_SRCDIR}/configure --quiet --with-gpg=/usr/bin/gpg --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 145 # 146 testmake $? 115 GPG=`find_path gpg` 116 let "num = num + 1" >/dev/null 117 # 118 if [ -z "$GPG" ]; then 119 log_skip $num $MAXTEST 'gpg not in PATH' 120 else 121 if test -r "Makefile"; then 122 $MAKE clean 123 fi 124 # 125 ${TOP_SRCDIR}/configure --quiet --with-gpg=$GPG --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 126 # 127 testmake $? $num || let "numfail = numfail + 1" >/dev/null 128 fi 147 129 148 130 # … … 157 139 ${TOP_SRCDIR}/configure --quiet --enable-stealth=128 --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 158 140 # 159 testmake $? 141 let "num = num + 1" >/dev/null 142 testmake $? $num || let "numfail = numfail + 1" >/dev/null 160 143 161 144 # … … 170 153 ${TOP_SRCDIR}/configure --quiet --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 171 154 # 172 testmake $? 155 let "num = num + 1" >/dev/null 156 testmake $? $num || let "numfail = numfail + 1" >/dev/null 157 158 # 159 # test standalone compilation w/mysql 160 # 161 TEST="${S}standalone agent w/mysql${E}" 162 # 163 if test -r "Makefile"; then 164 $MAKE clean 165 fi 166 # 167 ${TOP_SRCDIR}/configure --quiet --enable-xml-log --with-database=mysql --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 168 # 169 let "num = num + 1" >/dev/null 170 testmake $? $num "skip" || let "numfail = numfail + 1" >/dev/null 171 172 # 173 # test standalone compilation w/postgresql 174 # 175 TEST="${S}standalone agent w/postgresql${E}" 176 # 177 if test -r "Makefile"; then 178 $MAKE clean 179 fi 180 # 181 ${TOP_SRCDIR}/configure --quiet --enable-xml-log --with-database=postgresql --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 182 # 183 let "num = num + 1" >/dev/null 184 testmake $? $num "skip" || let "numfail = numfail + 1" >/dev/null 173 185 174 186 # … … 183 195 ${TOP_SRCDIR}/configure --quiet --disable-mail --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 184 196 # 185 testmake $? 197 let "num = num + 1" >/dev/null 198 testmake $? $num || let "numfail = numfail + 1" >/dev/null 186 199 187 200 # … … 196 209 ${TOP_SRCDIR}/configure --quiet --disable-external-scripts --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 197 210 # 198 testmake $? 211 let "num = num + 1" >/dev/null 212 testmake $? $num || let "numfail = numfail + 1" >/dev/null 199 213 200 214 # echo; echo "${S}__ TEST CLIENT/SERVER __${E}"; echo; … … 211 225 ${TOP_SRCDIR}/configure --quiet --enable-network=client --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test --with-timeserver=127.0.0.1 > /dev/null 2>> test_log 212 226 # 213 testmake $? 214 # 227 let "num = num + 1" >/dev/null 228 testmake $? $num || let "numfail = numfail + 1" >/dev/null 229 215 230 if test -r "Makefile"; then 216 231 $MAKE clean … … 219 234 ${TOP_SRCDIR}/configure --quiet --enable-network=server --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test --with-timeserver=127.0.0.1 > /dev/null 2>> test_log 220 235 # 221 testmake $? 236 let "num = num + 1" >/dev/null 237 testmake $? $num || let "numfail = numfail + 1" >/dev/null 222 238 223 239 # … … 226 242 TEST="${S}client/server application w/gpg${E}" 227 243 # 228 if test -r "Makefile"; then 229 $MAKE clean 230 fi 231 # 232 ${TOP_SRCDIR}/configure --quiet --enable-network=server --enable-srp --with-gpg=/usr/bin/gpg --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 233 # 234 testmake $? 235 # 236 if test -r "Makefile"; then 237 $MAKE clean 238 fi 239 # 240 ${TOP_SRCDIR}/configure --quiet --enable-network=client --enable-srp --with-gpg=/usr/bin/gpg --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 241 # 242 testmake $? 244 GPG=`find_path gpg` 245 let "num = num + 1" >/dev/null 246 # 247 if [ -z "$GPG" ]; then 248 log_skip $num $MAXTEST 'gpg not in PATH' 249 let "num = num + 1" >/dev/null 250 log_skip $num $MAXTEST 'gpg not in PATH' 251 else 252 if test -r "Makefile"; then 253 $MAKE clean 254 fi 255 # 256 ${TOP_SRCDIR}/configure --quiet --enable-network=server --enable-srp --with-gpg=$GPG --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 257 # 258 testmake $? $num || let "numfail = numfail + 1" >/dev/null 259 # 260 if test -r "Makefile"; then 261 $MAKE clean 262 fi 263 # 264 ${TOP_SRCDIR}/configure --quiet --enable-network=client --enable-srp --with-gpg=$GPG --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 265 # 266 let "num = num + 1" >/dev/null 267 testmake $? $num || let "numfail = numfail + 1" >/dev/null 268 fi 243 269 244 270 … … 254 280 ${TOP_SRCDIR}/configure --quiet --enable-network=server --disable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 255 281 # 256 testmake $? 282 let "num = num + 1" >/dev/null 283 testmake $? $num || let "numfail = numfail + 1" >/dev/null 257 284 # 258 285 if test -r "Makefile"; then … … 262 289 ${TOP_SRCDIR}/configure --quiet --enable-network=client --disable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 263 290 # 264 testmake $? 291 let "num = num + 1" >/dev/null 292 testmake $? $num || let "numfail = numfail + 1" >/dev/null 265 293 266 294 # … … 275 303 ${TOP_SRCDIR}/configure --quiet --enable-network=server --enable-debug --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 276 304 # 277 testmake $? 305 let "num = num + 1" >/dev/null 306 testmake $? $num || let "numfail = numfail + 1" >/dev/null 278 307 # 279 308 if test -r "Makefile"; then … … 283 312 ${TOP_SRCDIR}/configure --quiet --enable-network=client --enable-debug --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 284 313 # 285 testmake $? 314 let "num = num + 1" >/dev/null 315 testmake $? $num || let "numfail = numfail + 1" >/dev/null 286 316 287 317 # … … 296 326 ${TOP_SRCDIR}/configure --quiet --enable-network=server --enable-srp --enable-stealth=128 --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 297 327 # 298 testmake $? 328 let "num = num + 1" >/dev/null 329 testmake $? $num || let "numfail = numfail + 1" >/dev/null 299 330 # 300 331 if test -r "Makefile"; then … … 304 335 ${TOP_SRCDIR}/configure --quiet --enable-network=client --enable-srp --enable-stealth=128 --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 305 336 # 306 testmake $? 337 let "num = num + 1" >/dev/null 338 testmake $? $num || let "numfail = numfail + 1" >/dev/null 307 339 308 340 # … … 317 349 ${TOP_SRCDIR}/configure --quiet --enable-network=server --enable-srp --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 318 350 # 319 testmake $? 351 let "num = num + 1" >/dev/null 352 testmake $? $num || let "numfail = numfail + 1" >/dev/null 320 353 # 321 354 if test -r "Makefile"; then … … 325 358 ${TOP_SRCDIR}/configure --quiet --enable-network=client --enable-srp --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 326 359 # 327 testmake $? 360 let "num = num + 1" >/dev/null 361 testmake $? $num || let "numfail = numfail + 1" >/dev/null 328 362 329 363 # … … 338 372 ${TOP_SRCDIR}/configure --quiet --enable-network=server --disable-mail --enable-srp --enable-stealth=128 --enable-debug --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 339 373 # 340 testmake $? 374 let "num = num + 1" >/dev/null 375 testmake $? $num || let "numfail = numfail + 1" >/dev/null 341 376 # 342 377 if test -r "Makefile"; then … … 346 381 ${TOP_SRCDIR}/configure --quiet --enable-network=client --disable-mail --enable-srp --enable-stealth=128 --enable-debug --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 347 382 # 348 testmake $? 383 let "num = num + 1" >/dev/null 384 testmake $? $num || let "numfail = numfail + 1" >/dev/null 349 385 350 386 # … … 359 395 ${TOP_SRCDIR}/configure --quiet --enable-network=server --disable-srp --disable-external-scripts --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 360 396 # 361 testmake $? 397 let "num = num + 1" >/dev/null 398 testmake $? $num || let "numfail = numfail + 1" >/dev/null 362 399 # 363 400 if test -r "Makefile"; then … … 367 404 ${TOP_SRCDIR}/configure --quiet --enable-network=client --disable-srp --disable-external-scripts --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 368 405 # 369 testmake $? 406 let "num = num + 1" >/dev/null 407 testmake $? $num || let "numfail = numfail + 1" >/dev/null 408 409 log_end "COMPILE" 370 410 } 371 372 373 374 testcompile375 376 377 # echo; echo "${S}__ END TEST COMPILE __${E}"; echo;378 379 exit380 -
trunk/test/testext.sh
r1 r19 1 1 #! /bin/sh 2 2 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 15 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 EXTERNAL PROGRAM __${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 46 COMP=`which gcc` 47 if test "x$?" = x1 ; then 48 COMP="cc" 49 else 50 COMP=`which gcc | sed -e "s%\([a-z:]\) .*%\1%g"` 51 if test "x$COMP" = x; then 52 COMP="cc" 53 elif test "x$COMP" = xno; then 54 COMP="cc" 55 else 56 if test "x$COMP" = "xwhich:"; then 57 COMP="cc" 58 else 59 COMP="gcc" 60 gcc -v >/dev/null 2>&1 || COMP="gcc" 61 fi 62 fi 63 fi 64 echo MAKE is $MAKE 65 echo COMP is $COMP 66 echo 67 3 MAXTEST=1; export MAXTEST 68 4 69 5 testext0 () 70 6 { 7 COMP=`which gcc` 8 if test "x$?" = x1 ; then 9 COMP="cc" 10 else 11 COMP=`which gcc | sed -e "s%\([a-z:]\) .*%\1%g"` 12 if test "x$COMP" = x; then 13 COMP="cc" 14 elif test "x$COMP" = xno; then 15 COMP="cc" 16 else 17 if test "x$COMP" = "xwhich:"; then 18 COMP="cc" 19 else 20 COMP="gcc" 21 gcc -v >/dev/null 2>&1 || COMP="gcc" 22 fi 23 fi 24 fi 25 log_start "EXTERNAL PROGRAM" 26 [ -z "$verbose" ] || echo MAKE is $MAKE 27 [ -z "$verbose" ] || { echo COMP is $COMP; echo; } 71 28 # 72 29 # standalone compilation 73 30 # 74 echo "${S}Building standalone agent${E}"; echo;31 [ -z "$verbose" ] || { echo; echo "${S}Building standalone agent${E}"; echo; } 75 32 # 76 33 if test -r "Makefile"; then 77 ${MAKE} distclean34 ${MAKE} distclean >/dev/null 78 35 fi 79 36 # 80 ${TOP_SRCDIR}/configure --quiet --enable-debug --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/testrc_1ext --with-log-file=$ PW_DIR/.samhain_log--with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file37 ${TOP_SRCDIR}/configure --quiet --enable-debug --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/testrc_1ext --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file 81 38 # 82 39 if test x$? = x0; then 83 echo "configure completed, exit status 0"; echo; 84 ${MAKE} > /dev/null 85 echo "${MAKE} completed, exit status $?"; echo; 40 [ -z "$verbose" ] || log_msg_ok "configure..."; 41 $MAKE > /dev/null 42 if test x$? = x0; then 43 [ -z "$verbose" ] || log_msg_ok "make..."; 44 else 45 [ -z "$quiet" ] && log_msg_fail "make..."; 46 return 1 47 fi 48 86 49 else 87 echo "ERROR: configure failed"; echo; 50 [ -z "$quiet" ] && log_msg_fail "configure..."; 51 return 1 88 52 fi 89 53 # 90 54 # prepare the program 91 55 # 92 56 cat test/test_ext.c.in | sed -e "s%MYPWDIR%$PW_DIR/test_ext.res%g" > test_ext.c 93 57 94 58 ${COMP} -o test_ext test_ext.c 95 59 if test "x$?" != x0; then 96 echo "FAIL:${COMP} -o test_ext test_ext.c"97 exit160 log_msg_fail "${COMP} -o test_ext test_ext.c" 61 return 1 98 62 fi 99 chmod +rx $PW_DIR/test_ext 100 63 chmod +rx test_ext 64 if test "x$?" != x0; then 65 log_msg_fail "chmod +rx test_ext" 66 return 1 67 fi 68 101 69 # compute checksum and fix config file 102 70 # … … 107 75 echo "SetChecksum=$CHKSUM" >> testrc_1ext 108 76 echo "SetFilterOr=ALERT" >> testrc_1ext 109 77 110 78 rm -f $PW_DIR/test_ext.res 111 79 rm -f $PW_DIR/pdbg.child 112 80 rm -f $PW_DIR/pdbg.main 113 ./samhain 114 81 ./samhain -p none 82 115 83 # The shell is too fast ... 116 sleep 1 117 echo; 118 echo "${S}Logged by external C program test_ext (filtered: ALERT only):${E}"; 119 echo; 120 cat $PW_DIR/test_ext.res 121 echo; 84 sleep 1 85 [ -z "$verbose" ] || { 86 echo; 87 echo "${S}Logged by external C program test_ext (filtered: ALERT only):${E}"; 88 echo; 89 cat $PW_DIR/test_ext.res 90 echo 91 } 92 93 tmp=`cat $PW_DIR/test_ext.res | wc -l` 94 if [ $tmp -eq 4 ]; then 95 tmp=`egrep 'RECV: \[EOF\]' $PW_DIR/test_ext.res | wc -l` 96 if [ $tmp -eq 2 ]; then 97 tmp=`egrep 'RECV: ALERT' $PW_DIR/test_ext.res | wc -l` 98 if [ $tmp -eq 2 ]; then 99 log_ok 1 ${MAXTEST}; 100 else 101 log_fail 1 ${MAXTEST}; 102 fi 103 else 104 log_fail 1 ${MAXTEST}; 105 fi 106 else 107 log_fail 1 ${MAXTEST}; 108 fi 122 109 123 110 rm -f $PW_DIR/.samhain_file 124 rm -f $ PW_DIR/.samhain_log111 rm -f $LOGFILE 125 112 rm -f $PW_DIR/.samhain_lock 126 113 114 log_end "EXTERNAL PROGRAM" 127 115 } 128 116 129 130 131 testext0132 133 134 echo; echo "${S}__ END TEST EXTERNAL PROGRAM __${E}"; echo;135 136 exit137 -
trunk/test/testhash.sh
r1 r19 1 1 #! /bin/sh 2 2 3 RCFILE="$PW_DIR/testrc_1.dyn"; export RCFILE 4 LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE 3 5 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 15 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 HASH FUNCTION __${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 46 6 MAXTEST=1; export MAXTEST 47 7 48 8 testhash () 49 9 { 10 log_start "HASH FUNCTION" 50 11 # 51 12 # test standalone compilation … … 57 18 fi 58 19 # 59 ${TOP_SRCDIR}/configure --quiet --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log 20 ${TOP_SRCDIR}/configure --quiet $TRUST --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 --enable-debug 21 # 22 fail=0 60 23 # 61 24 if test x$? = x0; then 62 echo "PASS: configure ${TEST}";25 [ -z "$verbose" ] || log_msg_ok "configure..."; 63 26 $MAKE > /dev/null 2>> test_log 64 27 if test x$? = x0; then 65 echo "PASS: $MAKE ${TEST}";28 [ -z "$verbose" ] || log_msg_ok "make..."; 66 29 else 67 echo "FAIL: $MAKE ${TEST} (see ./test_log)"; 30 [ -z "$quiet" ] && log_msg_fail "make..."; 31 fail=1 68 32 fi 69 33 else 70 echo "FAIL: configure ${TEST} (see ./test_log)"; 34 [ -z "$quiet" ] && log_msg_fail "configure..."; 35 fail=1 71 36 fi 72 37 # 38 if [ $fail -eq 1 ]; then 39 [ -z "$quiet" ] && log_fail 1 ${MAXTEST}; 40 return 1 41 fi 42 # 73 43 echo "Test results of the TIGER hash algorithm" > testhash.tmp 74 44 echo >> testhash.tmp … … 84 54 ./samhain -H "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996." >> testhash.tmp 85 55 ./samhain -H "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-" >> testhash.tmp 86 87 # echo 88 # echo "${S}diff testhash.tmp testtiger.txt (empty == success):${E}" 89 # echo 90 RESU=`diff testhash.tmp ${SCRIPTDIR}/testtiger.txt` 56 # 57 RESU=`diff testhash.tmp ${SCRIPTDIR}/testtiger.txt 2>/dev/null` 91 58 if test "x${RESU}" = "x"; then 92 echo "PASS: test_hash"59 [ -z "$quiet" ] && log_ok 1 ${MAXTEST}; 93 60 else 94 echo "FAIL: test_hash" 61 [ -z "$quiet" ] && log_fail 1 ${MAXTEST}; 62 return 1 95 63 fi 64 log_end "HASH FUNCTION" 65 return 0 96 66 } 97 67 98 68 99 69 100 testhash101 102 103 #echo; echo "${S}__ END TEST HASH FUNCTION __${E}"; echo;104 105 exit106 -
trunk/test/testrc_1
r1 r19 35 35 # for these files, only changes in permissions and ownership are checked 36 36 # 37 file=/etc/mtab37 #file=/etc/mtab 38 38 #file=/etc/ssh_random_seed 39 39 #file=/etc/asound.conf … … 79 79 # dir=/usr/bin 80 80 81 dir=/usr/bin81 #dir=/usr/bin 82 82 #dir=/lib 83 83 #dir=/usr/lib … … 91 91 #[SuidCheck] 92 92 #SuidCheckActive=T 93 # SuidCheckExclude=/net/localhost93 #SuidCheckExclude=/home 94 94 95 95 [EventSeverity] … … 145 145 # Restrict to certain classes of messages 146 146 # MailClass = RUN 147 PreludeSeverity = err147 #PreludeSeverity = err 148 148 149 149 # Which system calls to log (execve, utime, unlink, dup, chdir, open, kill, … … 161 161 #KernelCheckInterval = 20 162 162 163 [Utmp]163 #[Utmp] 164 164 # 165 165 # 0 to switch off, 1 to activate 166 166 # 167 LoginCheckActive=1167 #LoginCheckActive=1 168 168 169 169 # Severity for logins, multiple logins, logouts 170 170 # 171 SeverityLogin=info172 SeverityLoginMulti=warn173 SeverityLogout=info171 #SeverityLogin=info 172 #SeverityLoginMulti=warn 173 #SeverityLogout=info 174 174 175 175 # interval for login/logout checks 176 176 # 177 LoginCheckInterval=60177 #LoginCheckInterval=60 178 178 179 179 [Misc] … … 219 219 # MailSubject=* body %H # %M 220 220 221 TrustedUser=uucp,fax,fnet221 #TrustedUser=uucp,fax,fnet 222 222 223 223 # Watch syslog port -
trunk/test/testrc_2.in
r1 r19 28 28 29 29 30 [Attributes]31 #32 # for these files, only changes in permissions and ownership are checked33 #34 file=/etc/mtab35 #file=/etc/ssh_random_seed36 #file=/etc/asound.conf37 #file=/etc/resolv.conf38 file=/etc/localtime39 #file=/etc/ioctl.save40 #file=/etc/passwd.backup41 #file=/etc/shadow.backup42 43 #44 # There are files in /etc that might change, thus changing the directory45 # timestamps. Put it here as 'file', and in the ReadOnly section as 'dir'.46 #47 file=/etc48 49 50 [GrowingLogFiles]51 #52 # for these files, changes in signature, timestamps, and increase in size53 # are ignored54 #55 file=/var/log/messages56 57 58 30 [ReadOnly] 59 31 # 60 32 # for these files, only access time is ignored 61 33 # 62 dir=/usr/bin 63 #dir=/bin 34 # dir=/usr/bin 35 # dir=/bin 36 37 file = /var 38 file = /bin 39 file = /usr 40 file = /tmp 41 file = /etc 64 42 65 43 [EventSeverity] … … 112 90 SyslogSeverity=none 113 91 ExportSeverity=none 114 DatabaseSeverity= info92 DatabaseSeverity=none 115 93 116 94 #databaseseverity=info … … 146 124 Daemon=no 147 125 148 SetOutgoingIP=127.0.0.1 126 SetOutgoingIP = 127.0.0.1 127 SetServerInterface = 127.0.0.1 149 128 150 UseSeparateLogs= yes129 UseSeparateLogs=no 151 130 152 131 SetUseSocket = yes 153 132 154 #SetClientFromAccept = yes133 SetClientFromAccept = yes 155 134 156 135 SetUdpActive=no … … 206 185 207 186 # timer for time stamps 208 SetLoopTime= 30187 SetLoopTime=10 209 188 210 189 # trusted users (root and the effective user are always trusted) -
trunk/test/testrun_1.sh
r1 r19 1 1 #! /bin/sh 2 2 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 15 16 PW_DIR=`pwd` 17 18 if test x$UID != x; then 19 # TRUST="--with-trusted=0,2" 20 TRUST="--with-trusted=0,2,$UID" 21 else 22 TRUST="--with-trusted=0,2,500" 23 fi 24 25 echo; echo "${S}__ STARTING TEST RUN STANDALONE __${E}"; echo; 26 echo Working directory: $PW_DIR 27 28 MAKE=`which gmake` 29 if test "x$?" = x1 ; then 30 MAKE="make -s" 31 else 32 MAKE=`which gmake | sed -e "s%\([a-z:]\) .*%\1%g"` 33 if test "x$MAKE" = x; then 34 MAKE="make -s" 35 elif test "x$MAKE" = xno; then 36 MAKE="make -s" 3 RCFILE="$PW_DIR/testrc_1.dyn"; export RCFILE 4 LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE 5 6 # --enable-login-watch --enable-xml-log 7 # --enable-debug --enable-suidcheck --with-prelude 8 9 BUILDOPTS="--quiet $TRUST --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 --enable-debug" 10 export BUILDOPTS 11 12 BASE="${PW_DIR}/testrun_testdata"; export BASE 13 TDIRS="a b c a/a a/b a/c a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c"; export TDIRS 14 TFILES="x y z"; export TFILES 15 16 ########################################################### 17 # 18 # ---- [Define tests here] ---- 19 # 20 21 # 1 for testing new tests 22 testrun1_setup=0 23 24 MAXTEST=10; export MAXTEST 25 26 test_dirs () { 27 for ff in $CDIRS; do 28 # 29 egrep "Checking.*${BASE}/${ff}(>|\")" $LOGFILE >/dev/null 2>&1 30 if [ $? -ne 0 ]; then 31 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff} (checking)"; 32 return 1 33 fi 34 tmp=`egrep "Checking.*${BASE}/${ff}(>|\")" $LOGFILE 2>/dev/null | wc -l` 35 if [ $tmp -ne 1 ]; then 36 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff} (multiple)"; 37 fi 38 # 39 done 40 for ff in $NDIRS; do 41 # 42 egrep "Checking.*${BASE}/${ff}(>|\")" $LOGFILE >/dev/null 2>&1 43 if [ $? -eq 0 ]; then 44 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff} (checking)"; 45 return 1 46 fi 47 done 48 } 49 50 TESTPOLICY_10=" 51 [ReadOnly] 52 dir=99${BASE} 53 [IgnoreAll] 54 dir=-1${BASE}/b 55 [Attributes] 56 dir=1${BASE}/a 57 " 58 59 mod_testdata_10 () { 60 sleep 1 61 echo "foobar" >"${BASE}/b/x"; # ok 62 echo "foobar" >"${BASE}/c/x"; # bad 63 echo "foobar" >"${BASE}/a/x"; # ok 64 chmod 0555 "${BASE}/a/a/x"; # bad 65 chmod 0555 "${BASE}/a/a/a/x";# ok 66 chmod 0555 "${BASE}/a/y"; # bad 67 } 68 69 chk_testdata_10 () { 70 # CDIRS="a b c a/a a/b a/c a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c"; 71 tmp=`grep CRIT $LOGFILE | wc -l` 72 if [ $tmp -ne 3 ]; then 73 [ -z "$verbose" ] || log_msg_fail "policy count"; 74 return 1 75 fi 76 egrep "CRIT.*POLICY \[ReadOnly\] C-------TS.*${BASE}/c/x" $LOGFILE >/dev/null 2>&1 77 if [ $? -ne 0 ]; then 78 [ -z "$verbose" ] || log_msg_fail "${BASE}/c/x"; 79 return 1 80 fi 81 egrep "CRIT.*POLICY \[Attributes\] -----M----.*${BASE}/a/a/x" $LOGFILE >/dev/null 2>&1 82 if [ $? -ne 0 ]; then 83 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/x"; 84 return 1 85 fi 86 egrep "CRIT.*POLICY \[Attributes\] -----M----.*${BASE}/a/y" $LOGFILE >/dev/null 2>&1 87 if [ $? -ne 0 ]; then 88 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/y"; 89 return 1 90 fi 91 CDIRS="a a/a a/b a/c c"; 92 NDIRS="b a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c"; 93 test_dirs; 94 return $? 95 } 96 97 TESTPOLICY_9=" 98 [ReadOnly] 99 dir=0${BASE}/b 100 [Attributes] 101 dir=2${BASE}/a/a 102 " 103 104 mod_testdata_9 () { 105 echo "foobar" >"${BASE}/b/x"; 106 echo "foobar" >"${BASE}/a/x"; 107 echo "foobar" >"${BASE}/x"; 108 } 109 110 chk_testdata_9 () { 111 # CDIRS="a b c a/a a/b a/c a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c"; 112 tmp=`grep CRIT $LOGFILE | wc -l` 113 if [ $tmp -ne 1 ]; then 114 [ -z "$verbose" ] || log_msg_fail "policy count"; 115 return 1 116 fi 117 CDIRS="b a/a a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c"; 118 NDIRS="a c a/b a/c"; 119 test_dirs; 120 return $? 121 } 122 123 TESTPOLICY_8=" 124 [ReadOnly] 125 dir=1${BASE} 126 [Attributes] 127 dir=1${BASE}/a/a 128 " 129 130 mod_testdata_8 () { 131 echo "foobar" >"${BASE}/a/x"; 132 chmod 0555 "${BASE}/a/a/a/b/x"; 133 } 134 135 chk_testdata_8 () { 136 # CDIRS="a b c a/a a/b a/c a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c"; 137 tmp=`grep CRIT $LOGFILE | wc -l` 138 if [ $tmp -ne 1 ]; then 139 [ -z "$verbose" ] || log_msg_fail "policy count"; 140 return 1 141 fi 142 CDIRS="a b c a/a a/a/a a/a/b a/a/c"; 143 NDIRS="a/b a/c a/a/a/a a/a/a/b a/a/a/c"; 144 test_dirs; 145 return $? 146 } 147 148 149 TESTPOLICY_7=" 150 [ReadOnly] 151 dir=${BASE} 152 [Attributes] 153 dir=${BASE}/a/a 154 [GrowingLogFiles] 155 dir=${BASE}/a/a/a 156 [IgnoreAll] 157 file=${BASE}/a/a/a/z 158 dir=${BASE}/b 159 " 160 161 mod_testdata_7 () { 162 sleep 1 163 echo "foobar" >"${BASE}/a/a/a/z" # ok 164 echo "foobar" >"${BASE}/a/a/a/x" # bad 165 echo "foobar" >"${BASE}/a/a/x" # ok 166 echo "foobar" >"${BASE}/a/x" # bad 167 chmod 0555 "${BASE}/a" # bad 168 chmod 0555 "${BASE}/b" # ok 169 } 170 171 172 chk_testdata_7 () { 173 tmp=`grep CRIT $LOGFILE | wc -l` 174 if [ $tmp -ne 3 ]; then 175 [ -z "$verbose" ] || log_msg_fail "policy count"; 176 return 1 177 fi 178 egrep "CRIT.*POLICY \[GrowingLogs\] C--------S.*${BASE}/a/a/a/x" $LOGFILE >/dev/null 2>&1 179 if [ $? -ne 0 ]; then 180 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/a/x"; 181 return 1 182 fi 183 egrep "CRIT.*POLICY \[ReadOnly\] -----M--T-.*${BASE}/a" $LOGFILE >/dev/null 2>&1 184 if [ $? -ne 0 ]; then 185 [ -z "$verbose" ] || log_msg_fail "${BASE}/a"; 186 return 1 187 fi 188 egrep "CRIT.*POLICY \[ReadOnly\] C-------TS.*${BASE}/a/x" $LOGFILE >/dev/null 2>&1 189 if [ $? -ne 0 ]; then 190 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/x"; 191 return 1 192 fi 193 } 194 195 196 TESTPOLICY_6=" 197 [ReadOnly] 198 dir=${BASE} 199 [Attributes] 200 file=${BASE}/a/y 201 file=${BASE}/b/y 202 file=${BASE}/c/y 203 file=${BASE}/a/a/y 204 file=${BASE}/a/b/y 205 file=${BASE}/a/c/y 206 file=${BASE}/a/a/a/y 207 file=${BASE}/a/a/b/y 208 file=${BASE}/a/a/c/y 209 file=${BASE}/a/a/a/a/y 210 file=${BASE}/a/a/a/b/y 211 file=${BASE}/a/a/a/c/y 212 " 213 214 mod_testdata_6 () { 215 sleep 1 216 for ff in $TDIRS; do 217 echo "foobar" >"${BASE}/${ff}/x" 218 chmod 0555 "${BASE}/${ff}/y" 219 echo "foobar" >"${BASE}/${ff}/z" 220 done 221 } 222 223 chk_testdata_6 () { 224 count6=0 225 for ff in $TDIRS; do 226 # 227 egrep "Checking.*${BASE}/${ff}(>|\")" $LOGFILE >/dev/null 2>&1 228 if [ $? -ne 0 ]; then 229 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff} (checking)"; 230 return 1 231 fi 232 tmp=`egrep "Checking.*${BASE}/${ff}(>|\")" $LOGFILE 2>/dev/null | wc -l` 233 if [ $tmp -ne 1 ]; then 234 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff} (multiple)"; 235 fi 236 # 237 for gg in $TFILES; do 238 egrep "Checksum.*${BASE}/${ff}/${gg}" $LOGFILE >/dev/null 2>&1 239 if [ $? -ne 0 ]; then 240 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/${gg} (checking)"; 241 fi 242 tmp=`egrep "Checksum.*${BASE}/${ff}/${gg}" $LOGFILE 2>/dev/null | wc -l` 243 if [ $tmp -ne 1 ]; then 244 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/${gg} (multiple)"; 245 fi 246 done 247 egrep "CRIT.*POLICY \[ReadOnly\] C-------TS.*${BASE}/${ff}/x" $LOGFILE >/dev/null 2>&1 248 if [ $? -ne 0 ]; then 249 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/x"; 250 return 1 251 fi 252 let "count6 = count6 + 1" >/dev/null 253 egrep "CRIT.*POLICY \[ReadOnly\] C-------TS.*${BASE}/${ff}/z" $LOGFILE >/dev/null 2>&1 254 if [ $? -ne 0 ]; then 255 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/z"; 256 return 1 257 fi 258 let "count6 = count6 + 1" >/dev/null 259 egrep "CRIT.*POLICY \[Attributes\] -----M----.*${BASE}/${ff}/y" $LOGFILE >/dev/null 2>&1 260 if [ $? -ne 0 ]; then 261 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/y"; 262 return 1 263 fi 264 let "count6 = count6 + 1" >/dev/null 265 done 266 tmp=`grep CRIT $LOGFILE | wc -l` 267 if [ $tmp -ne $count6 ]; then 268 [ -z "$verbose" ] || log_msg_fail "policy count"; 269 return 1 270 fi 271 } 272 273 TESTPOLICY_5=" 274 [Attributes] 275 dir=${BASE} 276 file=${BASE}/a/a/c/x 277 [ReadOnly] 278 file=${BASE}/a/a/c/y 279 [GrowingLogFiles] 280 dir=${BASE}/a/a/c 281 dir=${BASE}/a/a/b 282 dir=${BASE}/a/b 283 " 284 285 mod_testdata_5 () { 286 mod_testdata_4 287 echo "This is a xxxx file" > "${BASE}/a/a/b/x" # GrowingLogFiles 288 echo "This is a test file" > "${BASE}/a/a/b/y" # GrowingLogFiles 289 echo "This is a xxxx file bad" > "${BASE}/a/a/b/z" # GrowingLogFiles 290 } 291 292 chk_testdata_5 () { 293 for ff in $TDIRS; do 294 # 295 egrep "Checking.*${BASE}/${ff}(>|\")" $LOGFILE >/dev/null 2>&1 296 if [ $? -ne 0 ]; then 297 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff} (checking)"; 298 return 1 299 fi 300 tmp=`egrep "Checking.*${BASE}/${ff}(>|\")" $LOGFILE 2>/dev/null | wc -l` 301 if [ $tmp -ne 1 ]; then 302 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff} (multiple)"; 303 fi 304 # 305 for gg in $TFILES; do 306 egrep "Checksum.*${BASE}/${ff}/${gg}" $LOGFILE >/dev/null 2>&1 307 if [ $? -ne 0 ]; then 308 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/${gg} (checking)"; 309 fi 310 tmp=`egrep "Checksum.*${BASE}/${ff}/${gg}" $LOGFILE 2>/dev/null | wc -l` 311 if [ $tmp -ne 1 ]; then 312 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/${gg} (multiple)"; 313 fi 314 done 315 done 316 egrep "CRIT.*POLICY \[GrowingLogs\] C---------.*${BASE}/a/a/b/x" $LOGFILE >/dev/null 2>&1 317 if [ $? -ne 0 ]; then 318 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/b/x"; 319 return 1 320 fi 321 egrep "CRIT.*POLICY \[GrowingLogs\] C---------.*${BASE}/a/a/b/z" $LOGFILE >/dev/null 2>&1 322 if [ $? -ne 0 ]; then 323 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/b/z"; 324 return 1 325 fi 326 egrep "CRIT.*POLICY \[GrowingLogs\] -----M----.*${BASE}/a/b/z" $LOGFILE >/dev/null 2>&1 327 if [ $? -ne 0 ]; then 328 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/b/z"; 329 return 1 330 fi 331 egrep "CRIT.*POLICY \[GrowingLogs\] -----M----.*${BASE}/a/a/c/z" $LOGFILE >/dev/null 2>&1 332 if [ $? -ne 0 ]; then 333 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/c/z"; 334 return 1 335 fi 336 egrep "CRIT.*POLICY \[GrowingLogs\] C--------S.*${BASE}/a/b/y" $LOGFILE >/dev/null 2>&1 337 if [ $? -ne 0 ]; then 338 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/b/y"; 339 return 1 340 fi 341 egrep "CRIT.*POLICY \[Attributes\] -----M----.*${BASE}/a/a/c/x" $LOGFILE >/dev/null 2>&1 342 if [ $? -ne 0 ]; then 343 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/c/x"; 344 return 1 345 fi 346 egrep "CRIT.*POLICY ADDED.*${BASE}/a/a/c/foo" $LOGFILE >/dev/null 2>&1 347 if [ $? -ne 0 ]; then 348 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/c/foo"; 349 return 1 350 fi 351 egrep "CRIT.*POLICY ADDED.*033\[1;30m" $LOGFILE >/dev/null 2>&1 352 if [ $? -ne 0 ]; then 353 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/\033[1;30m"; 354 return 1 355 fi 356 egrep "WARN.*Weird filename.*033\[1;30m" $LOGFILE >/dev/null 2>&1 357 if [ $? -ne 0 ]; then 358 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/\033[1;30m"; 359 return 1 360 fi 361 egrep "CRIT.*POLICY \[ReadOnly\] C-------TS.*${BASE}/a/a/c/y" $LOGFILE >/dev/null 2>&1 362 if [ $? -ne 0 ]; then 363 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/c/y"; 364 return 1 365 fi 366 tmp=`grep CRIT $LOGFILE | wc -l` 367 if [ $tmp -ne 9 ]; then 368 [ -z "$verbose" ] || log_msg_fail "policy count"; 369 return 1 370 fi 371 } 372 373 374 TESTPOLICY_4=" 375 [Attributes] 376 dir=${BASE} 377 file=${BASE}/a/a/c/x 378 [ReadOnly] 379 file=${BASE}/a/a/c/y 380 [LogFiles] 381 dir=${BASE}/a/a/c 382 dir=${BASE}/a/b 383 " 384 385 mod_testdata_4 () { 386 sleep 1 387 echo "foobar" >> "${BASE}/a/a/x" # Attributes 388 echo "foobar" > "${BASE}/a/a/c/foo" # new within LogFiles 389 echo "foobar" >> "${BASE}/a/a/c/y" # ReadOnly 390 echo "foobar" >> "${BASE}/a/a/c/x" # Attributes 391 chmod 0555 "${BASE}/a/a/c/x" # Attributes 392 chmod 0555 "${BASE}/a/a/c/z" # LogFiles 393 echo "foobar" >> "${BASE}/a/b/x" # LogFiles 394 echo "" > "${BASE}/a/b/y" # LogFiles 395 chmod 0555 "${BASE}/a/b/z" # LogFiles 396 touch "${BASE}/a/a/[1;30m" # non-printable character in filename 397 } 398 399 chk_testdata_4 () { 400 for ff in $TDIRS; do 401 # 402 egrep "Checking.*${BASE}/${ff}(>|\")" $LOGFILE >/dev/null 2>&1 403 if [ $? -ne 0 ]; then 404 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff} (checking)"; 405 return 1 406 fi 407 tmp=`egrep "Checking.*${BASE}/${ff}(>|\")" $LOGFILE 2>/dev/null | wc -l` 408 if [ $tmp -ne 1 ]; then 409 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff} (multiple)"; 410 fi 411 # 412 for gg in $TFILES; do 413 egrep "Checksum.*${BASE}/${ff}/${gg}" $LOGFILE >/dev/null 2>&1 414 if [ $? -ne 0 ]; then 415 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/${gg} (checking)"; 416 fi 417 tmp=`egrep "Checksum.*${BASE}/${ff}/${gg}" $LOGFILE 2>/dev/null | wc -l` 418 if [ $tmp -ne 1 ]; then 419 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/${gg} (multiple)"; 420 fi 421 done 422 done 423 egrep "CRIT.*POLICY \[Attributes\] -----M----.*${BASE}/a/a/c/x" $LOGFILE >/dev/null 2>&1 424 if [ $? -ne 0 ]; then 425 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/c/x"; 426 return 1 427 fi 428 egrep "CRIT.*POLICY \[LogFiles\] -----M----.*${BASE}/a/b/z" $LOGFILE >/dev/null 2>&1 429 if [ $? -ne 0 ]; then 430 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/b/z"; 431 return 1 432 fi 433 egrep "CRIT.*POLICY \[LogFiles\] -----M----.*${BASE}/a/a/c/z" $LOGFILE >/dev/null 2>&1 434 if [ $? -ne 0 ]; then 435 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/c/z"; 436 return 1 437 fi 438 egrep "CRIT.*POLICY ADDED.*${BASE}/a/a/c/foo" $LOGFILE >/dev/null 2>&1 439 if [ $? -ne 0 ]; then 440 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/c/foo"; 441 return 1 442 fi 443 egrep "CRIT.*POLICY ADDED.*033\[1;30m" $LOGFILE >/dev/null 2>&1 444 if [ $? -ne 0 ]; then 445 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/\033[1;30m"; 446 return 1 447 fi 448 egrep "WARN.*Weird filename.*033\[1;30m" $LOGFILE >/dev/null 2>&1 449 if [ $? -ne 0 ]; then 450 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/\033[1;30m"; 451 return 1 452 fi 453 egrep "CRIT.*POLICY \[ReadOnly\] C-------TS.*${BASE}/a/a/c/y" $LOGFILE >/dev/null 2>&1 454 if [ $? -ne 0 ]; then 455 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/c/y"; 456 return 1 457 fi 458 tmp=`grep CRIT $LOGFILE | wc -l` 459 if [ $tmp -ne 6 ]; then 460 [ -z "$verbose" ] || log_msg_fail "policy count"; 461 return 1 462 fi 463 } 464 465 TESTPOLICY_3=" 466 [Attributes] 467 dir=${BASE} 468 file=${BASE}/a/a/c/x 469 [ReadOnly] 470 file=${BASE}/a/a/c/y 471 [IgnoreAll] 472 dir=${BASE}/a/a/c 473 " 474 mod_testdata_3 () { 475 sleep 1 476 echo "foobar" > "${BASE}/a/b/foo" # new within Attributes 477 chmod 0555 "${BASE}/a/b" 478 echo "foobar" > "${BASE}/a/a/c/foo" # new within IgnoreAll 479 echo "foobar" > "${BASE}/a/a/c/y" # ReadOnly 480 chmod 0555 "${BASE}/a/a/c/x" # Attributes 481 chmod 0555 "${BASE}/a/a/c/z" # IgnoreAll 482 } 483 484 chk_testdata_3 () { 485 for ff in $TDIRS; do 486 # 487 egrep "Checking.*${BASE}/${ff}(>|\")" $LOGFILE >/dev/null 2>&1 488 if [ $? -ne 0 ]; then 489 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff} (checking)"; 490 return 1 491 fi 492 tmp=`egrep "Checking.*${BASE}/${ff}(>|\")" $LOGFILE 2>/dev/null | wc -l` 493 if [ $tmp -ne 1 ]; then 494 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff} (multiple)"; 495 fi 496 # 497 for gg in $TFILES; do 498 egrep "Checksum.*${BASE}/${ff}/${gg}" $LOGFILE >/dev/null 2>&1 499 if [ $? -ne 0 ]; then 500 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/${gg} (checking)"; 501 fi 502 tmp=`egrep "Checksum.*${BASE}/${ff}/${gg}" $LOGFILE 2>/dev/null | wc -l` 503 if [ $tmp -ne 1 ]; then 504 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/${gg} (multiple)"; 505 fi 506 done 507 done 508 egrep "CRIT.*POLICY ADDED.*${BASE}/a/b/foo" $LOGFILE >/dev/null 2>&1 509 if [ $? -ne 0 ]; then 510 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/b/foo"; 511 return 1 512 fi 513 egrep "CRIT.*POLICY ADDED.*${BASE}/a/a/c/foo" $LOGFILE >/dev/null 2>&1 514 if [ $? -ne 0 ]; then 515 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/c/foo"; 516 return 1 517 fi 518 egrep "CRIT.*POLICY \[Attributes\] -----M----.*${BASE}/a/b" $LOGFILE >/dev/null 2>&1 519 if [ $? -ne 0 ]; then 520 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/b"; 521 return 1 522 fi 523 egrep "CRIT.*POLICY \[Attributes\] -----M----.*${BASE}/a/a/c/x" $LOGFILE >/dev/null 2>&1 524 if [ $? -ne 0 ]; then 525 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/c/x"; 526 return 1 527 fi 528 egrep "CRIT.*POLICY \[ReadOnly\] C-------TS.*${BASE}/a/a/c/y" $LOGFILE >/dev/null 2>&1 529 if [ $? -ne 0 ]; then 530 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/c/y"; 531 return 1 532 fi 533 tmp=`grep CRIT $LOGFILE | wc -l` 534 if [ $tmp -ne 5 ]; then 535 [ -z "$verbose" ] || log_msg_fail "policy count"; 536 return 1 537 fi 538 } 539 540 TESTPOLICY_2=" 541 [ReadOnly] 542 dir=${BASE} 543 file=${BASE}/a/a/c/x 544 [IgnoreAll] 545 dir=${BASE}/a/a/c 546 " 547 mod_testdata_2 () { 548 mod_testdata_1; 549 rm "${BASE}/a/a/c/y" 550 echo "foobar" > "${BASE}/a/a/c/foo" 551 chmod 0555 "${BASE}/a/a/c/x" 552 chmod 0555 "${BASE}/a/a/c/z" 553 } 554 555 chk_testdata_2 () { 556 for ff in $TDIRS; do 557 # 558 egrep "Checking.*${BASE}/${ff}(>|\")" $LOGFILE >/dev/null 2>&1 559 if [ $? -ne 0 ]; then 560 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff} (checking)"; 561 return 1 562 fi 563 tmp=`egrep "Checking.*${BASE}/${ff}(>|\")" $LOGFILE 2>/dev/null | wc -l` 564 if [ $tmp -ne 1 ]; then 565 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff} (multiple)"; 566 fi 567 # 568 for gg in $TFILES; do 569 egrep "Checksum.*${BASE}/${ff}/${gg}" $LOGFILE >/dev/null 2>&1 570 if [ $? -ne 0 ]; then 571 if [ x"${ff}/${gg}" = x"a/a/c/y" ]; then :; else 572 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/${gg} (checking)"; 573 return 1 574 fi 575 fi 576 done 577 done 578 egrep "CRIT.*POLICY ADDED.*${BASE}/a/a/c/foo" $LOGFILE >/dev/null 2>&1 579 if [ $? -ne 0 ]; then 580 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/c/foo"; 581 return 1 582 fi 583 egrep "CRIT.*POLICY MISSING.*${BASE}/a/a/c/y" $LOGFILE >/dev/null 2>&1 584 if [ $? -ne 0 ]; then 585 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/c/y"; 586 return 1 587 fi 588 egrep "CRIT.*POLICY \[ReadOnly\] -----M--T-.*${BASE}/a/a/c/x" $LOGFILE >/dev/null 2>&1 589 if [ $? -ne 0 ]; then 590 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/c/x"; 591 return 1 592 fi 593 tmp=`grep CRIT $LOGFILE | wc -l` 594 if [ $tmp -ne 8 ]; then 595 [ -z "$verbose" ] || log_msg_fail "policy count"; 596 return 1 597 fi 598 } 599 600 TESTPOLICY_1=" 601 [ReadOnly] 602 dir=${BASE} 603 " 604 605 mod_testdata_1 () { 606 sleep 1 607 touch "${BASE}/a/a/x" 608 chmod 0555 "${BASE}/a/a/y" 609 mv "${BASE}/a/b/y" "${BASE}/a/b/yy"; echo "This is a test file" > "${BASE}/a/b/y"; rm "${BASE}/a/b/yy" 610 echo "foobar" > "${BASE}/a/c/y" 611 } 612 613 chk_testdata_1 () { 614 for ff in $TDIRS; do 615 # 616 egrep "Checking.*${BASE}/${ff}(>|\")" $LOGFILE >/dev/null 2>&1 617 if [ $? -ne 0 ]; then 618 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff} (checking)"; 619 return 1 620 fi 621 tmp=`egrep "Checking.*${BASE}/${ff}(>|\")" $LOGFILE 2>/dev/null | wc -l` 622 if [ $tmp -ne 1 ]; then 623 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff} (multiple)"; 624 fi 625 # 626 for gg in $TFILES; do 627 egrep "Checksum.*${BASE}/${ff}/${gg}" $LOGFILE >/dev/null 2>&1 628 if [ $? -ne 0 ]; then 629 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/${gg} (checking)"; 630 return 1 631 fi 632 tmp=`egrep "Checksum.*${BASE}/${ff}/${gg}" $LOGFILE 2>/dev/null | wc -l` 633 if [ $tmp -ne 1 ]; then 634 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/${gg} (multiple)"; 635 fi 636 done 637 done 638 egrep "CRIT.*POLICY \[ReadOnly\] --------T-.*${BASE}/a/a/x" $LOGFILE >/dev/null 2>&1 639 if [ $? -ne 0 ]; then 640 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/x"; 641 return 1 642 fi 643 egrep "CRIT.*POLICY \[ReadOnly\] -----M--T-.*${BASE}/a/a/y" $LOGFILE >/dev/null 2>&1 644 if [ $? -ne 0 ]; then 645 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/y"; 646 return 1 647 fi 648 egrep "CRIT.*POLICY \[ReadOnly\] ---I----T-.*${BASE}/a/b/y" $LOGFILE >/dev/null 2>&1 649 if [ $? -ne 0 ]; then 650 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/b/y"; 651 return 1 652 fi 653 egrep "CRIT.*POLICY \[ReadOnly\] --------T-.*${BASE}/a/b" $LOGFILE >/dev/null 2>&1 654 if [ $? -ne 0 ]; then 655 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/b"; 656 return 1 657 fi 658 egrep "CRIT.*POLICY \[ReadOnly\] C-------TS.*${BASE}/a/c/y" $LOGFILE >/dev/null 2>&1 659 if [ $? -ne 0 ]; then 660 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/c/y"; 661 return 1 662 fi 663 tmp=`grep CRIT $LOGFILE | wc -l` 664 if [ $tmp -ne 5 ]; then 665 [ -z "$verbose" ] || log_msg_fail "policy count"; 666 return 1 667 fi 668 return 0 669 } 670 671 672 ############################################################## 673 # 674 # Common subroutines 675 # 676 677 mkconfig_misc () 678 { 679 test -f "${RCFILE}" || touch "${RCFILE}" 680 cat >> "${RCFILE}" <<End-of-data 681 [Misc] 682 Daemon=no 683 SetFilecheckTime=60 684 TrustedUser=uucp,fax,fnet 685 SetRecursionLevel=10 686 SetLoopTime=30 687 ReportFullDetail = no 688 ChecksumTest=check 689 690 End-of-data 691 } 692 693 mkconfig_log () 694 { 695 test -f "${RCFILE}" || touch "${RCFILE}" 696 cat >> "${RCFILE}" <<End-of-data 697 [Log] 698 MailSeverity=none 699 LogSeverity=warn 700 SyslogSeverity=none 701 PrintSeverity=info 702 MailSeverity=none 703 #Restrict to certain classes of messages 704 #LogClass=RUN 705 #PreludeSeverity=err 706 #ExportSeverity=none 707 708 End-of-data 709 } 710 711 mkconfig_sev () 712 { 713 test -f "${RCFILE}" || touch "${RCFILE}" 714 cat >> "${RCFILE}" <<End-of-data 715 [EventSeverity] 716 SeverityUser0=crit 717 SeverityUser1=crit 718 SeverityReadOnly=crit 719 SeverityLogFiles=crit 720 SeverityGrowingLogs=crit 721 SeverityIgnoreNone=crit 722 SeverityAttributes=crit 723 SeverityIgnoreAll=crit 724 SeverityFiles=err 725 SeverityDirs=err 726 SeverityNames=warn 727 728 End-of-data 729 } 730 731 prep_testpolicy () 732 { 733 test -f "${RCFILE}" || touch "${RCFILE}" 734 eval echo '"$'"TESTPOLICY_$1"'"' >>"${RCFILE}" 735 } 736 737 prep_init () 738 { 739 rm -f ./.samhain_file 740 rm -f "${LOGFILE}" 741 rm -f ./.samhain_lock 742 743 rm -f "${RCFILE}" 744 mkconfig_sev 745 mkconfig_log 746 mkconfig_misc 747 } 748 749 run_init () 750 { 751 ./samhain -t init -p none 752 753 if test x$? = x0; then 754 [ -z "$verbose" ] || log_msg_ok "init..."; 37 755 else 38 if test "x$MAKE" = "xwhich:"; then 39 MAKE="make -s" 40 else 41 MAKE="gmake -s" 42 gmake -v >/dev/null 2>&1 || MAKE="make -s" 43 fi 44 fi 45 fi 46 echo MAKE is $MAKE 47 echo 48 49 # --with-database=mysql 50 # --enable-debug 51 # [egd|unix|dev|default] 52 53 testrun1 () 54 { 756 [ -z "$quiet" ] && log_msg_fail "init..."; 757 return 1 758 fi 759 } 760 761 run_check () 762 { 763 ./samhain -t check -p none -l debug 764 765 if test x$? = x0; then 766 ./samhain -j -L $LOGFILE >"${LOGFILE}.tmp" && mv "${LOGFILE}.tmp" "${LOGFILE}" 767 if [ $? -ne 0 ]; then 768 [ -z "$quiet" ] && log_msg_fail "mv logfile..."; 769 return 1 770 fi 771 [ -z "$verbose" ] || log_msg_ok "check..."; 772 else 773 [ -z "$quiet" ] && log_msg_fail "check..."; 774 return 1 775 fi 776 } 777 778 run_update () 779 { 780 ./samhain -t update -p none -l debug 781 782 if test x$? = x0; then 783 [ -z "$verbose" ] || log_msg_ok "update..."; 784 else 785 [ -z "$quiet" ] && log_msg_fail "update..."; 786 return 1 787 fi 788 } 789 790 run_check_after_update () 791 { 792 rm -rf $LOGFILE 793 794 ./samhain -t check -p none -l debug 795 796 if test x$? = x0; then 797 # 798 tmp=`./samhain -j -L $LOGFILE | grep CRIT | wc -l` 799 if [ $tmp -ne 0 ]; then 800 [ -z "$verbose" ] || log_msg_fail "update not successful(?)"; 801 return 1 802 fi 803 tmp=`./samhain -j -L $LOGFILE | grep ERR | wc -l` 804 if [ $tmp -ne 0 ]; then 805 [ -z "$verbose" ] || log_msg_fail "update not successful(?)"; 806 return 1 807 fi 808 # 809 [ -z "$verbose" ] || log_msg_ok "check(2)..."; 810 else 811 [ -z "$quiet" ] && log_msg_fail "check(2)..."; 812 return 1 813 fi 814 } 815 816 prep_testdata () 817 { 818 chmod -R 0700 "${BASE}" || { 819 [ -z "$quiet" ] && log_msg_fail "chmod -R 0700 ${BASE}"; 820 return 1; 821 } 822 823 rm -rf "${BASE}" || { 824 [ -z "$quiet" ] && log_msg_fail "rm -rf ${BASE}"; 825 return 1; 826 } 827 828 mkdir "${BASE}" || { 829 [ -z "$quiet" ] && log_msg_fail "mkdir ${BASE}"; 830 return 1; 831 } 832 833 for ff in $TDIRS; do 834 mkdir "${BASE}/${ff}" || { 835 [ -z "$quiet" ] && log_msg_fail "mkdir ${BASE}/${ff}"; 836 return 1; 837 } 838 chmod 0755 "${BASE}/${ff}" 839 for gg in $TFILES; do 840 echo "This is a test file" > "${BASE}/${ff}/${gg}" 841 chmod 0644 "${BASE}/${ff}/${gg}" 842 done 843 done 844 } 845 846 check_err () 847 { 848 if [ $1 -ne 0 ]; then 849 [ -z "$quiet" ] && log_fail ${2} ${MAXTEST}; 850 return 1 851 fi 852 return 0 853 } 854 855 testrun_internal () 856 { 857 [ -z "$verbose" ] || echo Working directory: $PW_DIR 858 [ -z "$verbose" ] || { echo MAKE is $MAKE; echo; } 859 55 860 # 56 861 # test standalone compilation 57 862 # 58 echo "${S}Building standalone agent${E}"; echo;59 # 863 [ -z "$verbose" ] || { echo; echo "${S}Building standalone agent${E}"; echo; } 864 60 865 if test -r "Makefile"; then 61 $MAKE distclean 62 fi 63 # 64 # --enable-login-watch --enable-xml-log 65 # --enable-debug --enable-suidcheck --with-prelude 66 67 ${TOP_SRCDIR}/configure --quiet $TRUST --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/test/testrc_1 --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file --enable-debug 68 # --with-prelude --enable-micro-stealth=128 69 # --with-prelude 70 71 # --with-kcheck=/boot/System.map 72 73 # --with-prelude --enable-xml-log 74 75 # --with-kcheck=/boot/System.map-2.4.20-24.9 76 # --with-kcheck=/boot/System.map-deb-2.4.18-686 77 78 # --enable-stealth=192 79 # --with-console=$PW_DIR/dlog_file 866 $MAKE distclean >/dev/null 867 fi 868 869 ${TOP_SRCDIR}/configure ${BUILDOPTS} 80 870 81 871 # 82 872 if test x$? = x0; then 83 echo "configure completed, exit status 0"; echo;873 [ -z "$verbose" ] || log_msg_ok "configure..."; 84 874 $MAKE > /dev/null 85 875 if test x$? = x0; then 86 echo "$MAKE completed, exit status $?"; echo;876 [ -z "$verbose" ] || log_msg_ok "make..."; 87 877 else 88 echo "${S}ERROR:${E} make failed, exit status $?"; echo;89 exit878 [ -z "$quiet" ] && log_msg_fail "make..."; 879 return 1 90 880 fi 91 881 92 882 else 93 echo "${S}ERROR:${E} configure failed, exit status $?"; echo; 94 exit 95 fi 96 97 rm -f ./.samhain_file 98 rm -f ./.samhain_log 99 rm -f ./.samhain_lock 100 101 ./samhain -t init 102 103 if test x$? = x0; then 104 echo 105 echo "${S}init completed${E}" 106 echo 107 ./samhain -t check 108 if test x$? = x0; then 109 echo "${S}check completed${E}" 110 else 111 echo "${S}ERROR:${E} -- check -- failed, exit status $?" 112 echo 113 exit 114 fi 115 else 116 echo "${S}ERROR:${E} -- init -- failed, exit status $?"; echo; 117 exit 118 fi 883 [ -z "$quiet" ] && log_msg_fail "configure..."; 884 return 1 885 fi 886 887 [ -z "$verbose" ] || { echo; echo "${S}Running test suite${E}"; echo; } 888 889 tcount=1 890 POLICY=`eval echo '"$'"TESTPOLICY_$tcount"'"'` 891 892 until [ -z "$POLICY" ] 893 do 894 prep_init 895 check_err $? ${tcount}; errval=$? 896 if [ $errval -eq 0 ]; then 897 prep_testdata 898 check_err $? ${tcount}; errval=$? 899 fi 900 if [ $errval -eq 0 ]; then 901 prep_testpolicy ${tcount} 902 check_err $? ${tcount}; errval=$? 903 fi 904 if [ $errval -eq 0 ]; then 905 run_init 906 check_err $? ${tcount}; errval=$? 907 fi 908 if [ $errval -eq 0 ]; then 909 eval mod_testdata_${tcount} 910 check_err $? ${tcount}; errval=$? 911 fi 912 if [ $errval -eq 0 ]; then 913 run_check 914 check_err $? ${tcount}; errval=$? 915 fi 916 if [ $errval -eq 0 ]; then 917 eval chk_testdata_${tcount} 918 check_err $? ${tcount}; errval=$? 919 fi 920 if [ $testrun1_setup -eq 0 ]; then 921 if [ $errval -eq 0 ]; then 922 run_update 923 check_err $? ${tcount}; errval=$? 924 fi 925 if [ $errval -eq 0 ]; then 926 run_check_after_update 927 check_err $? ${tcount}; errval=$? 928 fi 929 fi 930 # 931 if [ $errval -eq 0 ]; then 932 [ -z "$quiet" ] && log_ok ${tcount} ${MAXTEST}; 933 fi 934 let "tcount = tcount + 1" >/dev/null 935 POLICY=`eval echo '"$'"TESTPOLICY_$tcount"'"'` 936 done 119 937 120 } 121 122 123 124 testrun1 125 126 127 echo; echo "${S}__ END TEST RUN STANDALONE __${E}"; echo; 128 129 exit 130 938 return 0 939 } 940 941 testrun1 () 942 { 943 log_start "RUN STANDALONE" 944 testrun_internal 945 log_end "RUN STANDALONE" 946 return 0 947 } 948 949 950 -
trunk/test/testrun_1a.sh
r1 r19 1 1 #! /bin/sh 2 2 3 BUILDOPTS="--quiet $TRUST --enable-debug --enable-xml-log --enable-micro-stealth=137 --enable-login-watch --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" 4 export BUILDOPTS 3 5 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 15 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 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 46 echo MAKE is $MAKE 47 echo 48 49 50 testrun1 () 6 testrun1a () 51 7 { 52 # 53 # test standalone compilation 54 # 55 echo "${S}Building standalone agent${E}"; echo; 56 # 57 if test -r "Makefile"; then 58 $MAKE distclean 59 fi 60 # 61 ${TOP_SRCDIR}/configure --quiet $TRUST --enable-debug --enable-xml-log --enable-micro-stealth=137 --enable-nocl=foo --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/test/testrc_1 --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file 62 # 63 if test x$? = x0; then 64 echo "configure completed, exit status 0"; echo; 65 $MAKE > /dev/null 66 if test x$? = x0; then 67 echo "$MAKE completed, exit status $?"; echo; 68 else 69 echo "${S}ERROR:${E} make failed, exit status $?"; echo; 70 exit 71 fi 72 73 else 74 echo "${S}ERROR:${E} configure failed, exit status $?"; echo; 75 exit 76 fi 77 78 rm -f ./.samhain_file 79 rm -f ./.samhain_log 80 rm -f ./.samhain_lock 81 82 echo '-t init' | ./samhain foo 83 84 if test x$? = x0; then 85 echo 86 echo "${S}init completed${E}" 87 echo 88 echo '-t check' | ./samhain foo 89 if test x$? = x0; then 90 echo "${S}check completed${E}" 91 else 92 echo "${S}ERROR:${E} -- check -- failed, exit status $?" 93 echo 94 exit 95 fi 96 else 97 echo "${S}ERROR:${E} -- init -- failed, exit status $?"; echo; 98 exit 99 fi 100 8 log_start "RUN STANDALONE W/STEALTH" 9 testrun_internal 10 log_end "RUN STANDALONE W/STEALTH" 11 return 0 101 12 } 102 13 103 104 105 testrun1106 107 108 echo; echo "${S}__ END TEST RUN STANDALONE __${E}"; echo;109 110 exit111 -
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 -
trunk/test/testrun_2.sh
r1 r19 1 1 #! /bin/sh 2 2 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 15 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 CLIENT/SERVER __${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 46 echo MAKE is $MAKE 47 echo 48 49 # --with-database=postgresql 50 # export MYLIB=-L/usr/local/pgsql/lib 51 # export MYINC=-I/usr/local/pgsql/include 52 # export LD_LIBRARY_PATH=/usr/local/pgsql/lib 53 54 # --with-database=mysql 55 # export MYLIB=-L/usr/local/mysql/lib 56 # export MYINC=-I/usr/local/mysql/include 57 # export LD_LIBRARY_PATH=/usr/local/mysql/lib 58 59 testrun2 () 3 LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE 4 RCFILE="$PW_DIR/testrc_2"; export RCFILE 5 6 7 do_test_1 () { 8 9 [ -z "$verbose" ] || { 10 echo; 11 echo "${S}Start Server${E}: ./yule -l info -p none &"; 12 echo; 13 } 14 ./yule -l info -p none >/dev/null 2>&1 & 15 PROC_Y=$! 16 sleep 5 17 18 [ -z "$verbose" ] || { 19 echo; 20 echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check"; 21 echo; 22 } 23 24 ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>&1 25 if test x$? = x0; then 26 [ -z "$verbose" ] || log_msg_ok "samhain.new -t check"; 27 else 28 [ -z "$quiet" ] && log_msg_fail "samhain.new -t check"; 29 kill $PROC_Y 30 return 1 31 fi 32 33 kill $PROC_Y 34 sleep 5 35 36 egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1 37 if [ $? -ne 0 ]; then 38 [ -z "$verbose" ] || log_msg_fail "Server start"; 39 return 1 40 fi 41 egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1 42 if [ $? -ne 0 ]; then 43 [ -z "$verbose" ] || log_msg_fail "Client connect"; 44 return 1 45 fi 46 egrep "remote_host.*Checking.*/bin" $LOGFILE >/dev/null 2>&1 47 if [ $? -ne 0 ]; then 48 [ -z "$verbose" ] || log_msg_fail "Client file check"; 49 return 1 50 fi 51 egrep "remote_host.*EXIT.*Samhain" $LOGFILE >/dev/null 2>&1 52 if [ $? -ne 0 ]; then 53 [ -z "$verbose" ] || log_msg_fail "Client exit"; 54 return 1 55 fi 56 egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1 57 if [ $? -ne 0 ]; then 58 [ -z "$verbose" ] || log_msg_fail "Server exit"; 59 return 1 60 fi 61 62 63 return 0 64 } 65 66 do_test_2 () { 67 68 ORIGINAL="UseSeparateLogs=no" 69 REPLACEMENT="UseSeparateLogs=yes" 70 ex $RCFILE <<EOF 71 :%s/$ORIGINAL/$REPLACEMENT/g 72 :wq 73 EOF 74 # :%s is the "ex" substitution command. 75 # :wq is write-and-quit. 76 [ -z "$verbose" ] || { 77 echo; 78 echo "${S}Start Server${E}: ./yule -l info -p none &"; 79 echo; 80 } 81 82 rm -f $LOGFILE 83 84 ./yule -l info -p none >/dev/null 2>&1 & 85 PROC_Y=$! 86 sleep 5 87 88 [ -z "$verbose" ] || { 89 echo; 90 echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check"; 91 echo; 92 } 93 94 ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>&1 95 if test x$? = x0; then 96 [ -z "$verbose" ] || log_msg_ok "samhain.new -t check"; 97 else 98 [ -z "$quiet" ] && log_msg_fail "samhain.new -t check"; 99 kill $PROC_Y 100 return 1 101 fi 102 103 kill $PROC_Y 104 sleep 5 105 106 if [ -f ${LOGFILE}.${SH_LOCALHOST} ]; then 107 remhost=${SH_LOCALHOST} 108 else 109 remhost=`echo $SH_LOCALHOST | sed 's,\..*,,'` 110 fi 111 if [ -f ${LOGFILE}.${remhost} ]; then 112 CLIENTLOG="${LOGFILE}.${remhost}" 113 else 114 CLIENTLOG=`ls -1 ${LOGFILE}.* | tail -n 1` 115 fi 116 117 egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1 118 if [ $? -ne 0 ]; then 119 [ -z "$verbose" ] || log_msg_fail "Server start"; 120 return 1 121 fi 122 egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1 123 if [ $? -ne 0 ]; then 124 [ -z "$verbose" ] || log_msg_fail "Client connect"; 125 return 1 126 fi 127 egrep "remote_host.*Checking.*/bin" ${CLIENTLOG} >/dev/null 2>&1 128 if [ $? -ne 0 ]; then 129 [ -z "$verbose" ] || log_msg_fail "Client file check"; 130 return 1 131 fi 132 egrep "remote_host.*EXIT.*Samhain" ${CLIENTLOG} >/dev/null 2>&1 133 if [ $? -ne 0 ]; then 134 [ -z "$verbose" ] || log_msg_fail "Client exit"; 135 return 1 136 fi 137 egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1 138 if [ $? -ne 0 ]; then 139 [ -z "$verbose" ] || log_msg_fail "Server exit"; 140 return 1 141 fi 142 143 rm -f ${LOGFILE}.${remhost} 144 return 0 145 } 146 147 do_test_3 () { 148 149 ORIGINAL_1="ExportSeverity=none" 150 REPLACEMENT_1="ExportSeverity=mark" 151 ORIGINAL_2="UseSeparateLogs=yes" 152 REPLACEMENT_2="UseSeparateLogs=no" 153 ORIGINAL_3="LogSeverity=none" 154 REPLACEMENT_3="LogSeverity=debug" 155 ORIGINAL_4="# SetClientTimeLimit=1800" 156 REPLACEMENT_4="SetClientTimeLimit=20" 157 ex $RCFILE <<EOF 158 :%s/${ORIGINAL_1}/${REPLACEMENT_1}/g 159 :%s/${ORIGINAL_2}/${REPLACEMENT_2}/g 160 :%s/${ORIGINAL_3}/${REPLACEMENT_3}/g 161 :%s/${ORIGINAL_4}/${REPLACEMENT_4}/g 162 :wq 163 EOF 164 # :%s is the "ex" substitution command. 165 # :wq is write-and-quit. 166 [ -z "$verbose" ] || { 167 echo; 168 echo "${S}Start Server${E}: ./yule -p none &"; 169 echo; 170 } 171 172 rm -f $LOGFILE 173 174 ./yule -p none >/dev/null 2>&1 & 175 PROC_Y=$! 176 sleep 5 177 178 [ -z "$verbose" ] || { 179 echo; 180 echo "${S}Start Client${E}: ./samhain.new -l none -p none -t check"; 181 echo; 182 } 183 184 ./samhain.new -t check -p none -l none --forever --bind-address=127.0.0.1 >/dev/null 2>&1 & 185 if test x$? = x0; then 186 PROC_S=$! 187 # echo "PID is ${PROC_S}" 188 [ -z "$verbose" ] || log_msg_ok "samhain.new -t check"; 189 sleep 5 190 # Redirect the shells (un-)helpful job monitoring messages. 191 # The 'disown' buildin is not portable. 192 { kill -9 ${PROC_S}; sleep 40; } >/dev/null 2>&1 193 else 194 [ -z "$quiet" ] && log_msg_fail "samhain.new -t check"; 195 kill $PROC_Y 196 return 1 197 fi 198 199 if [ -t 0 ]; then 200 # enable monitor mode again if interactive 201 set -m 202 fi 203 204 205 kill $PROC_Y 206 sleep 5 207 208 egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1 209 if [ $? -ne 0 ]; then 210 [ -z "$verbose" ] || log_msg_fail "Server start"; 211 return 1 212 fi 213 egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1 214 if [ $? -ne 0 ]; then 215 [ -z "$verbose" ] || log_msg_fail "Client connect"; 216 return 1 217 fi 218 egrep "remote_host.*File check completed.*" ${LOGFILE} >/dev/null 2>&1 219 if [ $? -ne 0 ]; then 220 [ -z "$verbose" ] || log_msg_fail "Client file check"; 221 return 1 222 fi 223 egrep "Time limit exceeded" ${LOGFILE} >/dev/null 2>&1 224 if [ $? -ne 0 ]; then 225 [ -z "$verbose" ] || log_msg_fail "Client dead detection"; 226 return 1 227 fi 228 egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1 229 if [ $? -ne 0 ]; then 230 [ -z "$verbose" ] || log_msg_fail "Server exit"; 231 return 1 232 fi 233 234 rm -f ${LOGFILE}.${remhost} 235 return 0 236 } 237 238 testrun2_internal () 60 239 { 61 # 62 # test standalone compilation 63 # 64 echo "${S}Building client and server${E}"; echo; 240 [ -z "$verbose" ] || { 241 echo; 242 echo Working directory: $PW_DIR; echo MAKE is $MAKE; 243 echo; 244 } 245 # 246 # 247 [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; } 65 248 # 66 249 if test -r "Makefile"; then … … 68 251 fi 69 252 # 70 ${TOP_SRCDIR}/configure --quiet $TRUST --enable- network=client --enable-xml-log --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/testrc_2 --with-log-file=$PW_DIR/.samhain_log--with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file --enable-encrypt=271 # 72 if test x$? = x0; then 73 echo "configure completed, exit status 0"; echo;74 $MAKE > /dev/null 253 ${TOP_SRCDIR}/configure --quiet $TRUST --enable-debug --enable-network=client --enable-xml-log --enable-login-watch --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 --enable-encrypt=2 254 # 255 if test x$? = x0; then 256 [ -z "$verbose" ] || log_msg_ok "configure..."; 257 $MAKE > /dev/null 2>>test_log 75 258 if test x$? = x0; then 76 echo "$MAKE completed, exit status $?"; echo;259 [ -z "$verbose" ] || log_msg_ok "make..."; 77 260 else 78 echo "${S}ERROR:${E} make failed, exit status $?"; echo;79 exit261 [ -z "$quiet" ] && log_msg_fail "make..."; 262 return 1 80 263 fi 81 264 82 265 else 83 echo "${S}ERROR:${E} configure failed, exit status $?"; echo;84 exit266 [ -z "$quiet" ] && log_msg_fail "configure..."; 267 return 1 85 268 fi 86 269 87 270 # save binary and build server 88 271 # 89 cp samhain samhain.build 90 make clean 91 92 ${TOP_SRCDIR}/configure --quiet $TRUST --enable-debug --enable-network=server --enable-xml-log --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$ PW_DIR/testrc_2 --with-log-file=$PW_DIR/.samhain_log--with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file --enable-identity=rainer --enable-encrypt=293 # 94 if test x$? = x0; then 95 echo "configure completed, exit status 0"; echo;96 $MAKE > /dev/null 272 cp samhain samhain.build || return 1 273 make clean >/dev/null || return 1 274 275 ${TOP_SRCDIR}/configure --quiet $TRUST --enable-debug --enable-network=server --enable-xml-log --enable-login-watch --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 --enable-identity=rainer --enable-encrypt=2 276 # 277 if test x$? = x0; then 278 [ -z "$verbose" ] || log_msg_ok "configure..."; 279 $MAKE > /dev/null 2>>test_log 97 280 if test x$? = x0; then 98 echo "$MAKE completed, exit status $?"; echo;281 [ -z "$verbose" ] || log_msg_ok "make..."; 99 282 else 100 echo "${S}ERROR:${E} make failed, exit status $?"; echo;101 exit283 [ -z "$quiet" ] && log_msg_fail "make..."; 284 return 1 102 285 fi 103 286 104 287 else 105 echo "${S}ERROR:${E} configure failed, exit status $?"; echo; 106 exit 107 fi 288 [ -z "$quiet" ] && log_msg_fail "configure..."; 289 return 1 290 fi 291 108 292 109 293 ##################################################################### 110 294 # 111 295 # 112 echo "${S}Initialize database${E}"; echo;113 114 296 rm -f ./.samhain_file 115 297 rm -f ./.samhain_log … … 118 300 cp ${SCRIPTDIR}/testrc_2.in testrc_2 119 301 120 echo "./samhain.build -t init" 121 ./samhain.build -t init 122 123 SHINI=$? 302 ./samhain.build -t init -p none 303 304 if test x$? = x0; then 305 [ -z "$verbose" ] || log_msg_ok "init..."; 306 else 307 [ -z "$quiet" ] && log_msg_fail "init..."; 308 return 1 309 fi 124 310 125 311 # Create a password … … 127 313 SHPW=`./yule -G` 128 314 if test x"$SHPW" = x; then 129 echo"password not generated -- aborting"130 exit1315 [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting" 316 return 1 131 317 fi 132 318 133 319 # Set in client 134 320 135 echo "./samhain_setpwd samhain.build new $SHPW" 136 ./samhain_setpwd samhain.build new $SHPW 137 138 mv samhain.build.new samhain.new 321 ./samhain_setpwd samhain.build new $SHPW >/dev/null 322 323 if test x$? = x0; then 324 [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd samhain.build new $SHPW"; 325 else 326 [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd samhain.build new $SHPW"; 327 return 1 328 fi 329 330 mv samhain.build.new samhain.new || return 1 139 331 140 332 rm -f ./.samhain_log.* … … 143 335 SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%` 144 336 337 if test x$? = x0; then 338 [ -z "$verbose" ] || log_msg_ok "yule -P $SHPW"; 339 else 340 [ -z "$quiet" ] && log_msg_fail "yule -P $SHPW"; 341 return 1 342 fi 343 145 344 echo $SHCLT >> testrc_2 146 345 147 if test x$SHINI = x0; then 148 echo; echo "${S}Start Server${E}: ./yule &"; echo; 149 ./yule -l info & 150 PROC_Y=$! 151 sleep 5 152 153 echo; echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check"; 154 155 ./samhain.new -t check -p none -l none -e info 156 if test x$? = x0; then 157 echo "${S}check completed${E}" 158 else 159 echo "${S}ERROR:${E} -- check -- failed, exit status $?" 160 echo 161 kill $PROC_Y 162 exit 163 fi 164 165 kill $PROC_Y 166 sleep 5 167 else 168 echo "${S}ERROR:${E} -- init -- failed, exit status $SHINI"; 169 echo; 170 exit 171 fi 172 173 } 174 175 if test x$1 = x; then 176 echo 177 echo "Please provide the local hostname as argument." 178 echo 179 exit 8 346 do_test_1 347 if [ $? -eq 0 ]; then 348 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client logging"; 349 else 350 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client logging"; 351 fi 352 353 do_test_2 354 if [ $? -eq 0 ]; then 355 [ -z "$quiet" ] && log_ok 2 ${MAXTEST} "Client logging, seperate logfiles"; 356 else 357 [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "Client logging, seperate logfiles"; 358 fi 359 360 do_test_3 361 if [ $? -eq 0 ]; then 362 [ -z "$quiet" ] && log_ok 3 ${MAXTEST} "Dead client detection"; 363 else 364 [ -z "$quiet" ] && log_fail 3 ${MAXTEST} "Dead client detection"; 365 fi 366 367 return $? 368 } 369 370 MAXTEST=3; export MAXTEST 371 372 testrun2 () 373 { 374 log_start "RUN CLIENT/SERVER" 375 376 if [ x"$1" = x ]; then 377 [ -z "$quiet" ] && log_msg_fail "Missing hostname" 180 378 fi 181 379 # 182 380 SH_LOCALHOST=$1; export SH_LOCALHOST 183 184 testrun2 185 186 187 echo; echo "${S}__ END TEST RUN CLIENT/SERVER __${E}"; echo; 188 189 exit 190 381 # 382 testrun2_internal 383 # 384 log_end "RUN CLIENT/SERVER" 385 386 return 0 387 } 388 -
trunk/test/testrun_2a.sh
r1 r19 1 1 #! /bin/sh 2 2 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 15 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 CLIENT/SERVER __${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 46 echo MAKE is $MAKE 47 echo 48 49 50 51 testrun2a () 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 () 52 70 { 53 # 54 # test standalone compilation 55 # 56 echo "${S}Building client and server${E}"; echo; 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; } 57 79 # 58 80 if test -r "Makefile"; then … … 60 82 fi 61 83 # 62 ${TOP_SRCDIR}/configure --quiet $TRUST --enable-debug --enable-network=client --enable-srp --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=localhost --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock 63 # 64 # --disable-encrypt 65 # 66 if test x$? = x0; then 67 echo "configure completed, exit status 0"; echo; 68 $MAKE > /dev/null 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 69 89 if test x$? = x0; then 70 echo "$MAKE completed, exit status $?"; echo;90 [ -z "$verbose" ] || log_msg_ok "make..."; 71 91 else 72 echo "${S}ERROR:${E} make failed, exit status $?"; echo;73 exit92 [ -z "$quiet" ] && log_msg_fail "make..."; 93 return 1 74 94 fi 75 95 76 96 else 77 echo "${S}ERROR:${E} configure failed, exit status $?"; echo;78 exit97 [ -z "$quiet" ] && log_msg_fail "configure..."; 98 return 1 79 99 fi 80 100 81 101 # save binary and build server 82 102 # 83 cp samhain samhain.build 84 make clean 85 86 # 87 ${TOP_SRCDIR}/configure --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 88 # --enable-identity=rainer 89 # --with-libwrap 90 # 91 if test x$? = x0; then 92 echo "configure completed, exit status 0"; echo; 93 $MAKE > /dev/null 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 94 111 if test x$? = x0; then 95 echo "$MAKE completed, exit status $?"; echo;112 [ -z "$verbose" ] || log_msg_ok "make..."; 96 113 else 97 echo "${S}ERROR:${E} make failed, exit status $?"; echo;98 exit114 [ -z "$quiet" ] && log_msg_fail "make..."; 115 return 1 99 116 fi 100 117 101 118 else 102 echo "${S}ERROR:${E} configure failed, exit status $?"; echo; 103 exit 104 fi 105 106 echo "${S}Initialize database${E}"; echo; 107 119 [ -z "$quiet" ] && log_msg_fail "configure..."; 120 return 1 121 fi 122 123 124 ##################################################################### 125 # 126 # 108 127 rm -f ./.samhain_file 109 128 rm -f ./.samhain_log … … 114 133 cp ${SCRIPTDIR}/testrc_2.in testrc_2 115 134 116 echo "./samhain.build -t init" 117 ./samhain.build -t init 118 119 SHINI=$? 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 120 143 121 144 # Create a password … … 123 146 SHPW=`./yule -G` 124 147 if test x"$SHPW" = x; then 125 echo"password not generated -- aborting"126 exit1148 [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting" 149 return 1 127 150 fi 128 151 129 152 # Set in client 130 153 131 echo "./samhain_setpwd samhain.build new $SHPW" 132 ./samhain_setpwd samhain.build new $SHPW 133 134 mv samhain.build.new samhain.new 135 136 rm -f ./.samhain_log 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* 137 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 138 178 139 179 cp ./testrc_2 ./rc.${SH_LOCALHOST} 140 180 mv ./.samhain_file ./file.${SH_LOCALHOST} 141 181 142 SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%` 143 144 echo $SHCLT >> testrc_2 145 146 if test x$SHINI = x0; then 147 echo; echo "${S}Start Server${E}: ./yule &"; echo; 148 ./yule -q & 149 PROC_Y=$! 150 sleep 5 151 152 echo; echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check"; 153 154 ./samhain.new -t check -p none -l none -e info 155 if test x$? = x0; then 156 echo "${S}check completed${E}" 157 else 158 echo "${S}ERROR:${E} -- check -- failed, exit status $?" 159 echo 160 kill $PROC_Y 161 exit 162 fi 163 164 kill $PROC_Y 165 sleep 5 166 else 167 echo "${S}ERROR:${E} -- init -- failed, exit status $SHINI"; 168 echo; 169 exit 170 fi 171 182 ALTHOST=`find_hostname` 183 cp ./testrc_2 "./rc.${ALTHOST}" 184 cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null 185 172 186 } 173 187 174 if test x$1 = x; then 175 echo 176 echo "Please provide the local hostname as argument." 177 echo 178 exit 8 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" 179 196 fi 180 197 # 181 198 SH_LOCALHOST=$1; export SH_LOCALHOST 182 183 testrun2a 184 185 186 echo; echo "${S}__ END TEST RUN CLIENT/SERVER __${E}"; echo; 187 188 exit 189 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 -
trunk/test/testrun_2b.sh
r1 r19 1 1 #! /bin/sh 2 2 3 LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE 4 RCFILE="$PW_DIR/testrc_2"; export RCFILE 5 RCFILE_C="$PW_DIR/testrc_1.dyn"; export RCFILE_C 3 6 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 7 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 15 8 16 PW_DIR=`pwd` 9 CLIENT_BUILDOPTS="--quiet $TRUST --enable-micro-stealth=137 --enable-debug --enable-network=client --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER${RCFILE_C} --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 17 10 18 if test x$UID != x; then 19 TRUST="--with-trusted=0,2,$UID" 20 else 21 TRUST="--with-trusted=0,2" 22 fi 11 testrun2b_internal () 12 { 13 GPG="$1" 23 14 24 TEST_MYSQL= 25 # TEST_MYSQL=" --with-database=mysql --with-libs=-L/usr/local/mysql/lib " 26 export TEST_MYSQL 15 [ -z "$verbose" ] || { 16 echo; 17 echo Working directory: $PW_DIR; echo MAKE is $MAKE; echo GPG is $GPG; 18 echo; 19 } 27 20 28 echo; echo "${S}__ STARTING TEST RUN CLIENT/SERVER W/GPG __${E}"; echo; 29 echo Working directory: $PW_DIR 21 [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; } 30 22 31 MAKE=`which gmake` 32 if test "x$?" = x1 ; then 33 MAKE="make -s" 34 else 35 MAKE=`which gmake | sed -e "s%\([a-z:]\) .*%\1%g"` 36 if test "x$MAKE" = x; then 37 MAKE="make -s" 38 elif test "x$MAKE" = xno; then 39 MAKE="make -s" 23 if test -r "Makefile"; then 24 $MAKE distclean 25 fi 26 27 ${TOP_SRCDIR}/configure --with-gpg=${GPG} --with-checksum=no ${CLIENT_BUILDOPTS} >/dev/null 2>&1 28 29 if test x$? = x0; then 30 [ -z "$verbose" ] || log_msg_ok "configure..."; 31 $MAKE > /dev/null 2>>test_log 32 if test x$? = x0; then 33 [ -z "$verbose" ] || log_msg_ok "make..."; 34 else 35 [ -z "$quiet" ] && log_msg_fail "make..."; 36 return 1 37 fi 40 38 else 41 if test "x$MAKE" = "xwhich:"; then 42 MAKE="make -s" 39 [ -z "$quiet" ] && log_msg_fail "configure..."; 40 return 1 41 fi 42 43 SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ { print NR + 1; exit 0; }' ${SCRIPTDIR}/test.sh` 44 45 tail -n "+$SKIP" ${SCRIPTDIR}/test.sh >/dev/null 2>&1 46 if [ $? -eq 0 ]; then 47 tail -n "+$SKIP" ${SCRIPTDIR}/test.sh | gunzip -c - | tar xf - && \ 48 mv "./testrc.gpg.asc" "${RCFILE_C}" 49 else 50 tail "+$SKIP" ${SCRIPTDIR}/test.sh | gunzip -c - | tar xf - && \ 51 mv "./testrc.gpg.asc" "${RCFILE_C}" 52 fi 53 if test x$? = x0; then 54 [ -z "$verbose" ] || log_msg_ok "extract gpg signed files..."; 55 else 56 [ -z "$quiet" ] && log_msg_fail "extract gpg signed files..."; 57 return 1 58 fi 59 60 # save binary and build server 61 62 cp samhain samhain.build || return 1 63 make clean >/dev/null || return 1 64 65 ${TOP_SRCDIR}/configure ${SERVER_BUILDOPTS} 66 67 if test x$? = x0; then 68 [ -z "$verbose" ] || log_msg_ok "configure..."; 69 $MAKE > /dev/null 2>>test_log 70 if test x$? = x0; then 71 [ -z "$verbose" ] || log_msg_ok "make..."; 43 72 else 44 MAKE="gmake -s"45 gmake -v >/dev/null 2>&1 || MAKE="make -s"73 [ -z "$quiet" ] && log_msg_fail "make..."; 74 return 1 46 75 fi 76 77 else 78 [ -z "$quiet" ] && log_msg_fail "configure..."; 79 return 1 47 80 fi 48 fi 81 82 83 ##################################################################### 84 # 85 # 86 rm -f ./.samhain_file 87 rm -f ./.samhain_log 88 rm -f ./.samhain_lock 89 rm -f ./rc.${SH_LOCALHOST} 90 rm -f ./file.${SH_LOCALHOST} 91 92 cp ${SCRIPTDIR}/testrc_2.in testrc_2 93 94 ./samhain.build -t init -p none 95 96 if test x$? = x0; then 97 [ -z "$verbose" ] || log_msg_ok "init..."; 98 else 99 [ -z "$quiet" ] && log_msg_fail "init..."; 100 return 1 101 fi 102 103 # Create a password 49 104 50 echo MAKE is $MAKE 51 echo 105 SHPW=`./yule -G` 106 if test x"$SHPW" = x; then 107 [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting" 108 return 1 109 fi 110 111 # Set in client 112 113 ./samhain_setpwd samhain.build new $SHPW >/dev/null 114 115 if test x$? = x0; then 116 [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd samhain.build new $SHPW"; 117 else 118 [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd samhain.build new $SHPW"; 119 return 1 120 fi 121 122 mv samhain.build.new samhain.new || return 1 123 124 rm -f ./.samhain_log* 125 rm -f ./.samhain_lock 126 127 SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%` 128 129 if test x$? = x0; then 130 [ -z "$verbose" ] || log_msg_ok "yule -P $SHPW"; 131 else 132 [ -z "$quiet" ] && log_msg_fail "yule -P $SHPW"; 133 return 1 134 fi 135 136 echo $SHCLT >> testrc_2 137 138 cp "${RCFILE_C}" ./rc.${SH_LOCALHOST} 139 mv $PW_DIR/.samhain_file.asc ./file.${SH_LOCALHOST} 52 140 53 # $GPG_PATH _must_ be an absolute path 54 # 55 if test x${GPG_PATH} = x; then 56 GPG_PATH=`which gpg | sed -e "s%\([a-z:]\) .*%\1%g"` 57 fi 141 ALTHOST=`find_hostname` 142 cp ./testrc_2 "./rc.${ALTHOST}" 143 cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null 144 } 58 145 59 if test x${GPG_PATH} = x; then 60 echo "ERROR: gpg (GnuPG) not found" 61 exit 62 else 63 GPG_OK=`echo ${GPG_PATH} | sed -e "s%\(/.*\)%OK%g"` 64 if test x${GPG_OK} = xOK; then 65 echo "GPG_PATH is ${GPG_PATH}" 66 else 67 echo "ERROR: GPG_PATH (${GPG_PATH}) is _not_ an absolute path." 68 echo 69 echo " Apparently the command 'which gpg' did not yield an absolute path." 70 echo " You can fix the problem by setting the environment variable GPG_PATH" 71 echo " to the absolute path to gpg (GnuPG) and start the test again." 72 exit 73 fi 74 fi 75 76 echo 146 MAXTEST=1; export MAXTEST 77 147 78 148 testrun2b () 79 149 { 80 # 81 # test standalone compilation 82 # 83 echo "${S}Building client and server${E}"; echo; 84 # 85 if test -r "Makefile"; then 86 $MAKE distclean 150 log_start "RUN FULL CLIENT/SERVER W/GPG"; 151 # 152 if [ x"$1" = x ]; then 153 [ -z "$quiet" ] && log_msg_fail "Missing hostname" 154 fi 155 # 156 GPG=`find_path gpg` 157 if [ -z "$GPG" ]; then 158 log_skip 1 $MAXTEST 'gpg not found in $PATH' 159 else 160 eval "$GPG" --list-keys 0F571F6C >/dev/null 2>/dev/null 161 if [ $? -ne 0 ]; then 162 log_skip 1 $MAXTEST 'public PGP key 0x0F571F6C not present' 163 else 164 165 SH_LOCALHOST=$1; export SH_LOCALHOST 166 167 testrun2b_internal "$GPG" 168 169 do_test_1_a 170 if [ $? -eq 0 ]; then 171 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client download+logging w/gpg"; 172 else 173 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client download+logging w/gpg"; 174 fi 175 176 if [ -n "$cleanup" ]; then 177 rm -f ./rc.${SH_LOCALHOST} 178 rm -f ./file.${SH_LOCALHOST} 179 ALTHOST=`find_hostname` 180 rm -f "./file.${ALTHOST}" 181 rm -f "./rc.${ALTHOST}" 182 fi 87 183 fi 88 # 89 GPG_HASH=`${GPG_PATH} --load-extension tiger --print-md TIGER192 ${GPG_PATH}` 90 # 91 echo GPG_HASH is ${GPG_HASH} 92 # 93 ${TOP_SRCDIR}/configure --quiet $TRUST --with-gpg=${GPG_PATH} --enable-xml-log --enable-network=client --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2.signed --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=localhost --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock 94 # 95 if test x$? = x0; then 96 echo "configure completed, exit status 0"; echo; 97 $MAKE > /dev/null 98 if test x$? = x0; then 99 echo "$MAKE completed, exit status $?"; echo; 100 else 101 echo "${S}ERROR:${E} make failed, exit status $?"; echo; 102 exit 103 fi 104 105 else 106 echo "${S}ERROR:${E} configure failed, exit status $?"; echo; 107 exit 108 fi 109 110 # save binary and build server 111 # 112 cp samhain samhain.build 113 make clean 114 115 # 116 ${TOP_SRCDIR}/configure --quiet $TRUST --with-gpg=${GPG_PATH} --enable-xml-log ${TEST_MYSQL} --enable-debug --enable-network=server --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2.signed --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 --enable-identity=rainer 117 # 118 if test x$? = x0; then 119 echo "configure completed, exit status 0"; echo; 120 $MAKE > /dev/null 121 if test x$? = x0; then 122 echo "$MAKE completed, exit status $?"; echo; 123 else 124 echo "${S}ERROR:${E} make failed, exit status $?"; echo; 125 exit 126 fi 127 128 else 129 echo "${S}ERROR:${E} configure failed, exit status $?"; echo; 130 exit 131 fi 132 echo "${S}Initialize database${E}"; echo; 133 134 rm -f ./.samhain_file 135 rm -f ./.samhain_log 136 rm -f ./.samhain_lock 137 rm -f ./rc.${SH_LOCALHOST} 138 rm -f ./file.${SH_LOCALHOST} 139 140 cp ${SCRIPTDIR}/testrc_2.in testrc_2.signed 141 142 # Create a password 143 SHPW=`./yule -G` 144 if test x"$SHPW" = x; then 145 echo "password not generated -- aborting" 146 exit 1 147 fi 148 149 # Set in client 150 echo "./samhain_setpwd samhain.build new $SHPW" 151 ./samhain_setpwd samhain.build new $SHPW 152 mv samhain.build.new samhain.new 153 SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%` 154 echo $SHCLT >> testrc_2.signed 155 156 echo "--- You need to sign the config file testrc_2.signed now ---" 157 echo 158 ${GPG_PATH} -a --clearsign --not-dash-escaped $PW_DIR/testrc_2.signed 159 mv $PW_DIR/testrc_2.signed.asc $PW_DIR/testrc_2.signed 160 161 echo "./samhain.new -t init" 162 ./samhain.new -t init 163 164 SHINI=$? 165 166 rm -f ./.samhain_log 167 rm -f ./.samhain_lock 168 169 cp ./testrc_2.signed ./rc.${SH_LOCALHOST} 170 mv ./.samhain_file ./file.${SH_LOCALHOST} 171 172 if test x$SHINI = x0; then 173 echo 174 echo "--- You need to sign the database file.${SH_LOCALHOST} now ---" 175 echo 176 ${GPG_PATH} -a --clearsign --not-dash-escaped $PW_DIR/file.${SH_LOCALHOST} 177 mv $PW_DIR/file.${SH_LOCALHOST}.asc $PW_DIR/file.${SH_LOCALHOST} 178 179 echo; echo "${S}Start Server${E}: ./yule &"; echo; 180 ./yule & 181 PROC_Y=$! 182 sleep 5 183 184 echo; echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check"; 185 186 ./samhain.new -t check -p none -l none -e info 187 if test x$? = x0; then 188 echo "${S}check completed${E}" 189 else 190 echo "${S}ERROR:${E} -- check -- failed, exit status $?" 191 echo 192 kill $PROC_Y 193 exit 194 fi 195 196 kill $PROC_Y 197 sleep 5 198 else 199 echo "${S}ERROR:${E} -- init -- failed, exit status $SHINI"; 200 echo; 201 exit 202 fi 203 184 fi 185 log_end "RUN FULL CLIENT/SERVER W/GPG" 204 186 } 205 187 206 if test x$1 = x; then207 echo208 echo "Please provide the local hostname as argument."209 echo210 exit 8211 fi212 213 SH_LOCALHOST=$1; export SH_LOCALHOST214 215 testrun2b216 217 218 echo; echo "${S}__ END TEST RUN CLIENT/SERVER W/GPG __${E}"; echo;219 220 exit221 -
trunk/test/testrun_2c.sh
r1 r19 1 1 #! /bin/sh 2 2 3 SERVER_BUILDOPTS="--quiet $TRUST --enable-xml-log --enable-debug --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 --with-database=mysql"; export SERVER_BUILDOPTS 3 4 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 5 CLIENT_BUILDOPTS="--quiet $TRUST --prefix=$PW_DIR --localstatedir=$PW_DIR --enable-network=client --disable-mail --disable-external-scripts --enable-login-watch --enable-xml-log --enable-db-reload --with-logserver=localhost --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock"; export CLIENT_BUILDOPTS 15 6 16 PW_DIR=`pwd` 7 check_mysql_log () { 8 DATE="$1" 17 9 18 if test x$UID != x; then 19 TRUST="--with-trusted=0,2,$UID" 20 else 21 TRUST="--with-trusted=0,2" 22 fi 10 rm -f test_log_db 11 echo "SELECT * FROM log WHERE entry_status = 'NEW' and log_time > '"${DATE}"';" | mysql --password=samhain -u samhain samhain >test_log_db 12 # 13 egrep "START.*Yule" test_log_db >/dev/null 2>&1 14 if [ $? -ne 0 ]; then 15 [ -z "$verbose" ] || log_msg_fail "Server start"; 16 return 1 17 fi 18 egrep "NEW CLIENT" test_log_db >/dev/null 2>&1 19 if [ $? -ne 0 ]; then 20 [ -z "$verbose" ] || log_msg_fail "Client connect"; 21 return 1 22 fi 23 egrep "Checking.*/bin" test_log_db >/dev/null 2>&1 24 if [ $? -ne 0 ]; then 25 [ -z "$verbose" ] || log_msg_fail "Client file check"; 26 return 1 27 fi 28 egrep "EXIT.*Samhain" test_log_db >/dev/null 2>&1 29 if [ $? -ne 0 ]; then 30 [ -z "$verbose" ] || log_msg_fail "Client exit"; 31 return 1 32 fi 33 egrep "EXIT.*Yule.*SIGTERM" test_log_db >/dev/null 2>&1 34 if [ $? -ne 0 ]; then 35 [ -z "$verbose" ] || log_msg_fail "Server exit"; 36 return 1 37 fi 38 return 0 39 } 23 40 24 echo; echo "${S}__ STARTING TEST RUN CLIENT/SERVER W/MYSQL __${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 46 echo MAKE is $MAKE 47 echo 48 41 MAXTEST=1; export MAXTEST 49 42 50 43 testrun2c () 51 44 { 52 # 53 # test standalone compilation 54 # 55 echo "${S}Building client and server${E}"; echo; 56 # 57 if test -r "Makefile"; then 58 $MAKE distclean 45 log_start "RUN FULL CLIENT/SERVER W/MYSQL" 46 # 47 if [ -z "$doall" ]; then 48 log_skip 1 $MAXTEST 'Client/server w/mysql (or use --really-all)' 49 return 0 50 fi 51 if [ x"$1" = x ]; then 52 [ -z "$quiet" ] && log_msg_fail "Missing hostname" 53 fi 54 MYSQL=`find_path mysql` 55 if [ -z "$MYSQL" ]; then 56 log_skip 1 $MAXTEST "mysql not found"; 57 return 1 58 else 59 TEST=`echo "DESCRIBE log;" | mysql --password=samhain -u samhain samhain 2>/dev/null` 60 if [ $? -ne 0 -o -z "$TEST" ]; then 61 log_skip 1 $MAXTEST "mysql not default setup" 62 return 1 59 63 fi 60 # 61 # 62 # ${TOP_SRCDIR}/configure --quiet $TRUST --enable-login-watch --enable-xml-log --enable-debug --enable-network=client --enable-srp --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=localhost --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock 63 # 64 ${TOP_SRCDIR}/configure --prefix=$PW_DIR --localstatedir=$PW_DIR --enable-network=client --disable-mail --disable-external-scripts --enable-login-watch --enable-xml-log --enable-db-reload --with-logserver=localhost --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-timeserver=localhost --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock 65 # 66 # 67 if test x$? = x0; then 68 echo "configure completed, exit status 0"; echo; 69 $MAKE > /dev/null 70 if test x$? = x0; then 71 echo "$MAKE completed, exit status $?"; echo; 72 else 73 echo "${S}ERROR:${E} make failed, exit status $?"; echo; 74 exit 75 fi 76 64 fi 65 # 66 SH_LOCALHOST=$1; export SH_LOCALHOST 67 # 68 DATE=`date '+%Y-%m-%d %T'` 69 # 70 testrun2a_internal 71 # 72 ORIGINAL="DatabaseSeverity=none" 73 REPLACEMENT="DatabaseSeverity=info" 74 ex $RCFILE <<EOF 75 :%s/$ORIGINAL/$REPLACEMENT/g 76 :wq 77 EOF 78 # 79 do_test_1_a 80 if [ $? -ne 0 ]; then 81 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client/server w/mysql"; 82 else 83 # 84 check_mysql_log "${DATE}" 85 if [ $? -ne 0 ]; then 86 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client/server w/mysql"; 77 87 else 78 echo "${S}ERROR:${E} configure failed, exit status $?"; echo; 79 exit 88 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client/server w/mysql"; 80 89 fi 81 82 # save binary and build server 83 # 84 cp samhain samhain.build 85 make clean 86 87 # 88 ${TOP_SRCDIR}/configure --quiet $TRUST --enable-xml-log --enable-debug --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 --with-database=mysql 89 90 # --enable-login-watch --enable-mounts-check --enable-userfiles --enable-identity=yule --enable-suidcheck --with-gpg=/usr/local/bin/gpg --with-fp="EF6C EF54 701A 0AFD B86A F4C3 1AAD 26C8 0F57 1F6C" 91 92 # 93 # --with-database=mysql --with-libs=-L/usr/local/mysql/lib 94 # --with-database=postgresql 95 # 96 if test x$? = x0; then 97 echo "configure completed, exit status 0"; echo; 98 $MAKE > /dev/null 99 if test x$? = x0; then 100 echo "$MAKE completed, exit status $?"; echo; 101 else 102 echo "${S}ERROR:${E} make failed, exit status $?"; echo; 103 exit 104 fi 105 106 else 107 echo "${S}ERROR:${E} configure failed, exit status $?"; echo; 108 exit 109 fi 110 echo "${S}Initialize database${E}"; echo; 111 112 rm -f ./.samhain_file 113 rm -f ./.samhain_log 114 rm -f ./.samhain_lock 90 fi 91 # 92 if [ -n "$cleanup" ]; then 115 93 rm -f ./rc.${SH_LOCALHOST} 116 94 rm -f ./file.${SH_LOCALHOST} 117 118 cp ${SCRIPTDIR}/testrc_2.in testrc_2 119 120 # Create a password 121 SHPW=`./yule -G` 122 if test x"$SHPW" = x; then 123 echo "password not generated -- aborting" 124 exit 1 125 fi 126 127 # Set in client 128 echo "./samhain_setpwd samhain.build new $SHPW" 129 ./samhain_setpwd samhain.build new $SHPW 130 mv samhain.build.new samhain.new 131 SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%` 132 echo $SHCLT >> testrc_2 133 134 echo "./samhain.new -t init" 135 ./samhain.new -t init 136 137 SHINI=$? 138 139 rm -f ./.samhain_log 140 rm -f ./.samhain_lock 141 142 cp ./testrc_2 ./rc.${SH_LOCALHOST} 143 mv ./.samhain_file ./file.${SH_LOCALHOST} 144 145 if test x$SHINI = x0; then 146 147 echo; echo "${S}Start Server${E}: ./yule &"; echo; 148 ./yule & 149 PROC_Y=$! 150 sleep 5 151 152 echo; echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check"; 153 154 ./samhain.new -t check -p none -l none -e info 155 if test x$? = x0; then 156 echo "${S}check completed${E}" 157 else 158 echo "${S}ERROR:${E} -- check -- failed, exit status $?" 159 echo 160 kill $PROC_Y 161 exit 162 fi 163 164 kill $PROC_Y 165 sleep 5 166 else 167 echo "${S}ERROR:${E} -- init -- failed, exit status $SHINI"; 168 echo; 169 exit 170 fi 171 95 ALTHOST=`find_hostname` 96 rm -f "./file.${ALTHOST}" 97 rm -f "./rc.${ALTHOST}" 98 fi 99 # 100 log_end "RUN FULL CLIENT/SERVER W/MYSQL" 172 101 } 173 102 174 if test x$1 = x; then175 echo176 echo "Please provide the local hostname as argument."177 echo178 exit 8179 fi180 181 SH_LOCALHOST=$1; export SH_LOCALHOST182 183 testrun2c184 185 186 echo; echo "${S}__ END TEST RUN CLIENT/SERVER W/MYSQL __${E}"; echo;187 188 exit189 -
trunk/test/testrun_2d.sh
r1 r19 1 1 #! /bin/sh 2 2 3 SERVER_BUILDOPTS="--quiet $TRUST --enable-xml-log --enable-debug --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 --with-database=postgresql"; export SERVER_BUILDOPTS 3 4 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 5 CLIENT_BUILDOPTS="--quiet $TRUST --prefix=$PW_DIR --localstatedir=$PW_DIR --enable-network=client --disable-mail --disable-external-scripts --enable-login-watch --enable-xml-log --enable-db-reload --with-logserver=localhost --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock"; export CLIENT_BUILDOPTS 15 6 16 PW_DIR=`pwd` 7 check_psql_log () { 8 DATE="$1" 17 9 18 if test x$UID != x; then 19 TRUST="--with-trusted=0,2,$UID" 20 else 21 TRUST="--with-trusted=0,2" 22 fi 10 rm -f test_log_db 11 PGPASSWORD=samhain; export PGPASSWORD 12 psql -U samhain -d samhain -c "SELECT * FROM log WHERE entry_status = 'NEW' and log_time > '${DATE}';" >test_log_db 13 # 14 egrep "START.*Yule" test_log_db >/dev/null 2>&1 15 if [ $? -ne 0 ]; then 16 [ -z "$verbose" ] || log_msg_fail "Server start"; 17 return 1 18 fi 19 egrep "NEW CLIENT" test_log_db >/dev/null 2>&1 20 if [ $? -ne 0 ]; then 21 [ -z "$verbose" ] || log_msg_fail "Client connect"; 22 return 1 23 fi 24 egrep "Checking.*/bin" test_log_db >/dev/null 2>&1 25 if [ $? -ne 0 ]; then 26 [ -z "$verbose" ] || log_msg_fail "Client file check"; 27 return 1 28 fi 29 egrep "EXIT.*Samhain" test_log_db >/dev/null 2>&1 30 if [ $? -ne 0 ]; then 31 [ -z "$verbose" ] || log_msg_fail "Client exit"; 32 return 1 33 fi 34 egrep "EXIT.*Yule.*SIGTERM" test_log_db >/dev/null 2>&1 35 if [ $? -ne 0 ]; then 36 [ -z "$verbose" ] || log_msg_fail "Server exit"; 37 return 1 38 fi 39 return 0 40 } 23 41 24 echo; echo "${S}__ STARTING TEST RUN CLIENT/SERVER __${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 46 echo MAKE is $MAKE 47 echo 48 49 # --with-database=postgresql 50 # export MYLIB=-L/usr/local/pgsql/lib 51 # export MYINC=-I/usr/local/pgsql/include 52 # export LD_LIBRARY_PATH=/usr/local/pgsql/lib 53 54 # --with-database=mysql 55 # export MYLIB=-L/usr/local/mysql/lib 56 # export MYINC=-I/usr/local/mysql/include 57 # export LD_LIBRARY_PATH=/usr/local/mysql/lib 42 MAXTEST=1; export MAXTEST 58 43 59 44 testrun2d () 60 45 { 61 # 62 # test standalone compilation 63 # 64 echo "${S}Building client and server${E}"; echo; 65 # 66 if test -r "Makefile"; then 67 $MAKE distclean 46 log_start "RUN FULL CLIENT/SERVER W/POSTGRESQL" 47 # 48 if [ -z "$doall" ]; then 49 log_skip 1 $MAXTEST 'Client/server w/postgresql (or use --really-all)' 50 return 0 51 fi 52 if [ x"$1" = x ]; then 53 [ -z "$quiet" ] && log_msg_fail "Missing hostname" 54 fi 55 PSQL=`find_path psql` 56 if [ -z "$PSQL" ]; then 57 log_skip 1 $MAXTEST "psql not found"; 58 return 1 59 else 60 PGPASSWORD="samhain"; export PGPASSWORD 61 TEST=`psql -U samhain -d samhain -c "SELECT * FROM log LIMIT 1;" 2>/dev/null` 62 if [ $? -ne 0 -o -z "$TEST" ]; then 63 log_skip 1 $MAXTEST "psql not default setup" 64 return 1 68 65 fi 69 # 70 ${TOP_SRCDIR}/configure --quiet $TRUST --enable-network=client --enable-xml-log --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/testrc_2 --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file 71 # 72 if test x$? = x0; then 73 echo "configure completed, exit status 0"; echo; 74 $MAKE > /dev/null 75 if test x$? = x0; then 76 echo "$MAKE completed, exit status $?"; echo; 77 else 78 echo "${S}ERROR:${E} make failed, exit status $?"; echo; 79 exit 80 fi 81 66 fi 67 # 68 SH_LOCALHOST=$1; export SH_LOCALHOST 69 # 70 DATE=`date '+%Y-%m-%d %T'` 71 # 72 testrun2a_internal 73 # 74 ORIGINAL="DatabaseSeverity=none" 75 REPLACEMENT="DatabaseSeverity=info" 76 ex $RCFILE <<EOF 77 :%s/$ORIGINAL/$REPLACEMENT/g 78 :wq 79 EOF 80 # 81 do_test_1_a 82 if [ $? -ne 0 ]; then 83 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client/server w/postgresql"; 84 else 85 # 86 check_psql_log "${DATE}" 87 if [ $? -ne 0 ]; then 88 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client/server w/postgresql"; 82 89 else 83 echo "${S}ERROR:${E} configure failed, exit status $?"; echo; 84 exit 90 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client/server w/postgresql"; 85 91 fi 86 87 # save binary and build server 88 # 89 cp samhain samhain.build 90 make clean 91 92 ${TOP_SRCDIR}/configure --quiet $TRUST --enable-network=server --enable-xml-log --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/testrc_2 --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file --enable-udp --enable-identity=rainer 93 # 94 if test x$? = x0; then 95 echo "configure completed, exit status 0"; echo; 96 $MAKE > /dev/null 97 if test x$? = x0; then 98 echo "$MAKE completed, exit status $?"; echo; 99 else 100 echo "${S}ERROR:${E} make failed, exit status $?"; echo; 101 exit 102 fi 103 104 else 105 echo "${S}ERROR:${E} configure failed, exit status $?"; echo; 106 exit 107 fi 108 109 ################################################################# 110 # 111 # 112 echo "${S}Initialize database${E}"; echo; 113 114 rm -f ./.samhain_file 115 rm -f ./.samhain_log 116 rm -f ./.samhain_lock 117 118 cp ${SCRIPTDIR}/testrc_2.in testrc_2 119 120 echo "./samhain.build -t init" 121 ./samhain.build -t init 122 123 SHINI=$? 124 125 # Create a password 126 127 SHPW=`./yule -G 2>&1 | grep -v 'ERRO'` 128 if test x"$SHPW" = x; then 129 echo "password not generated -- aborting" 130 exit 1 131 fi 132 133 # Set in client 134 135 echo "./samhain_setpwd samhain.build new $SHPW" 136 ./samhain_setpwd samhain.build new $SHPW 137 138 mv samhain.build.new samhain.new 139 140 rm -f ./.samhain_log 141 rm -f ./.samhain_lock 142 143 SHCLT=`./yule -P $SHPW 2>&1 | grep -v 'ERRO' | sed s%HOSTNAME%${SH_LOCALHOST}%` 144 145 echo $SHCLT >> testrc_2 146 147 if test x$SHINI = x0; then 148 echo; echo "${S}Start Server${E}: ./yule &"; echo; 149 su -c "./yule &" 150 PROC_Y=$! 151 sleep 5 152 153 echo; echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check"; 154 155 ./samhain.new -t check -p none -l none -e info 156 if test x$? = x0; then 157 echo "${S}check completed${E}" 158 else 159 echo "${S}ERROR:${E} -- check -- failed, exit status $?" 160 echo 161 su -c "kill $PROC_Y" 162 exit 163 fi 164 165 su -c "kill $PROC_Y" 166 sleep 5 167 else 168 echo "${S}ERROR:${E} -- init -- failed, exit status $SHINI"; 169 echo; 170 exit 171 fi 172 92 fi 93 # 94 if [ -n "$cleanup" ]; then 95 rm -f ./rc.${SH_LOCALHOST} 96 rm -f ./file.${SH_LOCALHOST} 97 ALTHOST=`find_hostname` 98 rm -f "./file.${ALTHOST}" 99 rm -f "./rc.${ALTHOST}" 100 fi 101 # 102 log_end "RUN FULL CLIENT/SERVER W/POSTGRESQL" 173 103 } 174 104 175 if test x$1 = x; then176 echo177 echo "Please provide the local hostname as argument."178 echo179 exit 8180 fi181 182 SH_LOCALHOST=$1; export SH_LOCALHOST183 184 testrun2d185 186 187 echo; echo "${S}__ END TEST RUN CLIENT/SERVER __${E}"; echo;188 189 exit190 -
trunk/test/testtimesrv.sh
r1 r19 1 1 #! /bin/sh 2 2 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 15 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 TIMESERVER OPTION __${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 46 echo MAKE is $MAKE 47 echo 48 49 50 testtime0 () 51 { 3 RCFILE="$PW_DIR/testrc_1.dyn"; export RCFILE 4 LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE 5 PIDFILE="$PW_DIR/.samhain_lock"; export PIDFILE 6 7 BASE="${PW_DIR}/testrun_testdata"; export BASE 8 TDIRS="a b c a/a a/b a/c a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c"; export TDIRS 9 TFILES="x y z"; export TFILES 10 11 prep_testdata () 12 { 13 chmod -R 0700 "${BASE}" || { 14 [ -z "$quiet" ] && log_msg_fail "chmod -R 0700 ${BASE}"; 15 return 1; 16 } 17 18 rm -rf "${BASE}" || { 19 [ -z "$quiet" ] && log_msg_fail "rm -rf ${BASE}"; 20 return 1; 21 } 22 23 mkdir "${BASE}" || { 24 [ -z "$quiet" ] && log_msg_fail "mkdir ${BASE}"; 25 return 1; 26 } 27 28 for ff in $TDIRS; do 29 mkdir "${BASE}/${ff}" || { 30 [ -z "$quiet" ] && log_msg_fail "mkdir ${BASE}/${ff}"; 31 return 1; 32 } 33 chmod 0755 "${BASE}/${ff}" 34 for gg in $TFILES; do 35 echo "This is a test file" > "${BASE}/${ff}/${gg}" 36 chmod 0644 "${BASE}/${ff}/${gg}" 37 done 38 done 39 } 40 41 mkconfig_misc () 42 { 43 test -f "${RCFILE}" || touch "${RCFILE}" 44 cat >> "${RCFILE}" <<End-of-data 45 [Misc] 46 Daemon=no 47 SetFilecheckTime=60 48 TrustedUser=uucp,fax,fnet 49 SetRecursionLevel=10 50 SetLoopTime=30 51 ReportFullDetail = no 52 ChecksumTest=check 53 54 End-of-data 55 } 56 57 mkconfig_log () 58 { 59 test -f "${RCFILE}" || touch "${RCFILE}" 60 cat >> "${RCFILE}" <<End-of-data 61 [Log] 62 MailSeverity=none 63 LogSeverity=warn 64 SyslogSeverity=none 65 PrintSeverity=info 66 MailSeverity=none 67 #Restrict to certain classes of messages 68 #LogClass=RUN 69 #PreludeSeverity=err 70 #ExportSeverity=none 71 72 End-of-data 73 } 74 75 mkconfig_sev () 76 { 77 test -f "${RCFILE}" || touch "${RCFILE}" 78 cat >> "${RCFILE}" <<End-of-data 79 [EventSeverity] 80 SeverityUser0=crit 81 SeverityUser1=crit 82 SeverityReadOnly=crit 83 SeverityLogFiles=crit 84 SeverityGrowingLogs=crit 85 SeverityIgnoreNone=crit 86 SeverityAttributes=crit 87 SeverityIgnoreAll=crit 88 SeverityFiles=err 89 SeverityDirs=err 90 SeverityNames=warn 91 92 End-of-data 93 } 94 95 prep_init () 96 { 97 rm -f ./.samhain_file 98 rm -f "${LOGFILE}" 99 rm -f ./.samhain_lock 100 101 rm -f "${RCFILE}" 102 mkconfig_sev 103 mkconfig_log 104 mkconfig_misc 105 } 106 107 TESTPOLICY=" 108 [ReadOnly] 109 dir=${BASE}/c 110 [Attributes] 111 dir=${BASE}/a 112 #dir=${BASE}/b 113 " 114 115 116 testtime0_int () 117 { 118 [ -z "$verbose" ] || echo Working directory: $PW_DIR 119 [ -z "$verbose" ] || { echo MAKE is $MAKE; echo; } 52 120 # 53 121 # standalone compilation 54 122 # 55 echo "${S}Building standalone agent w/timeserver${E}"; echo;123 [ -z "$verbose" ] || { echo; echo "${S}Building standalone agent w/timeserver${E}"; echo; } 56 124 # 57 125 if test -r "Makefile"; then 58 $MAKE distclean 126 $MAKE distclean >/dev/null 59 127 fi 60 128 # 61 ${TOP_SRCDIR}/configure --quiet --enable-debug -- prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/test/testrc_1 --with-timeserver=www.foo.bar --with-alttimeserver=127.0.0.1 --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock--with-data-file=$PW_DIR/.samhain_file129 ${TOP_SRCDIR}/configure --quiet --enable-debug --enable-xml-log --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$LOGFILE --with-pid-file=$PIDFILE --with-data-file=$PW_DIR/.samhain_file 62 130 # 63 131 if test x$? = x0; then 64 echo "configure completed, exit status 0"; echo;132 [ -z "$verbose" ] || log_msg_ok "configure..."; 65 133 $MAKE > /dev/null 66 echo "$MAKE completed, exit status $?"; echo; 134 if test x$? = x0; then 135 [ -z "$verbose" ] || log_msg_ok "make..."; 136 else 137 [ -z "$quiet" ] && log_msg_fail "make..."; 138 return 1 139 fi 67 140 else 68 echo "ERROR: configure failed"; echo; 69 fi 70 71 72 rm -f $PW_DIR/.samhain_file $PW_DIR/.samhain_log $PW_DIR/.samhain_lock 73 74 ./samhain -t init 141 [ -z "$quiet" ] && log_msg_fail "configure..."; 142 return 1 143 fi 144 145 prep_init && prep_testdata && echo "$TESTPOLICY" >>$RCFILE 146 if [ $? -ne 0 ]; then 147 [ -z "$quiet" ] && log_msg_fail "prepare..."; 148 return 1 149 fi 150 151 ./samhain -t init -p none 75 152 76 153 if test x$? = x0; then 77 echo 78 echo "${S}init completed${E}" 79 echo 80 ./samhain -t check 81 if test x$? = x0; then 82 echo "${S}check completed${E}" 83 else 84 echo "${S}ERROR:${E} -- check -- failed, exit status $?" 85 echo 86 exit 87 fi 154 [ -z "$verbose" ] || log_msg_ok "init..."; 88 155 else 89 echo "${S}ERROR:${E} -- init -- failed, exit status $?"; echo; 90 exit 91 fi 92 93 } 94 95 96 97 testtime0 98 99 100 echo; echo "${S}__ END TEST TIMESERVER OPTION __${E}"; echo; 101 102 exit 103 156 [ -z "$quiet" ] && log_msg_fail "init..."; 157 return 1 158 fi 159 160 chmod 0555 "${BASE}/a/x" 161 chmod 0555 "${BASE}/b/x" 162 163 ./samhain -t check -p none -l info -D 164 165 count=0 166 until [ -f $PIDFILE ]; do 167 sleep 1 168 let "count = count + 1" >/dev/null 169 if [ $count -gt 12 ]; then 170 break; 171 fi 172 done 173 174 if test x$? = x0; then 175 [ -z "$verbose" ] || log_msg_ok "start daemon..."; 176 else 177 [ -z "$quiet" ] && log_msg_fail "start daemon..."; 178 return 1 179 fi 180 181 return 0 182 } 183 184 MAXTEST=14; export MAXTEST 185 186 die () { 187 test -z "$stoponerr" && return 0; 188 PID=`cat $PIDFILE` 189 kill -9 $PID 190 } 191 192 killdaemon () { 193 if [ -f $PIDFILE ]; then 194 PID=`cat $PIDFILE` 195 kill -9 $PID 196 fi 197 } 198 199 check_err () { 200 if [ ${2} -ne 0 ]; then 201 die; 202 [ -z "$quiet" ] && log_fail ${1} ${MAXTEST} "${3}"; 203 return 1 204 else 205 [ -z "$quiet" ] && log_ok ${1} ${MAXTEST} "${3}"; 206 fi 207 } 208 209 daemontest_started () { 210 PID=`cat $PIDFILE` 211 212 kill -0 $PID 213 check_err ${1} $? "started" 214 } 215 216 daemontest_sigterm () { 217 PID=`cat $PIDFILE` 218 219 kill -15 $PID 220 count=0 221 while [ `kill -0 $PID` ]; do 222 sleep 1 223 let "count = count + 1" >/dev/null 224 if [ $count -gt 12 ]; then 225 check_err ${1} 1 "sigterm" 226 return 1 227 fi 228 done 229 check_err ${1} 0 "sigterm" 230 } 231 232 daemontest_sigusr2 () { 233 PID=`cat $PIDFILE` 234 235 tmp=`grep 'File check completed' $LOGFILE | wc -l` 236 kill -USR2 $PID 237 kill -TTOU $PID 238 239 count=0 240 tmp2=`grep 'SUSPEND' $LOGFILE | wc -l` 241 while [ $tmp2 -ne $2 ]; do 242 sleep 1 243 let "count = count + 1" >/dev/null 244 if [ $count -gt 12 ]; then 245 check_err ${1} 1 "sigusr2: suspend" 246 return 1 247 fi 248 tmp2=`grep 'SUSPEND' $LOGFILE | wc -l` 249 done 250 251 kill -USR2 $PID 252 253 count=0 254 tmp2=$tmp 255 while [ $tmp2 -eq $tmp ]; do 256 sleep 1 257 let "count = count + 1" >/dev/null 258 if [ $count -gt 12 ]; then 259 check_err ${1} 1 "sigusr2: wakeup" 260 return 1 261 fi 262 tmp2=`grep 'File check completed' $LOGFILE | wc -l` 263 done 264 check_err ${1} 0 "sigusr2" 265 } 266 267 daemontest_sigttou () { 268 PID=`cat $PIDFILE` 269 270 tmp=`grep 'File check completed' $LOGFILE | wc -l` 271 kill -TTOU $PID 272 count=0 273 tmp2=$tmp 274 while [ $tmp2 -eq $tmp ]; do 275 sleep 1 276 let "count = count + 1" >/dev/null 277 if [ $count -gt 12 ]; then 278 check_err ${1} 1 "sigttou" 279 return 1 280 fi 281 tmp2=`grep 'File check completed' $LOGFILE | wc -l` 282 done 283 check_err ${1} 0 "sigttou" 284 } 285 286 daemontest_sighup () { 287 288 if [ $2 -eq 1 ]; then 289 echo "dir=${BASE}/b" >>$RCFILE 290 tmp=`grep CRIT $LOGFILE | grep -v Runtime | wc -l` 291 if [ $tmp -ne 1 ]; then 292 [ -z "$verbose" ] || log_msg_fail "policy count (before)"; 293 return 1 294 fi 295 fi 296 297 PID=`cat $PIDFILE` 298 kill -HUP $PID 299 300 if [ $2 -eq 1 ]; then 301 kill -TTOU $PID 302 count=0 303 tmp=`grep CRIT $LOGFILE | grep -v Runtime | wc -l` 304 while [ $tmp -lt 2 ]; do 305 sleep 1 306 if [ $count -gt 12 ]; then 307 [ -z "$verbose" ] || log_msg_fail "policy count (after)"; 308 return 1 309 fi 310 tmp=`grep CRIT $LOGFILE | grep -v Runtime | wc -l` 311 done 312 fi 313 314 count=0 315 tmp2=0 316 while [ $tmp2 -ne $2 ]; do 317 sleep 1 318 let "count = count + 1" >/dev/null 319 if [ $count -gt 12 ]; then 320 check_err ${1} 1 "sighup" 321 return 1 322 fi 323 tmp2=`grep 'Runtime configuration reloaded' $LOGFILE | wc -l` 324 done 325 check_err ${1} 0 "sighup" 326 } 327 328 daemontest_sigabrt () { 329 PID=`cat $PIDFILE` 330 kill -ABRT $PID 331 332 count=0 333 while [ -f $LOGFILE.lock ]; do 334 sleep 1 335 let "count = count + 1" >/dev/null 336 if [ $count -gt 12 ]; then 337 check_err ${1} 1 "sigabrt" 338 return 1 339 fi 340 done 341 342 kill -TTOU $PID 343 344 sleep 4 345 346 if [ -f $LOGFILE.lock ]; then 347 tmp=`grep '<trail>' $LOGFILE | wc -l` 348 tst=$2; let "tst = tst + 2" >/dev/null; 349 if [ $tmp -eq $tst ]; then 350 check_err ${1} 0 "sigabrt" 351 return 0 352 fi 353 fi 354 check_err ${1} 1 "sigabrt" 355 } 356 357 testtime0 () { 358 log_start "DAEMON CONTROL" 359 360 testtime0_int; 361 362 tcount=1 363 364 trap 'killdaemon' 1 3 15 365 366 daemontest_started $tcount; 367 368 let "tcount = tcount + 1" >/dev/null 369 daemontest_sigttou $tcount; 370 let "tcount = tcount + 1" >/dev/null 371 daemontest_sigttou $tcount; 372 let "tcount = tcount + 1" >/dev/null 373 daemontest_sigttou $tcount; 374 375 let "tcount = tcount + 1" >/dev/null 376 daemontest_sigusr2 $tcount 1; 377 let "tcount = tcount + 1" >/dev/null 378 daemontest_sigusr2 $tcount 2; 379 let "tcount = tcount + 1" >/dev/null 380 daemontest_sigusr2 $tcount 3; 381 382 let "tcount = tcount + 1" >/dev/null 383 daemontest_sigabrt $tcount 1; 384 let "tcount = tcount + 1" >/dev/null 385 daemontest_sigabrt $tcount 2; 386 let "tcount = tcount + 1" >/dev/null 387 daemontest_sigabrt $tcount 3; 388 389 let "tcount = tcount + 1" >/dev/null 390 daemontest_sighup $tcount 1; 391 let "tcount = tcount + 1" >/dev/null 392 daemontest_sighup $tcount 2; 393 let "tcount = tcount + 1" >/dev/null 394 daemontest_sighup $tcount 3; 395 396 let "tcount = tcount + 1" >/dev/null 397 daemontest_sigterm $tcount; 398 399 log_end "DAEMON CONTROL" 400 } 401 402
Note:
See TracChangeset
for help on using the changeset viewer.