Changeset 740 for vendor/current/source3/lib/username.c
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/lib/username.c
r414 r740 4 4 Copyright (C) Andrew Tridgell 1992-1998 5 5 Copyright (C) Jeremy Allison 1997-2001. 6 6 Copyright (C) Andrew Bartlett 2002 7 7 8 This program is free software; you can redistribute it and/or modify 8 9 it under the terms of the GNU General Public License as published by 9 10 the Free Software Foundation; either version 3 of the License, or 10 11 (at your option) any later version. 11 12 12 13 This program is distributed in the hope that it will be useful, 13 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 16 GNU General Public License for more details. 16 17 17 18 You should have received a copy of the GNU General Public License 18 19 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 20 21 21 22 #include "includes.h" 23 #include "system/passwd.h" 24 #include "memcache.h" 25 #include "../lib/util/util_pw.h" 22 26 23 27 /* internal functions */ … … 29 33 int N); 30 34 35 static struct passwd *getpwnam_alloc_cached(TALLOC_CTX *mem_ctx, const char *name) 36 { 37 struct passwd *pw, *for_cache; 38 39 pw = (struct passwd *)memcache_lookup_talloc( 40 NULL, GETPWNAM_CACHE, data_blob_string_const_null(name)); 41 if (pw != NULL) { 42 return tcopy_passwd(mem_ctx, pw); 43 } 44 45 pw = sys_getpwnam(name); 46 if (pw == NULL) { 47 return NULL; 48 } 49 50 for_cache = tcopy_passwd(talloc_tos(), pw); 51 if (for_cache == NULL) { 52 return NULL; 53 } 54 55 memcache_add_talloc(NULL, GETPWNAM_CACHE, 56 data_blob_string_const_null(name), &for_cache); 57 58 return tcopy_passwd(mem_ctx, pw); 59 } 60 61 /**************************************************************************** 62 Flush all cached passwd structs. 63 ****************************************************************************/ 64 65 void flush_pwnam_cache(void) 66 { 67 memcache_flush(NULL, GETPWNAM_CACHE); 68 } 69 31 70 /**************************************************************************** 32 71 Get a users home directory. … … 76 115 strlower_m(user2); 77 116 DEBUG(5,("Trying _Get_Pwnam(), username as lowercase is %s\n",user2)); 78 ret = getpwnam_alloc (mem_ctx, user2);117 ret = getpwnam_alloc_cached(mem_ctx, user2); 79 118 if(ret) 80 119 goto done; … … 84 123 DEBUG(5,("Trying _Get_Pwnam(), username as given is %s\n", 85 124 user)); 86 ret = getpwnam_alloc (mem_ctx, user);125 ret = getpwnam_alloc_cached(mem_ctx, user); 87 126 if(ret) 88 127 goto done; … … 94 133 DEBUG(5,("Trying _Get_Pwnam(), username as uppercase is %s\n", 95 134 user2)); 96 ret = getpwnam_alloc (mem_ctx, user2);135 ret = getpwnam_alloc_cached(mem_ctx, user2); 97 136 if(ret) 98 137 goto done; … … 103 142 DEBUG(5,("Checking combinations of %d uppercase letters in %s\n", 104 143 lp_usernamelevel(), user2)); 105 ret = uname_string_combinations(user2, mem_ctx, getpwnam_alloc ,144 ret = uname_string_combinations(user2, mem_ctx, getpwnam_alloc_cached, 106 145 lp_usernamelevel()); 107 146 … … 122 161 { 123 162 fstring user2; 124 struct passwd *ret;125 163 126 164 if ( *user == '\0' ) { … … 133 171 DEBUG(5,("Finding user %s\n", user)); 134 172 135 ret = Get_Pwnam_internals(mem_ctx, user, user2); 136 137 return ret; 173 return Get_Pwnam_internals(mem_ctx, user, user2); 138 174 } 139 175 … … 161 197 for (i=offset;i<(len-(N-1));i++) { 162 198 char c = s[i]; 163 if (!islower_ ascii((int)c))199 if (!islower_m((int)c)) 164 200 continue; 165 s[i] = toupper_ ascii(c);201 s[i] = toupper_m(c); 166 202 ret = uname_string_combinations2(s, mem_ctx, i+1, fn, N-1); 167 203 if(ret)
Note:
See TracChangeset
for help on using the changeset viewer.