Changeset 143
- Timestamp:
- Oct 31, 2007, 1:09:26 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile.in
r140 r143 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 1654 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 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 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 $(srcinc)/sh_pthread.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 1657 1657 sh_suidchk.o: $(srcsrc)/sh_suidchk.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_suidchk.h $(srcinc)/sh_hash.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_schedule.h $(srcinc)/sh_calls.h … … 1695 1695 sh_prelude_old.o: $(srcsrc)/sh_prelude_old.c Makefile config_xor.h $(srcinc)/slib.h $(srcinc)/sh_mem.h $(srcinc)/sh_cat.h $(srcinc)/sh_error_min.h $(srcinc)/sh_prelude.h $(srcinc)/sh_static.h $(srcinc)/sh_pthread.h 1696 1696 sh_async.o: $(srcsrc)/sh_async.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_calls.h $(srcinc)/sh_error.h 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.h1697 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)/sh_pthread.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 $(srcinc)/sh_ modules.h $(srcinc)/sh_calls.h1699 sh_pthread.o: $(srcsrc)/sh_pthread.c Makefile config_xor.h $(srcinc)/sh_pthread.h $(srcinc)/sh_calls.h $(srcinc)/sh_modules.h -
trunk/configure.ac
r138 r143 13 13 dnl start 14 14 dnl 15 AM_INIT_AUTOMAKE(samhain, 2. 3.7)15 AM_INIT_AUTOMAKE(samhain, 2.4.0) 16 16 AC_CANONICAL_HOST 17 17 -
trunk/depend.dep
r140 r143 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 20 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 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 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 $(srcinc)/sh_pthread.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 23 23 sh_suidchk.o: $(srcsrc)/sh_suidchk.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_suidchk.h $(srcinc)/sh_hash.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_schedule.h $(srcinc)/sh_calls.h … … 61 61 kern_head.o: $(srcsrc)/kern_head.c Makefile config.h $(srcinc)/kern_head.h $(srcinc)/kern_head.h 62 62 sh_async.o: $(srcsrc)/sh_async.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_calls.h $(srcinc)/sh_error.h 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.h63 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)/sh_pthread.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 $(srcinc)/sh_ modules.h $(srcinc)/sh_calls.h65 sh_pthread.o: $(srcsrc)/sh_pthread.c Makefile config_xor.h $(srcinc)/sh_pthread.h $(srcinc)/sh_calls.h $(srcinc)/sh_modules.h -
trunk/depend.sum
r140 r143 1 836204565 1 2519500817 -
trunk/include/samhain.h
r140 r143 128 128 }; 129 129 130 enum { 131 SH_MOD_ACTIVE = 0, 132 SH_MOD_THREAD = 1, 133 SH_MOD_FAILED = 2 134 }; 135 130 #define SH_MOD_THREAD 1 131 #define SH_MOD_ACTIVE 0 132 #define SH_MOD_FAILED -1 133 136 134 /* Flags for file status 137 135 */ … … 287 285 extern volatile int sig_debug_switch; /* SIGUSR1 */ 288 286 extern volatile int sig_suspend_switch; /* SIGUSR2 */ 289 extern volatile int sh_global_suspend_flag; /* SIGUSR2 */287 extern volatile int sh_global_suspend_flag; 290 288 extern volatile int sig_fresh_trail; /* SIGIOT */ 289 extern volatile int sh_thread_pause_flag; 291 290 extern volatile int sig_config_read_again; /* SIGHUP */ 292 291 extern volatile int sig_terminate; /* SIGQUIT */ -
trunk/include/sh_pthread.h
r140 r143 38 38 #if defined(HAVE_PTHREAD_MUTEX_RECURSIVE) 39 39 40 /* On GNU C, it's an enum, thus the alternative implementation41 * below is used.42 */43 40 #define SH_MUTEX_RECURSIVE(M) \ 44 41 static pthread_mutex_t M; \ … … 46 43 { \ 47 44 pthread_mutexattr_t mta; \ 45 pthread_mutexattr_init(&mta); \ 48 46 pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE); \ 49 47 pthread_mutex_init(&(M), &mta); \ … … 115 113 SH_MUTEX_EXTERN(mutex_pwent); 116 114 SH_MUTEX_EXTERN(mutex_readdir); 115 /* Prevent threads from logging while we are in suspend */ 116 SH_MUTEX_EXTERN(mutex_thread_nolog); 117 117 118 118 /* … … 120 120 */ 121 121 extern int sh_g_thread(); 122 123 124 /* 125 * ---- Functions for threaded modules ---- 126 */ 127 int sh_pthread_create(void *(*start_routine)(void*), void *arg); 128 int sh_pthread_cancel_all(void); 129 void sh_threaded_module_reconf(void *arg); 130 void * sh_threaded_module_run(void *arg); 122 131 123 132 #else -
trunk/src/samhain.c
r142 r143 114 114 volatile int sh_global_suspend_flag; 115 115 volatile int sig_fresh_trail; /* SIGIOT */ 116 volatile int sh_thread_pause_flag = S_FALSE; 116 117 volatile int sig_config_read_again; /* SIGHUP */ 117 118 volatile int sig_terminate; /* SIGQUIT */ … … 1724 1725 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_RECONF); 1725 1726 1727 sh_thread_pause_flag = S_TRUE; 1728 1726 1729 #if defined(WITH_EXTERNAL) 1727 1730 /* delete list of external tasks … … 1793 1796 sh.flag.loop = S_FALSE; 1794 1797 } 1798 1799 sh_thread_pause_flag = S_FALSE; 1795 1800 1796 1801 /* --- Initialize modules. --- … … 1829 1834 if (sig_fresh_trail == 1) /* SIGIOT */ 1830 1835 { 1831 /* Logfile access 1832 */ 1836 if (sh_global_suspend_flag == 0) 1837 { 1838 SH_MUTEX_LOCK(mutex_thread_nolog); 1839 1840 /* Logfile access 1841 */ 1833 1842 #ifdef SH_USE_XML 1834 (void) sh_log_file (NULL, NULL); 1835 #endif 1836 TPT((0, FIL__, __LINE__, _("msg=<Logfile stop/restart.>\n"))); 1837 sh_error_only_stderr (S_TRUE); 1838 (void) sh_unix_rm_lock_file(sh.srvlog.name); 1839 (void) retry_msleep(3, 0); 1840 sh.flag.log_start = S_TRUE; 1841 sh_error_only_stderr (S_FALSE); 1842 sig_fresh_trail = 0; 1843 --sig_raised; 1843 (void) sh_log_file (NULL, NULL); 1844 #endif 1845 TPT((0, FIL__, __LINE__, _("msg=<Logfile stop/restart.>\n"))); 1846 sh_error_only_stderr (S_TRUE); 1847 (void) sh_unix_rm_lock_file(sh.srvlog.name); 1848 (void) retry_msleep(3, 0); 1849 sh.flag.log_start = S_TRUE; 1850 sh_error_only_stderr (S_FALSE); 1851 sh_thread_pause_flag = S_FALSE; 1852 sig_fresh_trail = 0; 1853 --sig_raised; 1854 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1855 } 1844 1856 } 1845 1857 … … 1863 1875 { 1864 1876 TPT((0, FIL__, __LINE__, _("msg=<Suspend switch.>\n"))); 1865 if (sh_global_suspend_flag == 1) {1866 sh_global_suspend_flag = 0;1867 } else {1877 if (sh_global_suspend_flag != 1) { 1878 SH_MUTEX_LOCK_UNSAFE(mutex_thread_nolog); 1879 sh_global_suspend_flag = 1; 1868 1880 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_SUSPEND, 1869 1881 sh.prg_name); 1870 sh_global_suspend_flag = 1; 1882 } else { 1883 sh_global_suspend_flag = 0; 1884 SH_MUTEX_UNLOCK_UNSAFE(mutex_thread_nolog); 1871 1885 } 1872 1886 --sig_suspend_switch; -
trunk/src/sh_kern.c
r140 r143 968 968 if (df) 969 969 { 970 SH_MUTEX_LOCK(mutex_readdir); 971 972 while (NULL != (entry = readdir(df))) 970 while (1) 973 971 { 972 SH_MUTEX_LOCK(mutex_readdir); 973 entry = readdir(df); 974 SH_MUTEX_UNLOCK(mutex_readdir); 975 976 if (entry == NULL) 977 break; 978 974 979 if (0 == strcmp(entry->d_name, ".") && 975 980 0 == strcmp(entry->d_name, "..")) … … 981 986 SH_FREE(pcipath); 982 987 } 983 984 SH_MUTEX_UNLOCK(mutex_readdir);985 988 986 989 closedir(df); -
trunk/src/sh_mem.c
r140 r143 108 108 109 109 #ifdef HAVE_PTHREAD 110 111 110 SH_MUTEX_RECURSIVE(mutex_mem); 112 113 #else114 #define MEM_MUTEX_INIT ((void)0)115 111 #endif 116 112 -
trunk/src/sh_processcheck.c
r140 r143 64 64 #include "sh_extern.h" 65 65 #include "sh_calls.h" 66 #include "sh_pthread.h" 66 67 67 68 #ifdef SH_USE_PROCESSCHECK … … 70 71 71 72 #ifdef __linux__ 72 #define HAVE_THREADS73 #define PS_THREADS 73 74 #endif 74 75 … … 76 77 */ 77 78 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) 79 80 SH_MUTEX_STATIC(mutex_proc_check, PTHREAD_MUTEX_INITIALIZER); 78 81 79 82 /* sh_prochk_maxpid is one more than the largest pid … … 405 408 if (S_FALSE == is_in_list(&list_missing, list->str, 0)) 406 409 { 410 SH_MUTEX_LOCK(mutex_thread_nolog); 407 411 sh_error_handle(sh_prochk_severity, FIL__, __LINE__, 0, 408 412 MSG_PCK_MISS, 409 413 list->str); 414 SH_MUTEX_UNLOCK(mutex_thread_nolog); 410 415 } 411 416 } … … 424 429 { 425 430 tmp = sh_util_safe_name (list->str); 431 SH_MUTEX_LOCK(mutex_thread_nolog); 426 432 sh_error_handle(sh_prochk_severity, FIL__, __LINE__, 0, 427 433 MSG_PCK_MISS, 428 434 tmp); 435 SH_MUTEX_UNLOCK(mutex_thread_nolog); 429 436 SH_FREE(tmp); 430 437 } … … 458 465 { 459 466 regerror(status, &(new->preg), errbuf, sizeof(errbuf)); 467 SH_MUTEX_LOCK(mutex_thread_nolog); 460 468 sh_error_handle((-1), FIL__, __LINE__, status, MSG_E_SUBGEN, 461 errbuf, _("sh_processes_runps")); 469 errbuf, _("sh_processes_add_process")); 470 SH_MUTEX_UNLOCK(mutex_thread_nolog); 462 471 SH_FREE(new->str); 463 472 SH_FREE(new); … … 578 587 if (val <= 0) 579 588 { 589 SH_MUTEX_LOCK(mutex_thread_nolog); 580 590 sh_error_handle ((-1), FIL__, __LINE__, EINVAL, MSG_EINVALS, 581 591 _("process check interval"), c); 592 SH_MUTEX_UNLOCK(mutex_thread_nolog); 582 593 retval = -1; 583 594 } … … 826 837 char errbuf[SH_ERRBUF_SIZE]; 827 838 839 /* SH_MUTEX_LOCK(mutex_thread_nolog) is in caller */ 828 840 sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, errno, MSG_E_SUBGEN, 829 841 sh_error_message(errno, errbuf, sizeof(errbuf)), … … 848 860 if (flag_err_debug == SL_TRUE) 849 861 { 850 sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, num, MSG_E_SUBGEN, 862 /* SH_MUTEX_LOCK(mutex_thread_nolog) is in caller */ 863 sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, num, 864 MSG_E_SUBGEN, 851 865 tstr, 852 866 _("sh_processes_readps")); … … 880 894 else if (isspace(cc)) 881 895 { 882 #ifdef HAVE_THREADS896 #ifdef PS_THREADS 883 897 num = 0; 884 898 line = SKIP_WS2; … … 979 993 if (!sh_prochk_psarg) 980 994 { 981 #ifdef HAVE_THREADS995 #ifdef PS_THREADS 982 996 (void) sh_ext_tas_add_argv(&task, _("-eT")); 983 997 #else … … 996 1010 if (status != 0) 997 1011 { 1012 /* SH_MUTEX_LOCK(mutex_thread_nolog) is in caller */ 998 1013 sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, status, MSG_E_SUBGEN, 999 1014 _("Could not open pipe"), _("sh_processes_runps")); … … 1037 1052 if (!res) 1038 1053 { 1054 SH_MUTEX_LOCK(mutex_thread_nolog); 1039 1055 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN, 1040 1056 _("Internal error: NULL argument"), 1041 1057 _("sh_process_check_int")); 1058 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1042 1059 SL_RETURN ((-1), _("sh_process_check_int")); 1043 1060 } 1044 1061 1062 SH_MUTEX_LOCK(mutex_thread_nolog); 1045 1063 sh_processes_runps (res, NULL, 0, SH_PR_PS, 0); 1064 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1046 1065 for (i = sh_prochk_minpid; i != sh_prochk_maxpid; ++i) 1047 1066 { … … 1049 1068 res[j] = sh_processes_check ((pid_t) i, res[j]); 1050 1069 } 1070 SH_MUTEX_LOCK(mutex_thread_nolog); 1051 1071 sh_processes_runps (res, NULL, 0, SH_PR_PS2, 0); 1072 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1052 1073 1053 1074 /* Evaluate results … … 1084 1105 if ((res[j] & SH_PR_PS_ANY) && (res[j] & SH_PR_ANY)) 1085 1106 { 1107 SH_MUTEX_LOCK(mutex_thread_nolog); 1086 1108 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_PCK_OK, 1087 1109 (unsigned long) i, tests); 1110 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1088 1111 } 1089 1112 … … 1105 1128 char * safe; 1106 1129 1130 SH_MUTEX_LOCK(mutex_thread_nolog); 1107 1131 aout = get_user_and_path ((pid_t) i, user, sizeof(user)); 1132 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1108 1133 1109 1134 if (aout) 1110 1135 { 1111 1136 safe = sh_util_safe_name (aout); 1137 SH_MUTEX_LOCK(mutex_thread_nolog); 1112 1138 sh_error_handle(sh_prochk_severity, FIL__, __LINE__, 0, 1113 1139 MSG_PCK_P_HIDDEN, 1114 1140 (unsigned long) i, tests, safe, user); 1141 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1115 1142 SH_FREE(safe); 1116 1143 SH_FREE(aout); 1117 1144 } 1118 1145 else 1119 sh_error_handle(sh_prochk_severity, FIL__, __LINE__, 0, 1120 MSG_PCK_HIDDEN, 1121 (unsigned long) i, tests); 1122 1146 { 1147 SH_MUTEX_LOCK(mutex_thread_nolog); 1148 sh_error_handle(sh_prochk_severity, FIL__, __LINE__, 0, 1149 MSG_PCK_HIDDEN, 1150 (unsigned long) i, tests); 1151 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1152 } 1123 1153 } 1124 1154 } … … 1134 1164 if (S_FALSE == is_in_list(&list_fake, NULL, i)) 1135 1165 { 1166 SH_MUTEX_LOCK(mutex_thread_nolog); 1136 1167 sh_error_handle(sh_prochk_severity, FIL__, __LINE__, 0, 1137 1168 MSG_PCK_FAKE, 1138 1169 (unsigned long) i, tests); 1170 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1139 1171 } 1140 1172 } … … 1150 1182 /* Initialise. 1151 1183 */ 1152 int sh_prochk_init(struct mod_type * arg) 1153 { 1154 (void) arg; 1184 static int sh_prochk_init_internal() 1185 { 1155 1186 SL_ENTER(_("sh_prochk_init")); 1156 1187 … … 1179 1210 } 1180 1211 1212 int sh_prochk_init (struct mod_type * arg) 1213 { 1214 if (ShProchkActive == S_FALSE) 1215 return SH_MOD_FAILED; 1216 #ifdef HAVE_PTHREAD 1217 if (arg != NULL && arg->initval < 0 && sh.flag.isdaemon == S_TRUE) 1218 { 1219 if (0 == sh_pthread_create(sh_threaded_module_run, (void *)arg)) 1220 return SH_MOD_THREAD; 1221 else 1222 return SH_MOD_FAILED; 1223 } 1224 #endif 1225 return sh_prochk_init_internal(); 1226 } 1181 1227 1182 1228 int sh_prochk_timer(time_t tcurrent) … … 1199 1245 SL_ENTER(_("sh_prochk_check")); 1200 1246 1247 SH_MUTEX_LOCK(mutex_proc_check); 1201 1248 if( ShProchkActive != S_FALSE ) 1202 1249 { 1250 SH_MUTEX_LOCK(mutex_thread_nolog); 1203 1251 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_PCK_CHECK, 1204 1252 (unsigned long) sh_prochk_minpid, 1205 1253 (unsigned long) (sh_prochk_maxpid-1)); 1254 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1206 1255 1207 1256 if (sh_prochk_res) { … … 1220 1269 clean_list (&list_fake); 1221 1270 } 1271 SH_MUTEX_UNLOCK(mutex_proc_check); 1222 1272 1223 1273 SL_RETURN(status, _("sh_prochk_check")); … … 1254 1304 SL_ENTER(_("sh_prochk_reconf")); 1255 1305 1306 SH_MUTEX_LOCK(mutex_proc_check); 1256 1307 userdef_maxpid = 0; 1257 1308 sh_prochk_maxpid = 0x8000; … … 1271 1322 SH_FREE(sh_prochk_pspath); 1272 1323 sh_prochk_pspath = NULL; 1324 SH_MUTEX_UNLOCK(mutex_proc_check); 1273 1325 1274 1326 SL_RETURN(0, _("sh_prochk_reconf")); -
trunk/src/sh_pthread.c
r142 r143 8 8 #include "sh_calls.h" 9 9 #include "sh_modules.h" 10 11 SH_MUTEX_INIT(mutex_skey, PTHREAD_MUTEX_INITIALIZER); 12 SH_MUTEX_INIT(mutex_resolv, PTHREAD_MUTEX_INITIALIZER); 13 SH_MUTEX_INIT(mutex_pwent, PTHREAD_MUTEX_INITIALIZER); 14 SH_MUTEX_INIT(mutex_readdir,PTHREAD_MUTEX_INITIALIZER); 10 extern volatile int sh_thread_pause_flag; 11 12 SH_MUTEX_INIT(mutex_skey, PTHREAD_MUTEX_INITIALIZER); 13 SH_MUTEX_INIT(mutex_resolv, PTHREAD_MUTEX_INITIALIZER); 14 SH_MUTEX_INIT(mutex_pwent, PTHREAD_MUTEX_INITIALIZER); 15 SH_MUTEX_INIT(mutex_readdir, PTHREAD_MUTEX_INITIALIZER); 16 SH_MUTEX_INIT(mutex_thread_nolog, PTHREAD_MUTEX_INITIALIZER); 15 17 16 18 void sh_pthread_mutex_unlock (void *arg) … … 136 138 /* ---- Utility functions for modules ---- 137 139 */ 140 141 #undef S_TRUE 142 #define S_TRUE 1 143 #undef S_FALSE 144 #define S_FALSE 0 145 138 146 void sh_threaded_module_cleanup(void *arg) 139 147 { … … 162 170 while (1) 163 171 { 164 if (0 != this_module->mod_timer(time(NULL))) 172 if (sh_thread_pause_flag != S_TRUE && 173 0 != this_module->mod_timer(time(NULL))) 165 174 { 166 175 /* If module has been de-activated on reconfigure, … … 172 181 break; 173 182 pthread_testcancel(); 174 retry_msleep(1,0);175 183 } 184 retry_msleep(1,0); 176 185 } 177 186 -
trunk/src/sh_suidchk.c
r140 r143 874 874 do { 875 875 876 if (sig_urgent > 0) {877 SL_RETURN( (0), _("sh_suidchk_check_internal"));878 }879 880 876 thisEntry = readdir (thisDir); 881 877 … … 905 901 if (!dirlist) 906 902 break; 903 904 if (sig_urgent > 0) { 905 SL_RETURN( (0), _("sh_suidchk_check_internal")); 906 } 907 907 908 908 tmpcat = SH_ALLOC(PATH_MAX); -
trunk/src/sh_tools.c
r137 r143 522 522 #endif 523 523 { 524 host_name = NULL; 525 524 526 SH_MUTEX_LOCK(mutex_resolv); 525 527 … … 596 598 } 597 599 } 598 599 SH_FREE(host_name);600 600 } 601 601 } 602 602 SH_MUTEX_UNLOCK(mutex_resolv); 603 if (host_name) SH_FREE(host_name); 603 604 } 604 605 -
trunk/src/sh_unix.c
r138 r143 4221 4221 if (0 != page_locking) 4222 4222 { 4223 SL_RETURN((-1), _("sh_unix_mlock")); 4223 status = -1; 4224 goto exit_mlock; 4224 4225 } 4225 4226 … … 4284 4285 SH_FREE(page_list); 4285 4286 page_locking = 0; 4286 SL_RETURN((status), _("sh_unix_mlock"));4287 goto exit_mlock; 4287 4288 } 4288 4289 page_list->next = sh_page_locked; … … 4292 4293 } 4293 4294 page_locking = 0; 4295 4296 exit_mlock: 4294 4297 SH_MUTEX_UNLOCK_UNSAFE(mutex_mlock); 4295 4298 … … 4332 4335 if (0 != page_locking) 4333 4336 { 4334 SL_RETURN((-1), _("sh_unix_munlock")); 4337 status = -1; 4338 goto exit_munlock; 4335 4339 } 4336 4340 page_locking = 1; … … 4437 4441 4438 4442 page_locking = 0; 4443 4444 exit_munlock: 4439 4445 SH_MUTEX_UNLOCK_UNSAFE(mutex_mlock); 4440 4441 4446 SL_RETURN((status), _("sh_unix_munlock")); 4442 4447 } -
trunk/src/sh_utmp.c
r142 r143 79 79 #include "sh_modules.h" 80 80 #include "sh_utmp.h" 81 81 #include "sh_pthread.h" 82 83 SH_MUTEX_EXTERN(mutex_thread_nolog); 82 84 83 85 #ifdef TM_IN_SYS_TIME … … 300 302 if (sh_utmpfile == NULL) 301 303 { 304 SH_MUTEX_LOCK(mutex_thread_nolog); 302 305 fd = (int) aud_open (FIL__, __LINE__, SL_NOPRIV, 303 306 sh_utmppath, O_RDONLY, 0); 307 SH_MUTEX_UNLOCK(mutex_thread_nolog); 304 308 if (fd >= 0) 305 309 { … … 313 317 { 314 318 error = errno; 319 SH_MUTEX_LOCK(mutex_thread_nolog); 315 320 sh_error_handle ((-1), FIL__, __LINE__, error, MSG_E_ACCESS, 316 321 (long) sh.real.uid, sh_utmppath); 322 SH_MUTEX_UNLOCK(mutex_thread_nolog); 317 323 SL_RET0(_("sh_utmp_setutent")); 318 324 } … … 489 495 return SH_MOD_FAILED; 490 496 #ifdef HAVE_PTHREAD 491 if (arg != NULL && arg->initval < 0 )497 if (arg != NULL && arg->initval < 0 && sh.flag.isdaemon == S_TRUE) 492 498 { 493 499 if (0 == sh_pthread_create(sh_threaded_module_run, (void *)arg)) … … 559 565 if (ShUtmpActive == BAD) 560 566 SL_RETURN( (-1), _("sh_utmp_check")); 567 SH_MUTEX_LOCK(mutex_thread_nolog); 561 568 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_UT_CHECK); 569 SH_MUTEX_UNLOCK(mutex_thread_nolog); 562 570 sh_utmp_check_internal (1); 563 571 … … 579 587 tmp[0] = '='; tmp[1] = '\0'; 580 588 (void) sl_strlcat (tmp, c, 32); 589 SH_MUTEX_LOCK(mutex_thread_nolog); 581 590 retval = sh_error_set_level (tmp, &ShUtmpLoginSolo); 591 SH_MUTEX_UNLOCK(mutex_thread_nolog); 582 592 SL_RETURN(retval, _("sh_utmp_set_login_solo")); 583 593 } … … 591 601 tmp[0] = '='; tmp[1] = '\0'; 592 602 (void) sl_strlcat (tmp, c, 32); 603 SH_MUTEX_LOCK(mutex_thread_nolog); 593 604 retval = sh_error_set_level (tmp, &ShUtmpLoginMulti); 605 SH_MUTEX_UNLOCK(mutex_thread_nolog); 594 606 SL_RETURN(retval, _("sh_utmp_set_login_multi")); 595 607 } … … 603 615 tmp[0] = '='; tmp[1] = '\0'; 604 616 (void) sl_strlcat (tmp, c, 32); 617 SH_MUTEX_LOCK(mutex_thread_nolog); 605 618 retval = sh_error_set_level (tmp, &ShUtmpLogout); 619 SH_MUTEX_UNLOCK(mutex_thread_nolog); 606 620 SL_RETURN(retval, _("sh_utmp_set_logout_good")); 607 621 } … … 616 630 if (val <= 0) 617 631 { 632 SH_MUTEX_LOCK(mutex_thread_nolog); 618 633 sh_error_handle ((-1), FIL__, __LINE__, EINVAL, MSG_EINVALS, 619 634 _("utmp timer"), c); 635 SH_MUTEX_UNLOCK(mutex_thread_nolog); 620 636 retval = -1; 621 637 } … … 823 839 ) { 824 840 status = sh_utmp_login_a(user->name); 841 SH_MUTEX_LOCK(mutex_thread_nolog); 825 842 (void) sh_unix_time (user->time, ttt, TIM_MAX); 826 843 sh_error_handle( ShUtmpLoginSolo, FIL__, __LINE__, 0, … … 843 860 status 844 861 ); 862 SH_MUTEX_UNLOCK(mutex_thread_nolog); 845 863 } else 846 864 if (0 != sh_utmp_is_virtual(ut->ut_line, user->ut_host)) 847 865 { 848 866 status = sh_utmp_login_a(user->name); 867 SH_MUTEX_LOCK(mutex_thread_nolog); 849 868 (void) sh_unix_time (user->time, ttt, TIM_MAX); 850 869 sh_error_handle( ShUtmpLoginMulti, FIL__, __LINE__, 0, … … 867 886 status 868 887 ); 888 SH_MUTEX_UNLOCK(mutex_thread_nolog); 869 889 } 870 890 … … 882 902 { 883 903 status = sh_utmp_login_r(user->name); 904 SH_MUTEX_LOCK(mutex_thread_nolog); 884 905 (void) sh_unix_time (ut->ut_time, ttt, TIM_MAX); 885 906 sh_error_handle( ShUtmpLogout, FIL__, __LINE__, 0, … … 902 923 status 903 924 ); 925 SH_MUTEX_UNLOCK(mutex_thread_nolog); 904 926 userold->next = user->next; 905 927 if (user == userlist) … … 912 934 { 913 935 (void) sl_strlcpy(terminated_line, ut->ut_line, UT_HOSTSIZE); 936 SH_MUTEX_LOCK(mutex_thread_nolog); 914 937 (void) sh_unix_time (ut->ut_time, ttt, TIM_MAX); 915 938 sh_error_handle( ShUtmpLogout, FIL__, __LINE__, 0, … … 918 941 ttt, 0 919 942 ); 943 SH_MUTEX_UNLOCK(mutex_thread_nolog); 920 944 } 921 945 SL_RET0(_("sh_utmp_addlogin")); … … 943 967 userlist = user; 944 968 969 SH_MUTEX_LOCK(mutex_thread_nolog); 945 970 (void) sh_unix_time (user->time, ttt, TIM_MAX); 946 947 948 971 sh_error_handle( ShUtmpLoginSolo, FIL__, __LINE__, 0, 949 972 #if defined(HAVE_UTHOST) && defined(HAVE_UTADDR) … … 965 988 1 966 989 ); 990 SH_MUTEX_UNLOCK(mutex_thread_nolog); 967 991 sh_utmp_login_morechecks(ut); 968 992 } 969 993 else /* probably a logout */ 970 994 { 995 SH_MUTEX_LOCK(mutex_thread_nolog); 971 996 (void) sh_unix_time (ut->ut_time, ttt, TIM_MAX); 972 973 997 sh_error_handle( ShUtmpLogout, FIL__, __LINE__, 0, 974 998 #if defined(HAVE_UTHOST) && defined(HAVE_UTADDR) … … 990 1014 1 991 1015 ); 1016 SH_MUTEX_UNLOCK(mutex_thread_nolog); 992 1017 sh_utmp_logout_morechecks(user); 993 1018 userold->next = user->next; … … 1014 1039 struct SH_UTMP_S * ut; 1015 1040 unsigned long this_read = 0; 1041 int val_retry; 1016 1042 1017 1043 SL_ENTER(_("sh_utmp_check_internal")); … … 1019 1045 /* error if no access 1020 1046 */ 1021 if (0 != retry_lstat(FIL__, __LINE__, mode_path[mode], &buf)) 1047 do { 1048 val_retry = /*@-unrecog@*/lstat ( mode_path[mode], &buf)/*@+unrecog@*/; 1049 } while (val_retry < 0 && errno == EINTR); 1050 1051 if (0 != val_retry) 1022 1052 { 1023 1053 error = errno; 1054 SH_MUTEX_LOCK(mutex_thread_nolog); 1024 1055 sh_error_handle((-1), FIL__, __LINE__, error, MSG_E_ACCESS, 1025 1056 (long) sh.real.uid, mode_path[mode]); 1057 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1026 1058 SL_RET0(_("sh_utmp_check_internal")); 1027 1059 } … … 1043 1075 if (/*@-usedef@*/buf.st_size < lastsize/*@+usedef@*/ && mode < 2) 1044 1076 { 1077 SH_MUTEX_LOCK(mutex_thread_nolog); 1045 1078 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_UT_ROT, 1046 1079 mode_path[mode]); 1080 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1047 1081 lastread = 0; 1048 1082 #ifndef USE_SETUTENT
Note:
See TracChangeset
for help on using the changeset viewer.