- Timestamp:
- Dec 7, 2009, 8:44:43 PM (15 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
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.