- Timestamp:
- Sep 16, 2018, 8:56:38 PM (6 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_hash.c
r516 r534 24 24 #include <stdio.h> 25 25 #include <sys/types.h> 26 #ifdef HAVE_SYS_SYSMACROS_H 27 #include <sys/sysmacros.h> 28 #endif 26 29 #include <sys/stat.h> 27 30 #include <unistd.h> -
trunk/src/sh_unix.c
r516 r534 2827 2827 2828 2828 /* --------- end caching code --------- */ 2829 2829 2830 #include "sh_subuid.h" 2831 2830 2832 char * sh_unix_getUIDname (int level, uid_t uid, char * out, size_t len) 2831 2833 { … … 2863 2865 status = errno; 2864 2866 #endif 2865 2866 if (tempres == NULL) 2867 { 2868 sh_error_handle (level, FIL__, __LINE__, EINVAL, MSG_E_PWNULL, 2869 sh_error_message(status, errbuf, sizeof(errbuf)), 2870 _("getpwuid"), (long) uid, _("completely missing")); 2871 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2872 SH_FREE(buffer); 2873 #endif 2874 sh_userid_add(uid, NULL, CACHE_UID); 2875 SL_RETURN( NULL, _("sh_unix_getUIDname")); 2876 } 2877 2878 2879 if (tempres->pw_name != NULL) 2867 2868 /* case 1: we have it 2869 */ 2870 if (tempres && tempres->pw_name != NULL) 2880 2871 { 2881 2872 … … 2888 2879 2889 2880 SL_RETURN( out, _("sh_unix_getUIDname")); 2890 } 2891 else 2892 { 2881 } 2882 2883 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2884 SH_FREE(buffer); 2885 #endif 2886 2887 if (tempres == NULL) 2888 { 2889 char * pwname = sh_get_subuid ((unsigned long) uid); 2890 2891 if (pwname) 2892 { 2893 sl_strlcpy(out, pwname, len); 2894 sh_userid_add(uid, out, CACHE_UID); 2895 SL_RETURN( out, _("sh_unix_getUIDname")); 2896 } 2897 2893 2898 sh_error_handle (level, FIL__, __LINE__, EINVAL, MSG_E_PWNULL, 2894 2899 sh_error_message(status, errbuf, sizeof(errbuf)), 2895 _("getpwuid"), (long) uid, _("pw_user")); 2896 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2897 SH_FREE(buffer); 2898 #endif 2900 _("getpwuid"), (long) uid, _("completely missing")); 2901 sh_userid_add(uid, NULL, CACHE_UID); 2899 2902 SL_RETURN( NULL, _("sh_unix_getUIDname")); 2900 2903 } 2901 /* notreached */ 2904 2905 2906 /* getwpuid returns struct, but no pw_name 2907 */ 2908 sh_error_handle (level, FIL__, __LINE__, EINVAL, MSG_E_PWNULL, 2909 sh_error_message(status, errbuf, sizeof(errbuf)), 2910 _("getpwuid"), (long) uid, _("pw_user")); 2911 SL_RETURN( NULL, _("sh_unix_getUIDname")); 2902 2912 } 2903 2913 … … 2959 2969 } 2960 2970 2961 if (tempres == NULL) 2962 { 2963 sh_error_handle (level, FIL__, __LINE__, EINVAL, MSG_E_GRNULL, 2964 sh_error_message(status, errbuf, sizeof(errbuf)), 2965 _("getgrgid"), (long) gid, _("completely missing")); 2966 2967 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2968 SH_FREE(buffer); 2969 #endif 2970 2971 sh_userid_add(gid, NULL, CACHE_GID); 2972 SL_RETURN( NULL, _("sh_unix_getGIDname")); 2973 } 2974 2975 if (tempres->gr_name != NULL) 2971 if (tempres && tempres->gr_name != NULL) 2976 2972 { 2977 2973 … … 2985 2981 SL_RETURN( out, _("sh_unix_getGIDname")); 2986 2982 } 2987 else 2988 { 2983 2984 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2985 SH_FREE(buffer); 2986 #endif 2987 2988 if (tempres == NULL) 2989 { 2990 char * grname = sh_get_subgid ((unsigned long) gid); 2991 2992 if (grname) 2993 { 2994 sl_strlcpy(out, grname, len); 2995 sh_userid_add((uid_t)gid, out, CACHE_GID); 2996 SL_RETURN( out, _("sh_unix_getGIDname")); 2997 } 2998 2989 2999 sh_error_handle (level, FIL__, __LINE__, EINVAL, MSG_E_GRNULL, 2990 3000 sh_error_message(status, errbuf, sizeof(errbuf)), 2991 _("getgrgid"), (long) gid, _("gr_name")); 2992 2993 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2994 SH_FREE(buffer); 2995 #endif 2996 3001 _("getgrgid"), (long) gid, _("completely missing")); 3002 sh_userid_add(gid, NULL, CACHE_GID); 2997 3003 SL_RETURN( NULL, _("sh_unix_getGIDname")); 2998 3004 } 2999 /* notreached */ 3005 3006 sh_error_handle (level, FIL__, __LINE__, EINVAL, MSG_E_GRNULL, 3007 sh_error_message(status, errbuf, sizeof(errbuf)), 3008 _("getgrgid"), (long) gid, _("gr_name")); 3009 SL_RETURN( NULL, _("sh_unix_getGIDname")); 3000 3010 } 3001 3011 … … 3066 3076 } 3067 3077 3068 3078 /* return >0 on success, -1 on EOF */ 3069 3079 int sh_unix_getline (SL_TICKET fd, char * line, int sizeofline) 3070 3080 {
Note:
See TracChangeset
for help on using the changeset viewer.