- Timestamp:
- Oct 30, 2007, 12:17:00 AM (17 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/samhain.c
r140 r142 704 704 for (modnum = 0; modList[modnum].name != NULL; ++modnum) 705 705 { 706 if (modList[modnum].initval == GOOD)706 if (modList[modnum].initval == SH_MOD_ACTIVE) 707 707 (void) modList[modnum].mod_cleanup(); 708 708 } 709 #ifdef HAVE_PTHREAD 710 sh_pthread_cancel_all(); 711 #endif 709 712 #endif 710 713 … … 1637 1640 for (modnum = 0; modList[modnum].name != NULL; ++modnum) 1638 1641 { 1639 if ( 0 != (status = modList[modnum].mod_init(&(modList[modnum]))) ) 1642 status = modList[modnum].mod_init(&(modList[modnum])); 1643 if ( status < 0 ) 1640 1644 { 1641 1645 if (status == (-1)) { … … 1649 1653 status); 1650 1654 } 1651 modList[modnum].initval = S _FALSE;1655 modList[modnum].initval = SH_MOD_FAILED; 1652 1656 } 1653 1657 else … … 1655 1659 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_MOD_OK, 1656 1660 _(modList[modnum].name)); 1657 modList[modnum].initval = S_TRUE;1661 modList[modnum].initval = status; 1658 1662 } 1659 1663 } … … 1744 1748 for (modnum = 0; modList[modnum].name != NULL; ++modnum) 1745 1749 { 1746 if (modList[modnum].initval == GOOD)1750 if (modList[modnum].initval >= SH_MOD_ACTIVE) 1747 1751 (void) modList[modnum].mod_reconf(); 1748 1752 } … … 1795 1799 for (modnum = 0; modList[modnum].name != NULL; ++modnum) 1796 1800 { 1797 if (0 != (status = modList[modnum].mod_init(&(modList[modnum])))) 1801 status = modList[modnum].mod_init(&(modList[modnum])); 1802 1803 if (status < 0) 1798 1804 { 1799 1805 if (status == (-1)) { … … 1808 1814 status); 1809 1815 } 1810 modList[modnum].initval = S _FALSE;1816 modList[modnum].initval = SH_MOD_FAILED; 1811 1817 } 1812 1818 else … … 1814 1820 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_MOD_OK, 1815 1821 _(modList[modnum].name)); 1816 modList[modnum].initval = S_TRUE;1822 modList[modnum].initval = status; 1817 1823 } 1818 1824 } … … 2025 2031 for (modnum = 0; modList[modnum].name != NULL; ++modnum) 2026 2032 { 2027 if (modList[modnum].initval == GOOD&&2033 if (modList[modnum].initval == SH_MOD_ACTIVE && 2028 2034 0 != modList[modnum].mod_timer(tcurrent)) 2029 2035 if (0 != (status = modList[modnum].mod_check())) -
trunk/src/sh_error.c
r140 r142 20 20 #include "config_xor.h" 21 21 22 /* required on linux to get the correct strerror_r function 22 /* Required on linux to get the correct strerror_r function. Also 23 * for recursive mutexes (_XOPEN_SOURCE >= 500). 23 24 */ 24 25 #define _XOPEN_SOURCE 600 -
trunk/src/sh_modules.c
r140 r142 21 21 { 22 22 N_("UTMP"), 23 0,23 -1, 24 24 sh_utmp_init, 25 25 sh_utmp_timer, … … 37 37 { 38 38 N_("MOUNTS"), 39 0,39 -1, 40 40 sh_mounts_init, 41 41 sh_mounts_timer, … … 53 53 { 54 54 N_("USERFILES"), 55 0,55 -1, 56 56 sh_userfiles_init, 57 57 sh_userfiles_timer, … … 69 69 { 70 70 N_("KERNEL"), 71 0,71 -1, 72 72 sh_kern_init, 73 73 sh_kern_timer, … … 85 85 { 86 86 N_("SUIDCHECK"), 87 0,87 -1, 88 88 sh_suidchk_init, 89 89 sh_suidchk_timer, … … 101 101 { 102 102 N_("PROCESSCHECK"), 103 0,103 -1, 104 104 sh_prochk_init, 105 105 sh_prochk_timer, … … 117 117 { 118 118 N_("PORTCHECK"), 119 0,119 -1, 120 120 sh_portchk_init, 121 121 sh_portchk_timer, … … 132 132 { 133 133 NULL, 134 0,134 -1, 135 135 136 136 NULL, -
trunk/src/sh_pthread.c
r141 r142 40 40 41 41 /* MODULES: init() 42 * -- starts thread_run() function if threaded 43 * -- fallback on internal_init if threading fails 44 * -- and returns MODULE_INACTIVE/MODULE_ACTIVE/MODULE_THREADED 45 * 46 * int retval = MODULE_INACTIVE; 47 * if (0 != sh_pthread_create(thread_run, NULL)) 48 * return internal_init(); 49 * return MODULE_THREADED; 50 * 51 * thread_run() 42 * 43 * #ifdef HAVE_PTHREAD 44 * if (arg != NULL) 45 * { 46 * if (0 == sh_pthread_create(sh_threaded_module_run, (void *)arg)) 47 * return SH_MOD_THREAD; 48 * else 49 * return SH_MOD_FAILED; 50 * } 51 * #else 52 * return sh_utmp_init_internal(); 53 * #endif 54 * 55 * 56 * sh_threaded_module_run(module_struct) 52 57 * -- calls internal init, 53 58 * -- polls timer, … … 131 136 /* ---- Utility functions for modules ---- 132 137 */ 133 void sh_threaded_module_ reconf(void *arg)138 void sh_threaded_module_cleanup(void *arg) 134 139 { 135 140 sh_mtype * this_module = (sh_mtype *) arg; 136 this_module->mod_ reconf();141 this_module->mod_cleanup(); 137 142 return; 138 143 } 139 144 140 void sh_threaded_module_run(void *arg)145 void * sh_threaded_module_run(void *arg) 141 146 { 142 147 sh_mtype * this_module = (sh_mtype *) arg; … … 153 158 if (0 == this_module->mod_init(NULL)) 154 159 { 155 pthread_cleanup_push(sh_threaded_module_ reconf, arg);160 pthread_cleanup_push(sh_threaded_module_cleanup, arg); 156 161 157 162 while (1) … … 159 164 if (0 != this_module->mod_timer(time(NULL))) 160 165 { 161 this_module->mod_check(); 166 /* If module has been de-activated on reconfigure, 167 * mod_check() must return non-zero. 168 * The mod_cleanup() routine must then enable the 169 * module to be re-activated eventually. 170 */ 171 if (0 != this_module->mod_check()) 172 break; 162 173 pthread_testcancel(); 163 174 retry_msleep(1,0); … … 171 182 pthread_cleanup_pop(1); 172 183 173 return ;184 return NULL; 174 185 } 175 186 -
trunk/src/sh_utmp.c
r140 r142 455 455 static struct log_user * userlist = NULL; 456 456 static time_t lastcheck; 457 static int init_done = 0; 457 458 458 459 /************* … … 461 462 * 462 463 *************/ 463 int sh_utmp_init (struct mod_type * arg) 464 { 465 static int done = 0; 466 (void) arg; 464 465 static int sh_utmp_init_internal () 466 { 467 467 468 468 SL_ENTER(_("sh_utmp_init")); … … 472 472 /* do not re-initialize after a re-configuration 473 473 */ 474 if ( done == 1) {474 if (init_done == 1) { 475 475 SL_RETURN( (0), _("sh_utmp_init")); 476 476 } … … 480 480 sh_utmp_check_internal (2); /* current logins */ 481 481 sh_utmp_check_internal (0); 482 done = 1;482 init_done = 1; 483 483 SL_RETURN( (0), _("sh_utmp_init")); 484 } 485 486 int sh_utmp_init (struct mod_type * arg) 487 { 488 if (ShUtmpActive == BAD) 489 return SH_MOD_FAILED; 490 #ifdef HAVE_PTHREAD 491 if (arg != NULL && arg->initval < 0) 492 { 493 if (0 == sh_pthread_create(sh_threaded_module_run, (void *)arg)) 494 return SH_MOD_THREAD; 495 else 496 return SH_MOD_FAILED; 497 } 498 #endif 499 return sh_utmp_init_internal(); 484 500 } 485 501 … … 509 525 (void) sh_utmp_login_clean(); 510 526 #endif 527 /* Reset the flag, such that the module 528 * can be re-enabled. 529 */ 530 ShUtmpActive = S_TRUE; 531 init_done = 0; 511 532 SL_RETURN( (0), _("sh_utmp_end")); 512 533 } … … 536 557 { 537 558 SL_ENTER(_("sh_utmp_check")); 559 if (ShUtmpActive == BAD) 560 SL_RETURN( (-1), _("sh_utmp_check")); 538 561 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_UT_CHECK); 539 562 sh_utmp_check_internal (1);
Note:
See TracChangeset
for help on using the changeset viewer.