summaryrefslogtreecommitdiff
path: root/source3/libsmb/namequery.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-04-26 12:08:22 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-04-27 11:40:18 +1000
commite130dec97bb4e08b11f39c1c1382f0c8ad36ef67 (patch)
tree23a24bce465618eb7dc6a6f52c9b92e02e582540 /source3/libsmb/namequery.c
parent806eef63ba6ee9681f89accea262a0c2fa3c8038 (diff)
downloadsamba-e130dec97bb4e08b11f39c1c1382f0c8ad36ef67.tar.gz
samba-e130dec97bb4e08b11f39c1c1382f0c8ad36ef67.tar.bz2
samba-e130dec97bb4e08b11f39c1c1382f0c8ad36ef67.zip
s3-libsmb Use 'resolv:hosts file' as a DNS emulation when specified.
This allows make test to operate without making real DNS calls. Andrew Bartlett
Diffstat (limited to 'source3/libsmb/namequery.c')
-rw-r--r--source3/libsmb/namequery.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 752b4b1eb9..16669c0532 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -1738,6 +1738,7 @@ static NTSTATUS resolve_hosts(const char *name, int name_type,
struct addrinfo *res = NULL;
int ret = -1;
int i = 0;
+ const char *dns_hosts_file;
if ( name_type != 0x20 && name_type != 0x0) {
DEBUG(5, ("resolve_hosts: not appropriate "
@@ -1762,6 +1763,32 @@ static NTSTATUS resolve_hosts(const char *name, int name_type,
hints.ai_family = AF_INET;
#endif
+ dns_hosts_file = lp_parm_const_string(-1, "resolv", "host file", NULL);
+ if (dns_hosts_file) {
+ struct sockaddr_storage *ss_list;
+ NTSTATUS status;
+ TALLOC_CTX *ctx = talloc_stackframe();
+ if (!ctx) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = resolve_dns_hosts_file_as_sockaddr(dns_hosts_file, name, false,
+ ctx, &ss_list, return_count);
+ if (NT_STATUS_IS_OK(status)) {
+ if (convert_ss2service(return_iplist,
+ ss_list,
+ *return_count)) {
+ talloc_free(ctx);
+ return NT_STATUS_OK;
+ } else {
+ talloc_free(ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+ }
+ talloc_free(ctx);
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
ret = getaddrinfo(name,
NULL,
&hints,