- Timestamp:
- Oct 29, 2007, 1:09:10 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile.in
r138 r140 1638 1638 sh_unix.o: $(srcsrc)/sh_unix.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_mem.h $(srcinc)/sh_hash.h $(srcinc)/sh_tools.h $(srcinc)/sh_tiger.h $(srcinc)/sh_prelink.h $(srcinc)/sh_pthread.h $(srcinc)/sh_static.h $(srcinc)/sh_prelude.h $(srcinc)/sh_ignore.h 1639 1639 sh_utils.o: $(srcsrc)/sh_utils.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_entropy.h $(srcinc)/sh_pthread.h 1640 sh_error.o: $(srcsrc)/sh_error.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_cat.h $(srcinc)/sh_database.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_mail.h $(srcinc)/sh_forward.h $(srcinc)/sh_prelude.h $(srcinc)/sh_ tools.h $(srcinc)/sh_extern.h1640 sh_error.o: $(srcsrc)/sh_error.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_cat.h $(srcinc)/sh_database.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_mail.h $(srcinc)/sh_forward.h $(srcinc)/sh_prelude.h $(srcinc)/sh_pthread.h $(srcinc)/sh_tools.h $(srcinc)/sh_extern.h 1641 1641 sh_files.o: $(srcsrc)/sh_files.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_tiger.h $(srcinc)/sh_hash.h $(srcinc)/sh_ignore.h $(srcinc)/zAVLTree.h 1642 1642 sh_getopt.o: $(srcsrc)/sh_getopt.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_getopt.h $(srcinc)/sh_files.h $(srcinc)/sh_utils.h $(srcinc)/sh_mail.h $(srcinc)/sh_forward.h $(srcinc)/sh_hash.h $(srcinc)/sh_extern.h … … 1652 1652 sh_entropy.o: $(srcsrc)/sh_entropy.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_calls.h $(srcinc)/sh_pthread.h $(srcinc)/sh_static.h $(srcinc)/sh_pthread.h 1653 1653 sh_forward.o: $(srcsrc)/sh_forward.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_tiger.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_forward.h $(srcinc)/sh_srp.h $(srcinc)/sh_fifo.h $(srcinc)/sh_tools.h $(srcinc)/sh_entropy.h $(srcinc)/sh_html.h $(srcinc)/sh_mail.h $(srcinc)/sh_socket.h $(srcinc)/sh_static.h $(srcinc)/rijndael-api-fst.h $(srcinc)/sh_readconf.h $(srcinc)/zAVLTree.h $(srcinc)/sh_extern.h 1654 sh_modules.o: $(srcsrc)/sh_modules.c Makefile config_xor.h $(srcinc)/sh_modules.h $(srcinc)/sh_ utmp.h $(srcinc)/sh_mounts.h $(srcinc)/sh_userfiles.h $(srcinc)/sh_kern.h $(srcinc)/sh_suidchk.h $(srcinc)/sh_processcheck.h $(srcinc)/sh_portcheck.h1654 sh_modules.o: $(srcsrc)/sh_modules.c Makefile config_xor.h $(srcinc)/sh_modules.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utmp.h $(srcinc)/sh_mounts.h $(srcinc)/sh_userfiles.h $(srcinc)/sh_kern.h $(srcinc)/sh_suidchk.h $(srcinc)/sh_processcheck.h $(srcinc)/sh_portcheck.h 1655 1655 sh_utmp.o: $(srcsrc)/sh_utmp.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_utmp.h 1656 1656 sh_kern.o: $(srcsrc)/sh_kern.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_kern.h sh_ks_xor.h $(srcinc)/sh_unix.h $(srcinc)/sh_hash.h … … 1697 1697 sh_processcheck.o: $(srcsrc)/sh_processcheck.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_modules.h $(srcinc)/sh_processcheck.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_extern.h $(srcinc)/sh_calls.h $(srcinc)/CuTest.h 1698 1698 sh_portcheck.o: $(srcsrc)/sh_portcheck.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_mem.h $(srcinc)/sh_calls.h $(srcinc)/sh_utils.h $(srcinc)/sh_modules.h $(srcinc)/sh_pthread.h $(srcinc)/CuTest.h 1699 sh_pthread.o: $(srcsrc)/sh_pthread.c Makefile config_xor.h $(srcinc)/sh_pthread.h 1699 sh_pthread.o: $(srcsrc)/sh_pthread.c Makefile config_xor.h $(srcinc)/sh_pthread.h $(srcinc)/sh_modules.h $(srcinc)/sh_calls.h -
trunk/depend.dep
r138 r140 4 4 sh_unix.o: $(srcsrc)/sh_unix.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_mem.h $(srcinc)/sh_hash.h $(srcinc)/sh_tools.h $(srcinc)/sh_tiger.h $(srcinc)/sh_prelink.h $(srcinc)/sh_pthread.h $(srcinc)/sh_static.h $(srcinc)/sh_prelude.h $(srcinc)/sh_ignore.h 5 5 sh_utils.o: $(srcsrc)/sh_utils.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_entropy.h $(srcinc)/sh_pthread.h 6 sh_error.o: $(srcsrc)/sh_error.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_cat.h $(srcinc)/sh_database.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_mail.h $(srcinc)/sh_forward.h $(srcinc)/sh_prelude.h $(srcinc)/sh_ tools.h $(srcinc)/sh_extern.h6 sh_error.o: $(srcsrc)/sh_error.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_cat.h $(srcinc)/sh_database.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_mail.h $(srcinc)/sh_forward.h $(srcinc)/sh_prelude.h $(srcinc)/sh_pthread.h $(srcinc)/sh_tools.h $(srcinc)/sh_extern.h 7 7 sh_files.o: $(srcsrc)/sh_files.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_tiger.h $(srcinc)/sh_hash.h $(srcinc)/sh_ignore.h $(srcinc)/zAVLTree.h 8 8 sh_getopt.o: $(srcsrc)/sh_getopt.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_getopt.h $(srcinc)/sh_files.h $(srcinc)/sh_utils.h $(srcinc)/sh_mail.h $(srcinc)/sh_forward.h $(srcinc)/sh_hash.h $(srcinc)/sh_extern.h … … 18 18 sh_entropy.o: $(srcsrc)/sh_entropy.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_calls.h $(srcinc)/sh_pthread.h $(srcinc)/sh_static.h $(srcinc)/sh_pthread.h 19 19 sh_forward.o: $(srcsrc)/sh_forward.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_tiger.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_forward.h $(srcinc)/sh_srp.h $(srcinc)/sh_fifo.h $(srcinc)/sh_tools.h $(srcinc)/sh_entropy.h $(srcinc)/sh_html.h $(srcinc)/sh_mail.h $(srcinc)/sh_socket.h $(srcinc)/sh_static.h $(srcinc)/rijndael-api-fst.h $(srcinc)/sh_readconf.h $(srcinc)/zAVLTree.h $(srcinc)/sh_extern.h 20 sh_modules.o: $(srcsrc)/sh_modules.c Makefile config_xor.h $(srcinc)/sh_modules.h $(srcinc)/sh_ utmp.h $(srcinc)/sh_mounts.h $(srcinc)/sh_userfiles.h $(srcinc)/sh_kern.h $(srcinc)/sh_suidchk.h $(srcinc)/sh_processcheck.h $(srcinc)/sh_portcheck.h20 sh_modules.o: $(srcsrc)/sh_modules.c Makefile config_xor.h $(srcinc)/sh_modules.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utmp.h $(srcinc)/sh_mounts.h $(srcinc)/sh_userfiles.h $(srcinc)/sh_kern.h $(srcinc)/sh_suidchk.h $(srcinc)/sh_processcheck.h $(srcinc)/sh_portcheck.h 21 21 sh_utmp.o: $(srcsrc)/sh_utmp.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_utmp.h 22 22 sh_kern.o: $(srcsrc)/sh_kern.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_kern.h sh_ks_xor.h $(srcinc)/sh_unix.h $(srcinc)/sh_hash.h … … 63 63 sh_processcheck.o: $(srcsrc)/sh_processcheck.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_modules.h $(srcinc)/sh_processcheck.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_extern.h $(srcinc)/sh_calls.h $(srcinc)/CuTest.h 64 64 sh_portcheck.o: $(srcsrc)/sh_portcheck.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_mem.h $(srcinc)/sh_calls.h $(srcinc)/sh_utils.h $(srcinc)/sh_modules.h $(srcinc)/sh_pthread.h $(srcinc)/CuTest.h 65 sh_pthread.o: $(srcsrc)/sh_pthread.c Makefile config_xor.h $(srcinc)/sh_pthread.h 65 sh_pthread.o: $(srcsrc)/sh_pthread.c Makefile config_xor.h $(srcinc)/sh_pthread.h $(srcinc)/sh_modules.h $(srcinc)/sh_calls.h -
trunk/depend.sum
r138 r140 1 754800869 1 836204565 -
trunk/include/samhain.h
r138 r140 126 126 SH_CHECK_INIT = 1, 127 127 SH_CHECK_CHECK = 2 128 }; 129 130 enum { 131 SH_MOD_ACTIVE = 0, 132 SH_MOD_THREAD = 1, 133 SH_MOD_FAILED = 2 128 134 }; 129 135 -
trunk/include/sh_kern.h
r68 r140 6 6 7 7 #ifdef SH_USE_KERN 8 int sh_kern_init ( void);8 int sh_kern_init (struct mod_type * arg); 9 9 int sh_kern_timer (time_t tcurrent); 10 10 int sh_kern_check (void); -
trunk/include/sh_modules.h
r68 r140 3 3 #define SH_MODULE_H 4 4 5 #include "sh_pthread.h" 5 6 6 7 typedef struct rconf … … 19 20 20 21 /* The initialization function. Return 0 on success. */ 21 int (* mod_init) ( void);22 int (* mod_init) (struct mod_type * arg); 22 23 23 24 /* The timer function. Return 0 if NOT time to check. */ … … 39 40 sh_rconf * conf_table; 40 41 42 SH_MUTEX(mod_mutex); 43 41 44 } sh_mtype; 42 45 -
trunk/include/sh_mounts.h
r1 r140 11 11 12 12 #ifdef SH_USE_MOUNTS 13 int sh_mounts_init ( void);13 int sh_mounts_init (struct mod_type * arg); 14 14 int sh_mounts_timer (time_t tcurrent); 15 15 int sh_mounts_check (void); -
trunk/include/sh_portcheck.h
r67 r140 3 3 #define SH_PORTCHECK_H 4 4 5 int sh_portchk_init( void);5 int sh_portchk_init(struct mod_type * arg); 6 6 int sh_portchk_timer(time_t tcurrent); 7 7 int sh_portchk_check(void); -
trunk/include/sh_processcheck.h
r67 r140 3 3 #define SH_PROCESSCHECK_H 4 4 5 int sh_prochk_init( void);5 int sh_prochk_init(struct mod_type * arg); 6 6 int sh_prochk_timer(time_t tcurrent); 7 7 int sh_prochk_check(void); -
trunk/include/sh_pthread.h
r139 r140 123 123 #else 124 124 125 #define PTHREAD_MUTEX_INITIALIZER NULL 125 126 #define SH_MUTEX(M) void *SH_MUTEX_DUMMY_ ## M 126 127 #define SH_MUTEX_INIT(M,I) extern void *SH_MUTEX_DUMMY_ ## M -
trunk/include/sh_suidchk.h
r119 r140 6 6 7 7 #ifdef SH_USE_SUIDCHK 8 int sh_suidchk_init ( void);8 int sh_suidchk_init (struct mod_type * arg); 9 9 int sh_suidchk_timer (time_t tcurrent); 10 10 int sh_suidchk_check (void); -
trunk/include/sh_userfiles.h
r68 r140 9 9 10 10 #ifdef SH_USE_USERFILES 11 int sh_userfiles_init ( void);11 int sh_userfiles_init (struct mod_type * arg); 12 12 int sh_userfiles_timer (time_t tcurrent); 13 13 int sh_userfiles_check (void); -
trunk/include/sh_utmp.h
r68 r140 6 6 7 7 #ifdef SH_USE_UTMP 8 int sh_utmp_init ( void);8 int sh_utmp_init (struct mod_type * arg); 9 9 int sh_utmp_timer (time_t tcurrent); 10 10 int sh_utmp_check (void); -
trunk/src/samhain.c
r137 r140 1637 1637 for (modnum = 0; modList[modnum].name != NULL; ++modnum) 1638 1638 { 1639 if ( 0 != (status = modList[modnum].mod_init()))1639 if ( 0 != (status = modList[modnum].mod_init(&(modList[modnum]))) ) 1640 1640 { 1641 1641 if (status == (-1)) { … … 1795 1795 for (modnum = 0; modList[modnum].name != NULL; ++modnum) 1796 1796 { 1797 if (0 != (status = modList[modnum].mod_init( )))1797 if (0 != (status = modList[modnum].mod_init(&(modList[modnum])))) 1798 1798 { 1799 1799 if (status == (-1)) { -
trunk/src/sh_error.c
r133 r140 56 56 #include "sh_forward.h" 57 57 #include "sh_prelude.h" 58 #include "sh_pthread.h" 58 59 59 60 #if defined(WITH_DATABASE) … … 857 858 **********************************************************/ 858 859 860 SH_MUTEX_RECURSIVE(mutex_err_handle); 861 859 862 void sh_error_handle (int sev, char * file, long line, 860 863 long status, unsigned long msg_id, ...) … … 868 871 869 872 int flag_inet = S_FALSE; 873 874 #ifdef SH_WITH_SERVER 870 875 int class_inet = clt_class; /* initialize from global */ 871 872 #ifdef SH_WITH_SERVER873 876 char local_inet_peer[SH_MINIBUF]; 874 877 #endif … … 908 911 SL_ENTER(_("sh_error_handle")); 909 912 913 SH_MUTEX_RECURSIVE_INIT(mutex_err_handle); 914 SH_MUTEX_RECURSIVE_LOCK(mutex_err_handle); 915 910 916 #ifdef SH_WITH_SERVER 911 917 /* copy the global string into a local array … … 918 924 else 919 925 local_inet_peer[0] = '\0'; 920 #endif921 926 922 927 clt_class = (-1); /* reset global */ 928 #endif 929 923 930 924 931 if (own_block == 1) 925 932 { 926 SL_RET0(_("sh_error_handle"));933 goto exit_here; 927 934 } 928 935 929 936 /* --- Initialize to default values. --- 930 937 */ 931 own_block = 1;932 938 if (IsInitialized == BAD) 933 939 (void) sh_error_init(); 934 own_block = 0; 935 936 /* --- Consistency checks. --- 937 */ 938 own_block = 1; 940 941 /* Returns pointer to (constant|thread-specific) static memory 942 */ 939 943 fmt = /*@i@*/get_format (msg_id, &severity, &class); 940 own_block = 0; 941 944 945 #ifdef SH_WITH_SERVER 942 946 if (class_inet != (-1)) 943 947 class = (unsigned int) class_inet; 944 948 #endif 949 950 /* --- Consistency check. --- 951 */ 945 952 ASSERT((fmt != NULL), _("fmt != NULL")) 946 953 if (fmt == NULL) … … 949 956 _("ERROR: msg=<NULL format>, file=<%s>, line=<%ld>\n"), 950 957 file, line); 951 SL_RET0(_("sh_error_handle"));958 goto exit_here; 952 959 } 953 960 … … 995 1002 ) 996 1003 { 997 SL_RET0(_("sh_error_handle"));1004 goto exit_here; 998 1005 } 999 1006 1000 1007 if ((severity & SH_ERR_NOT) != 0) 1001 1008 { 1002 SL_RET0(_("sh_error_handle"));1009 goto exit_here; 1003 1010 } 1004 1011 … … 1017 1024 lmsg->line = line; 1018 1025 lmsg->status = status; 1019 own_block = 0;1020 1021 1026 1022 1027 /* Format the log message with timestamp etc. 1023 1028 * Allocate lmsg->msg 1024 1029 */ 1025 own_block = 1;1026 1030 va_start (vl, msg_id); 1027 1031 (void) sh_error_string (lmsg, vl); … … 1311 1315 SH_FREE( lmsg ); 1312 1316 own_block = 0; 1317 1318 exit_here: 1319 1320 SH_MUTEX_RECURSIVE_UNLOCK(mutex_err_handle); 1313 1321 1314 1322 /*@i@*/SL_RET0(_("sh_error_handle")); -
trunk/src/sh_kern.c
r137 r140 1754 1754 static int AddressReconf = 0; 1755 1755 1756 int sh_kern_init ( )1756 int sh_kern_init (struct mod_type * arg) 1757 1757 { 1758 1758 #if defined(HOST_IS_LINUX) … … 1760 1760 char * str; 1761 1761 #endif 1762 (void) arg; 1762 1763 1763 1764 SL_ENTER(_("sh_kern_init")); -
trunk/src/sh_mem.c
r139 r140 256 256 eblock = 1; 257 257 (void) safe_logger (0, 0, NULL); 258 /*259 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MMEM,260 file, line);261 */262 258 eblock = 0; 263 259 } … … 348 344 eblock = 1; 349 345 (void) safe_logger(0, 0, NULL); 350 /*351 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MMEM,352 file, line);353 */354 346 eblock = 0; 355 347 } … … 491 483 eblock = 1; 492 484 (void) safe_logger(0, 0, NULL); 493 /*494 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MMEM);495 */496 485 eblock = 0; 497 486 } -
trunk/src/sh_modules.c
r68 r140 7 7 8 8 #include "sh_modules.h" 9 #include "sh_pthread.h" 9 10 10 11 #include "sh_utmp.h" … … 29 30 N_("[Utmp]"), 30 31 sh_utmp_table, 32 PTHREAD_MUTEX_INITIALIZER, 31 33 }, 32 34 #endif … … 44 46 N_("[Mounts]"), 45 47 sh_mounts_table, 48 PTHREAD_MUTEX_INITIALIZER, 46 49 }, 47 50 #endif … … 59 62 N_("[UserFiles]"), 60 63 sh_userfiles_table, 64 PTHREAD_MUTEX_INITIALIZER, 61 65 }, 62 66 #endif … … 74 78 N_("[Kernel]"), 75 79 sh_kern_table, 80 PTHREAD_MUTEX_INITIALIZER, 76 81 }, 77 82 #endif … … 89 94 N_("[SuidCheck]"), 90 95 sh_suidchk_table, 96 PTHREAD_MUTEX_INITIALIZER, 91 97 }, 92 98 #endif … … 104 110 N_("[ProcessCheck]"), 105 111 sh_prochk_table, 112 PTHREAD_MUTEX_INITIALIZER, 106 113 }, 107 114 #endif … … 119 126 N_("[PortCheck]"), 120 127 sh_portchk_table, 128 PTHREAD_MUTEX_INITIALIZER, 121 129 }, 122 130 #endif … … 134 142 NULL, 135 143 NULL, 144 PTHREAD_MUTEX_INITIALIZER, 136 145 }, 137 146 }; -
trunk/src/sh_mounts.c
r68 r140 165 165 * This is called once at the start of each samhain run. 166 166 * Non-configuration setup code should be placed here. */ 167 int sh_mounts_init () 168 { 167 int sh_mounts_init (struct mod_type * arg) 168 { 169 (void) arg; 169 170 SL_ENTER(_("sh_mounts_init")); 170 171 -
trunk/src/sh_portcheck.c
r137 r140 815 815 #endif 816 816 817 int sh_portchk_init ( )817 int sh_portchk_init (struct mod_type * arg) 818 818 { 819 819 struct hostent * hent; 820 820 int i = 0; 821 821 char errbuf[256]; 822 (void) arg; 822 823 823 824 if (portchk_debug) -
trunk/src/sh_processcheck.c
r132 r140 1150 1150 /* Initialise. 1151 1151 */ 1152 int sh_prochk_init(void) 1153 { 1152 int sh_prochk_init(struct mod_type * arg) 1153 { 1154 (void) arg; 1154 1155 SL_ENTER(_("sh_prochk_init")); 1155 1156 -
trunk/src/sh_pthread.c
r139 r140 2 2 3 3 #include "sh_pthread.h" 4 #include "sh_modules.h" 4 5 5 6 #ifdef HAVE_PTHREAD 7 8 #include <signal.h> 9 #include "sh_calls.h" 10 6 11 SH_MUTEX_INIT(mutex_skey, PTHREAD_MUTEX_INITIALIZER); 7 12 SH_MUTEX_INIT(mutex_resolv, PTHREAD_MUTEX_INITIALIZER); … … 15 20 } 16 21 22 int sh_pthread_init_threadspecific() 23 { 24 int rc = 0; 25 #ifdef SH_STEALTH 26 extern int sh_g_thread(); 27 28 rc = sh_g_thread(); 29 if (rc != 0) 30 return rc; 31 #endif 32 33 return rc; 34 } 35 36 37 /* 38 * ---- Utilities for modules ---- 39 */ 40 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() 52 * -- calls internal init, 53 * -- polls timer, 54 * -- runs module check, 55 * -- runs sh_pthread_testcancel() 56 * -- returns (return == exit) 57 */ 58 59 #define SH_NUM_THREADS 16 60 static pthread_t threads[SH_NUM_THREADS]; 61 static int ithread[SH_NUM_THREADS]; 62 static pthread_mutex_t create_mutex = PTHREAD_MUTEX_INITIALIZER; 63 64 int sh_pthread_create(void *(*start_routine)(void*), void *arg) 65 { 66 int rc, nthread = 1; 67 sigset_t signal_set; 68 int retval = 0; 69 70 pthread_mutex_lock(&create_mutex); 71 72 /* block all signals 73 */ 74 sigfillset( &signal_set ); 75 pthread_sigmask( SIG_BLOCK, &signal_set, NULL ); 76 77 /* find a free slot in threads[] 78 */ 79 while (nthread < SH_NUM_THREADS) 80 { 81 if (ithread[nthread] == 0) 82 break; 83 ++nthread; 84 if (nthread == SH_NUM_THREADS) 85 { 86 retval = -1; 87 goto err_out; 88 } 89 } 90 91 rc = pthread_create(&threads[nthread], NULL, start_routine, arg); 92 if (rc != 0) 93 { 94 retval = -1; 95 goto err_out; 96 } 97 98 ithread[nthread] = 1; 99 100 err_out: 101 pthread_sigmask( SIG_UNBLOCK, &signal_set, NULL ); 102 pthread_mutex_unlock(&create_mutex); 103 return retval; 104 } 105 106 int sh_pthread_cancel_all() 107 { 108 int i; 109 int ret = 0; 110 111 SH_MUTEX_LOCK(create_mutex); 112 113 for (i = 1; i < SH_NUM_THREADS; ++i) 114 { 115 if (ithread[i] != 0) 116 if (0 != pthread_cancel(threads[i])) 117 ithread[i] = 0; 118 } 119 120 for (i = 1; i < SH_NUM_THREADS; ++i) 121 { 122 if (ithread[i] != 0) 123 pthread_join(threads[i], NULL); 124 ithread[i] = 0; 125 } 126 127 SH_MUTEX_UNLOCK(create_mutex); 128 return ret; 129 } 130 131 /* ---- Utility functions for modules ---- 132 */ 133 void sh_threaded_module_reconf(void *arg) 134 { 135 sh_mtype * this_module = (sh_mtype *) arg; 136 this_module->mod_reconf(); 137 return; 138 } 139 140 void sh_threaded_module_run(void *arg) 141 { 142 sh_mtype * this_module = (sh_mtype *) arg; 143 144 /* First we lock the module. This ensures that it cannot be 145 * run twice. 146 */ 147 pthread_cleanup_push(sh_pthread_mutex_unlock, (void*) &(this_module->mod_mutex)); 148 pthread_mutex_lock(&(this_module->mod_mutex)); 149 150 if (0 == sh_pthread_init_threadspecific()) 151 { 152 153 if (0 == this_module->mod_init(NULL)) 154 { 155 pthread_cleanup_push(sh_threaded_module_reconf, arg); 156 157 while (1) 158 { 159 if (0 != this_module->mod_timer(time(NULL))) 160 { 161 this_module->mod_check(); 162 pthread_testcancel(); 163 retry_msleep(1,0); 164 } 165 } 166 167 pthread_cleanup_pop(1); /* notreached,but required */ 168 } 169 } 170 171 pthread_cleanup_pop(1); 172 173 return; 174 } 175 176 177 /* 178 * ---- Implementation of recursive mutexes from libxml2 ---- 179 */ 17 180 #if !defined(HAVE_PTHREAD_MUTEX_RECURSIVE) 18 181 /** … … 21 184 * Gary Pennington <Gary.Pennington@uk.sun.com> 22 185 * daniel@veillard.com 23 */ 24 186 187 * Except where otherwise noted in the source code (e.g. the files hash.c, 188 * list.c and the trio files, which are covered by a similar licence but 189 * with different Copyright notices) all the files are: 190 * 191 * Copyright (C) 1998-2003 Daniel Veillard. All Rights Reserved. 192 * 193 * Permission is hereby granted, free of charge, to any person obtaining a copy 194 * of this software and associated documentation files (the "Software"), to deal 195 * in the Software without restriction, including without limitation the rights 196 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 197 * copies of the Software, and to permit persons to whom the Software is fur- 198 * nished to do so, subject to the following conditions: 199 * 200 * The above copyright notice and this permission notice shall be included in 201 * all copies or substantial portions of the Software. 202 * 203 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 204 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- 205 * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 206 * DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 207 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- 208 * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 209 * 210 * Except as contained in this notice, the name of Daniel Veillard shall not 211 * be used in advertising or otherwise to promote the sale, use or other deal- 212 * ings in this Software without prior written authorization from him. 213 */ 214 215 /* Modified NewRMutex -> InitRMutex. We use a static structure, rather than 216 * allocating one. Also dropped code for non-POSIX OSes. 217 */ 25 218 void sh_InitRMutex(struct sh_RMutex * tok) 26 219 { -
trunk/src/sh_suidchk.c
r138 r140 1172 1172 * 1173 1173 *************/ 1174 int sh_suidchk_init () 1175 { 1174 int sh_suidchk_init (struct mod_type * arg) 1175 { 1176 (void) arg; 1176 1177 if (ShSuidchkActive == S_FALSE) 1177 1178 return (-1); -
trunk/src/sh_userfiles.c
r137 r140 246 246 /* Build the list of users, then use this to construct the filenames to 247 247 * be checked. */ 248 int sh_userfiles_init( void) {248 int sh_userfiles_init(struct mod_type * arg) { 249 249 struct passwd *cur_user; 250 250 struct userhomeslist *end; 251 251 struct userhomeslist *new; 252 252 struct userhomeslist *homes; 253 (void) arg; 253 254 254 255 SL_ENTER(_("sh_userfiles_init")); -
trunk/src/sh_utmp.c
r132 r140 461 461 * 462 462 *************/ 463 int sh_utmp_init ( )463 int sh_utmp_init (struct mod_type * arg) 464 464 { 465 465 static int done = 0; 466 (void) arg; 466 467 467 468 SL_ENTER(_("sh_utmp_init")); -
trunk/test/testcompile.sh
r138 r140 51 51 for i in ${CDIR}/*.c.sm ; do 52 52 # echo $i; 53 cat $i | ./unreached_code.pl ;53 cat $i | ./unreached_code.pl | grep -v sh_threaded_module_run; 54 54 cat $i | ./ampersand_missing.sh; 55 55 cat $i | ./eqeq.pl;
Note:
See TracChangeset
for help on using the changeset viewer.