summaryrefslogtreecommitdiff
path: root/source4/libcli/resolve
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-08-31 12:07:07 +1000
committerAndrew Tridgell <tridge@samba.org>2010-09-02 13:37:08 +1000
commitefbc702b1eac7c35b0d64d45a8043db3642361a0 (patch)
tree90258e2a7d03a126ba477cbd9b3328e6c06dc59c /source4/libcli/resolve
parent39599e949b9231fa5d88b1a6830b442c1faba1d9 (diff)
downloadsamba-efbc702b1eac7c35b0d64d45a8043db3642361a0.tar.gz
samba-efbc702b1eac7c35b0d64d45a8043db3642361a0.tar.bz2
samba-efbc702b1eac7c35b0d64d45a8043db3642361a0.zip
s4-resolve: add a default domain for unqualified names in file backend
this better emulates what happens with real DNS
Diffstat (limited to 'source4/libcli/resolve')
-rw-r--r--source4/libcli/resolve/file.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/source4/libcli/resolve/file.c b/source4/libcli/resolve/file.c
index c01b462909..9d64f35d42 100644
--- a/source4/libcli/resolve/file.c
+++ b/source4/libcli/resolve/file.c
@@ -33,6 +33,7 @@
struct resolve_file_data {
const char *lookup_file;
+ const char *default_domain;
};
struct resolve_file_state {
@@ -57,6 +58,7 @@ struct composite_context *resolve_name_file_send(TALLOC_CTX *mem_ctx,
struct resolve_file_state *state;
struct sockaddr_storage *resolved_iplist;
int resolved_count, i;
+ char *dns_name;
bool srv_lookup = (flags & RESOLVE_NAME_FLAG_DNS_SRV);
@@ -79,8 +81,13 @@ struct composite_context *resolve_name_file_send(TALLOC_CTX *mem_ctx,
if (composite_nomem(state, c)) return c;
c->private_data = state;
+ dns_name = name->name;
+ if (strchr(dns_name, '.') == NULL) {
+ dns_name = talloc_asprintf(state, "%s.%s", dns_name, data->default_domain);
+ }
- c->status = resolve_dns_hosts_file_as_sockaddr(data->lookup_file, name->name, srv_lookup, state, &resolved_iplist, &resolved_count);
+ c->status = resolve_dns_hosts_file_as_sockaddr(data->lookup_file, dns_name,
+ srv_lookup, state, &resolved_iplist, &resolved_count);
if (!composite_is_ok(c)) return c;
for (i=0; i < resolved_count; i++) {
@@ -100,7 +107,7 @@ struct composite_context *resolve_name_file_send(TALLOC_CTX *mem_ctx,
state->names = talloc_realloc(state, state->names, char *, i+2);
if (composite_nomem(state->addrs, c)) return c;
- state->names[i] = talloc_strdup(state->names, name->name);
+ state->names[i] = talloc_strdup(state->names, dns_name);
if (composite_nomem(state->names[i], c)) return c;
state->names[i+1] = NULL;
@@ -137,14 +144,17 @@ NTSTATUS resolve_name_file_recv(struct composite_context *c,
}
-bool resolve_context_add_file_method(struct resolve_context *ctx, const char *lookup_file)
+bool resolve_context_add_file_method(struct resolve_context *ctx, const char *lookup_file, const char *default_domain)
{
struct resolve_file_data *data = talloc(ctx, struct resolve_file_data);
- data->lookup_file = lookup_file;
+ data->lookup_file = talloc_strdup(data, lookup_file);
+ data->default_domain = talloc_strdup(data, default_domain);
return resolve_context_add_method(ctx, resolve_name_file_send, resolve_name_file_recv, data);
}
bool resolve_context_add_file_method_lp(struct resolve_context *ctx, struct loadparm_context *lp_ctx)
{
- return resolve_context_add_file_method(ctx, lpcfg_parm_string(lp_ctx, NULL, "resolv", "host file"));
+ return resolve_context_add_file_method(ctx,
+ lpcfg_parm_string(lp_ctx, NULL, "resolv", "host file"),
+ lpcfg_dnsdomain(lp_ctx));
}