Changeset 740 for vendor/current/libcli/nbt/lmhosts.c
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/libcli/nbt/lmhosts.c
r414 r740 27 27 #include "system/filesys.h" 28 28 #include "system/network.h" 29 #include "../libcli/nbt/libnbt.h" 29 30 30 31 /******************************************************** … … 156 157 } 157 158 159 /******************************************************** 160 Resolve via "lmhosts" method. 161 *********************************************************/ 162 163 NTSTATUS resolve_lmhosts_file_as_sockaddr(const char *lmhosts_file, 164 const char *name, int name_type, 165 TALLOC_CTX *mem_ctx, 166 struct sockaddr_storage **return_iplist, 167 int *return_count) 168 { 169 /* 170 * "lmhosts" means parse the local lmhosts file. 171 */ 172 173 XFILE *fp; 174 char *lmhost_name = NULL; 175 int name_type2; 176 struct sockaddr_storage return_ss; 177 NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND; 178 TALLOC_CTX *ctx = NULL; 179 180 *return_iplist = NULL; 181 *return_count = 0; 182 183 DEBUG(3,("resolve_lmhosts: " 184 "Attempting lmhosts lookup for name %s<0x%x>\n", 185 name, name_type)); 186 187 fp = startlmhosts(lmhosts_file); 188 189 if ( fp == NULL ) 190 return NT_STATUS_NO_SUCH_FILE; 191 192 ctx = talloc_new(mem_ctx); 193 if (!ctx) { 194 endlmhosts(fp); 195 return NT_STATUS_NO_MEMORY; 196 } 197 198 while (getlmhostsent(ctx, fp, &lmhost_name, &name_type2, &return_ss)) { 199 200 if (!strequal(name, lmhost_name)) { 201 TALLOC_FREE(lmhost_name); 202 continue; 203 } 204 205 if ((name_type2 != -1) && (name_type != name_type2)) { 206 TALLOC_FREE(lmhost_name); 207 continue; 208 } 209 210 *return_iplist = talloc_realloc(ctx, (*return_iplist), 211 struct sockaddr_storage, 212 (*return_count)+1); 213 214 if ((*return_iplist) == NULL) { 215 TALLOC_FREE(ctx); 216 endlmhosts(fp); 217 DEBUG(3,("resolve_lmhosts: talloc_realloc fail !\n")); 218 return NT_STATUS_NO_MEMORY; 219 } 220 221 (*return_iplist)[*return_count] = return_ss; 222 *return_count += 1; 223 224 /* we found something */ 225 status = NT_STATUS_OK; 226 227 /* Multiple names only for DC lookup */ 228 if (name_type != 0x1c) 229 break; 230 } 231 232 talloc_steal(mem_ctx, *return_iplist); 233 TALLOC_FREE(ctx); 234 endlmhosts(fp); 235 return status; 236 } 237
Note:
See TracChangeset
for help on using the changeset viewer.