Changeset 259
- Timestamp:
- Dec 7, 2009, 8:44:43 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile.in
r257 r259 123 123 sh_mounts.h sh_userfiles.h sh_static.h sh_prelink.h \ 124 124 sh_processcheck.h sh_portcheck.h sh_pthread.h sh_string.h \ 125 sh_log_check.h sh_log_evalrule.h 125 sh_log_check.h sh_log_evalrule.h sh_inotify.h 126 126 127 127 … … 162 162 $(srcsrc)/sh_log_parse_apache.c $(srcsrc)/sh_log_evalrule.c \ 163 163 $(srcsrc)/sh_log_check.c $(srcsrc)/dnmalloc.c \ 164 $(srcsrc)/sh_inotify.c \ 164 165 $(srcsrc)/t-test1.c 165 166 … … 178 179 sh_log_parse_syslog.o sh_log_parse_pacct.o sh_log_parse_apache.o \ 179 180 sh_log_parse_samba.o sh_log_evalrule.o sh_log_check.o \ 180 sh_pthread.o sh_string.o dnmalloc.o181 sh_pthread.o sh_string.o sh_inotify.o dnmalloc.o 181 182 182 183 KERN = kern_head.h kern_head.c … … 1676 1677 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_nmail.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 1677 1678 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 $(srcinc)/sh_logmon.h 1678 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 1679 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 $(srcinc)/sh_inotify.h 1679 1680 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 1680 1681 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 … … 1732 1733 sh_nmail.o: $(srcsrc)/sh_nmail.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_mem.h $(srcinc)/sh_mail.h $(srcinc)/sh_tiger.h $(srcinc)/sh_string.h $(srcinc)/sh_utils.h $(srcinc)/sh_fifo.h $(srcinc)/sh_filter.h $(srcinc)/sh_mail_int.h $(srcinc)/zAVLTree.h 1733 1734 sh_filter.o: $(srcsrc)/sh_filter.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_mem.h $(srcinc)/sh_filter.h 1735 sh_inotify.o: $(srcsrc)/sh_inotify.c Makefile config_xor.h $(srcinc)/sh_pthread.h $(srcinc)/sh_calls.h $(srcinc)/sh_inotify.h $(srcinc)/sh_mem.h $(srcinc)/slib.h $(srcinc)/sh_calls.h -
trunk/configure.ac
r257 r259 222 222 223 223 AC_CHECK_HEADERS(stddef.h libgen.h sched.h malloc.h sys/uio.h \ 224 sys/mman.h sys/param.h \224 sys/mman.h sys/param.h sys/inotify.h \ 225 225 sys/vfs.h mntent.h \ 226 226 sys/select.h sys/socket.h netinet/in.h \ … … 370 370 strerror_r getgrgid_r getpwnam_r getpwuid_r \ 371 371 gmtime_r localtime_r rand_r readdir_r strtok_r \ 372 mincore posix_fadvise 372 mincore posix_fadvise inotify_init1 373 373 ) 374 374 AC_CHECK_FUNC(statfs, AC_DEFINE(HAVE_STATFS) statfs="yes", statfs="no") -
trunk/depend.dep
r230 r259 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_nmail.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 $(srcinc)/sh_logmon.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 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 $(srcinc)/sh_inotify.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 … … 77 77 sh_nmail.o: $(srcsrc)/sh_nmail.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_mem.h $(srcinc)/sh_mail.h $(srcinc)/sh_tiger.h $(srcinc)/sh_string.h $(srcinc)/sh_utils.h $(srcinc)/sh_fifo.h $(srcinc)/sh_filter.h $(srcinc)/sh_mail_int.h $(srcinc)/zAVLTree.h 78 78 sh_filter.o: $(srcsrc)/sh_filter.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_mem.h $(srcinc)/sh_filter.h 79 sh_inotify.o: $(srcsrc)/sh_inotify.c Makefile config_xor.h $(srcinc)/sh_pthread.h $(srcinc)/sh_calls.h $(srcinc)/sh_inotify.h $(srcinc)/sh_mem.h $(srcinc)/slib.h $(srcinc)/sh_calls.h -
trunk/depend.sum
r230 r259 1 32987386531 2870675903 -
trunk/docs/Changelog
r258 r259 1 2.6.1: 2 * use inotify to track login/logout (sh_inotify.c, sh_utmp.c) 3 1 4 2.6.0: 2 5 * don't use statvfs() for process checking on FreeBSD … … 8 11 * By default disable scanning ..namedfork/rsrc (deprecated by Apple) 9 12 10 2.5.10 :13 2.5.10 (12-10-2009): 11 14 * sh_suidchk.c: handle $HOME/.gvfs mount gracefully 12 15 * slib.c: fix race condition caused by closing a stream and the fd 13 16 14 2.5.9c :17 2.5.9c (01-10-2009): 15 18 * move stale file record error message closer to problem zone 16 19 * sh_port2proc.c: fix flawed logic for interpreting /proc/net/udp,tcp 17 20 18 2.5.9b :21 2.5.9b (22-09-2009): 19 22 * remove stale file record when creating handle, and raise diagnostic 20 23 error to find origin of stale record 21 24 * sh_port2proc.c: check /proc/net/upd6 for IPv6-only UDP sockets 22 25 23 2.5.9a :26 2.5.9a (17-09-2009): 24 27 * fixed a race condition in closing of file handles 25 28 -
trunk/include/sh_modules.h
r253 r259 4 4 5 5 #include "sh_pthread.h" 6 7 enum 8 { 9 SH_MODFL_NOTIMER = (1 << 0) 10 }; 11 6 12 7 13 typedef struct rconf … … 18 24 /* Set by samhain to 1 on successful initialization, else 0 */ 19 25 int initval; 26 27 /* Flags: SH_MOD_NOTIMER */ 28 int flags; 20 29 21 30 /* The initialization function. Return 0 on success. */ -
trunk/src/sh_modules.c
r186 r259 23 23 N_("UTMP"), 24 24 -1, 25 SH_MODFL_NOTIMER, 25 26 sh_utmp_init, 26 27 sh_utmp_timer, … … 39 40 N_("MOUNTS"), 40 41 -1, 42 0, 41 43 sh_mounts_init, 42 44 sh_mounts_timer, … … 55 57 N_("USERFILES"), 56 58 -1, 59 0, 57 60 sh_userfiles_init, 58 61 sh_userfiles_timer, … … 71 74 N_("KERNEL"), 72 75 -1, 76 0, 73 77 sh_kern_init, 74 78 sh_kern_timer, … … 87 91 N_("SUIDCHECK"), 88 92 -1, 93 0, 89 94 sh_suidchk_init, 90 95 sh_suidchk_timer, … … 103 108 N_("PROCESSCHECK"), 104 109 -1, 110 0, 105 111 sh_prochk_init, 106 112 sh_prochk_timer, … … 119 125 N_("PORTCHECK"), 120 126 -1, 127 0, 121 128 sh_portchk_init, 122 129 sh_portchk_timer, … … 135 142 N_("LOGMON"), 136 143 -1, 144 0, 137 145 sh_log_check_init, 138 146 sh_log_check_timer, … … 150 158 NULL, 151 159 -1, 160 0, 152 161 153 162 NULL, -
trunk/src/sh_pthread.c
r170 r259 182 182 pthread_testcancel(); 183 183 } 184 retry_msleep(1,0); 184 if (0 == (SH_MODFL_NOTIMER & this_module->flags)) 185 retry_msleep(1,0); 185 186 } 186 187 -
trunk/src/sh_utmp.c
r252 r259 80 80 #include "sh_utmp.h" 81 81 #include "sh_pthread.h" 82 #include "sh_inotify.h" 82 83 83 84 SH_MUTEX_EXTERN(mutex_thread_nolog); … … 186 187 static char terminated_line[UT_HOSTSIZE]; 187 188 #endif 189 190 static char * mode_path[] = { _PATH_WTMP, _PATH_WTMP, _PATH_UTMP }; 188 191 189 192 static struct SH_UTMP_S save_utmp; … … 519 522 #endif 520 523 524 #if defined(HAVE_PTHREAD) 525 static sh_watches inotify_watch; 526 #endif 527 521 528 int sh_utmp_end () 522 529 { … … 540 547 set_defaults(); 541 548 init_done = 0; 549 550 sh_inotify_remove(&inotify_watch); 551 542 552 SL_RETURN( (0), _("sh_utmp_end")); 543 553 } 544 554 555 545 556 int sh_utmp_reconf() 546 557 { 547 558 set_defaults(); 559 sh_inotify_remove(&inotify_watch); 548 560 return 0; 549 561 } … … 557 569 int sh_utmp_timer (time_t tcurrent) 558 570 { 571 #if !defined(HAVE_PTHREAD) 572 retry_msleep(1, 0); 573 559 574 if ((time_t) (tcurrent - lastcheck) >= ShUtmpInterval) 560 575 { … … 563 578 } 564 579 return 0; 580 #else 581 int errnum = 0; 582 583 if (sh.flag.checkSum != SH_CHECK_INIT) 584 sh_inotify_wait_for_change(mode_path[1], &inotify_watch, 585 &errnum, ShUtmpInterval); 586 587 lastcheck = tcurrent; 588 if (SH_INOTIFY_ERROR(errnum)) 589 { 590 char ebuf[SH_ERRBUF_SIZE]; 591 592 SH_MUTEX_LOCK(mutex_thread_nolog); 593 sh_error_message(errnum, ebuf, sizeof(ebuf)); 594 sh_error_handle (SH_ERR_WARN, FIL__, __LINE__, errnum, MSG_E_SUBGEN, 595 ebuf, 596 _("sh_utmp_timer") ); 597 SH_MUTEX_UNLOCK(mutex_thread_nolog); 598 } 599 return -1; 600 #endif 565 601 } 566 602 … … 574 610 SL_ENTER(_("sh_utmp_check")); 575 611 if (ShUtmpActive == BAD) 576 SL_RETURN( (-1), _("sh_utmp_check")); 612 { 613 #if defined(HAVE_PTHREAD) 614 sh_inotify_remove(&inotify_watch); 615 #endif 616 SL_RETURN( (-1), _("sh_utmp_check")); 617 } 577 618 SH_MUTEX_LOCK(mutex_thread_nolog); 578 619 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_UT_CHECK); … … 746 787 * - link user.ut_record -> log_record 747 788 */ 789 748 790 #ifdef HAVE_UTTYPE 749 791 static int sh_utmp_is_virtual (char * in_utline, char * in_uthost) 750 792 { 751 if (in_utline != NULL) 752 { 753 if (0 == sl_strncmp(in_utline, _("ttyp"), 4)) 754 { return 0; } 755 else if (0 == sl_strncmp(in_utline, _("ttyq"), 4)) 756 { return 0; } 757 } 758 if (in_uthost != NULL && 793 794 if (in_uthost != NULL && 795 in_utline != NULL && 759 796 in_uthost[0] == ':' && 760 797 in_uthost[1] == '0' && 761 in_uthost[2] == '\0')762 { 763 /* return 0; */764 return 1; /* actually does not seem portable, not even among linuxes */765 } 766 return 1;798 0 == sl_strncmp(in_utline, _("pts/"), 4)) 799 { 800 return 1; 801 } 802 803 return 0; 767 804 } 768 805 #endif … … 884 921 SH_MUTEX_UNLOCK(mutex_thread_nolog); 885 922 } else 886 if (0 != sh_utmp_is_virtual(ut->ut_line, (char*)user->ut_host))923 if (0 == sh_utmp_is_virtual(ut->ut_line, (char*)user->ut_host)) 887 924 { 888 925 status = sh_utmp_login_a((char*)user->name); … … 923 960 if (user != NULL) 924 961 { 925 status = sh_utmp_login_r((char*)user->name); 926 SH_MUTEX_LOCK(mutex_thread_nolog); 927 (void) sh_unix_time (ut->ut_time, ttt, TIM_MAX); 928 sh_error_handle( ShUtmpLogout, FIL__, __LINE__, 0, 962 #if defined(__linux__) 963 if (0 == sh_utmp_is_virtual(ut->ut_line, (char*)user->ut_host)) { 964 #endif 965 status = sh_utmp_login_r((char*)user->name); 966 SH_MUTEX_LOCK(mutex_thread_nolog); 967 (void) sh_unix_time (ut->ut_time, ttt, TIM_MAX); 968 sh_error_handle( ShUtmpLogout, FIL__, __LINE__, 0, 929 969 #if defined(HAVE_UTHOST) && defined(HAVE_UTADDR) 930 MSG_UT_LG3X,970 MSG_UT_LG3X, 931 971 #elif defined(HAVE_UTHOST) 932 MSG_UT_LG3A,933 #else 934 MSG_UT_LG3B,935 #endif 936 user->name,937 user->ut_tty,972 MSG_UT_LG3A, 973 #else 974 MSG_UT_LG3B, 975 #endif 976 user->name, 977 user->ut_tty, 938 978 #if defined(HAVE_UTHOST) && defined(HAVE_UTADDR) 939 user->ut_host,940 user->ut_ship,979 user->ut_host, 980 user->ut_ship, 941 981 #elif defined(HAVE_UTHOST) 942 user->ut_host, 943 #endif 944 ttt, 945 status 946 ); 947 SH_MUTEX_UNLOCK(mutex_thread_nolog); 948 userold->next = user->next; 949 if (user == userlist) 950 userlist = user->next; 951 sh_utmp_logout_morechecks((struct log_user *)user); 952 SH_FREE((struct log_user *)user); 953 user = NULL; 982 user->ut_host, 983 #endif 984 ttt, 985 status 986 ); 987 SH_MUTEX_UNLOCK(mutex_thread_nolog); 988 userold->next = user->next; 989 if (user == userlist) 990 userlist = user->next; 991 sh_utmp_logout_morechecks((struct log_user *)user); 992 SH_FREE((struct log_user *)user); 993 user = NULL; 994 #if defined(__linux__) 995 } 996 #endif 954 997 } 955 998 else … … 1053 1096 static unsigned long lastread = 0; 1054 1097 1055 static char * mode_path[] = { _PATH_WTMP, _PATH_WTMP, _PATH_UTMP };1056 1057 1098 static void sh_utmp_check_internal (int mode) 1058 1099 {
Note:
See TracChangeset
for help on using the changeset viewer.