Changeset 143 for trunk/src/sh_utmp.c
- Timestamp:
- Oct 31, 2007, 1:09:26 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.