summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2014-07-30 08:40:32 +0200
committerKarolin Seeger <kseeger@samba.org>2014-09-08 07:49:10 +0200
commit07f72fc989969951e219f1ba09812ab562cfbc43 (patch)
tree670c2e989bab016f884feb9f53bf5f832653d196 /source4
parent4f7d4fd6a216e2cfed42eb0aa727c9a0e5c7b577 (diff)
downloadsamba-07f72fc989969951e219f1ba09812ab562cfbc43.tar.gz
s4:dlz_bind9: let dlz_bind9 use dns_common_lookup() for name lookup
Bug: https://bugzilla.samba.org/show_bug.cgi?id=10749 Change-Id: I2632fa0ce120a978f6f400fa5cbf18a7fbbd64a3 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> (cherry picked from commit 96dcebe8c20b9aa954a96a4deabe16957576be2c)
Diffstat (limited to 'source4')
-rw-r--r--source4/dns_server/dlz_bind9.c68
-rw-r--r--source4/dns_server/wscript_build6
2 files changed, 21 insertions, 53 deletions
diff --git a/source4/dns_server/dlz_bind9.c b/source4/dns_server/dlz_bind9.c
index 01700a55e12..5cb9428a148 100644
--- a/source4/dns_server/dlz_bind9.c
+++ b/source4/dns_server/dlz_bind9.c
@@ -37,7 +37,7 @@
#include "messaging/messaging.h"
#include "lib/cmdline/popt_common.h"
#include "dlz_minimal.h"
-
+#include "dns_server/dnsserver_common.h"
struct b9_options {
const char *url;
@@ -801,11 +801,10 @@ static isc_result_t dlz_lookup_types(struct dlz_bind9_data *state,
const char **types)
{
TALLOC_CTX *tmp_ctx = talloc_new(state);
- const char *attrs[] = { "dnsRecord", NULL };
- int ret = LDB_SUCCESS, i;
- struct ldb_result *res;
- struct ldb_message_element *el;
struct ldb_dn *dn;
+ WERROR werr = WERR_DNS_ERROR_NAME_DOES_NOT_EXIST;
+ struct dnsp_DnssrvRpcRecord *records = NULL;
+ uint16_t num_records = 0, i;
for (i=0; zone_prefixes[i]; i++) {
dn = ldb_dn_copy(tmp_ctx, ldb_get_default_basedn(state->samdb));
@@ -819,38 +818,21 @@ static isc_result_t dlz_lookup_types(struct dlz_bind9_data *state,
return ISC_R_NOMEMORY;
}
- ret = ldb_search(state->samdb, tmp_ctx, &res, dn, LDB_SCOPE_BASE,
- attrs, "objectClass=dnsNode");
- if (ret == LDB_SUCCESS) {
+ werr = dns_common_lookup(state->samdb, tmp_ctx, dn,
+ &records, &num_records, NULL);
+ if (W_ERROR_IS_OK(werr)) {
break;
}
}
- if (ret != LDB_SUCCESS || res->count == 0) {
+ if (!W_ERROR_IS_OK(werr)) {
talloc_free(tmp_ctx);
return ISC_R_NOTFOUND;
}
- el = ldb_msg_find_element(res->msgs[0], "dnsRecord");
- if (el == NULL || el->num_values == 0) {
- talloc_free(tmp_ctx);
- return ISC_R_NOTFOUND;
- }
-
- for (i=0; i<el->num_values; i++) {
- struct dnsp_DnssrvRpcRecord rec;
- enum ndr_err_code ndr_err;
+ for (i=0; i < num_records; i++) {
isc_result_t result;
- ndr_err = ndr_pull_struct_blob(&el->values[i], tmp_ctx, &rec,
- (ndr_pull_flags_fn_t)ndr_pull_dnsp_DnssrvRpcRecord);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- state->log(ISC_LOG_ERROR, "samba_dlz: failed to parse dnsRecord for %s",
- ldb_dn_get_linearized(dn));
- talloc_free(tmp_ctx);
- return ISC_R_FAILURE;
- }
-
- result = b9_putrr(state, lookup, &rec, types);
+ result = b9_putrr(state, lookup, &records[i], types);
if (result != ISC_R_SUCCESS) {
talloc_free(tmp_ctx);
return result;
@@ -1059,39 +1041,25 @@ _PUBLIC_ void dlz_closeversion(const char *zone, isc_boolean_t commit,
*/
static bool b9_has_soa(struct dlz_bind9_data *state, struct ldb_dn *dn, const char *zone)
{
- const char *attrs[] = { "dnsRecord", NULL };
- struct ldb_result *res;
- struct ldb_message_element *el;
TALLOC_CTX *tmp_ctx = talloc_new(state);
- int ret, i;
+ WERROR werr;
+ struct dnsp_DnssrvRpcRecord *records = NULL;
+ uint16_t num_records = 0, i;
if (!ldb_dn_add_child_fmt(dn, "DC=@,DC=%s", zone)) {
talloc_free(tmp_ctx);
return false;
}
- ret = ldb_search(state->samdb, tmp_ctx, &res, dn, LDB_SCOPE_BASE,
- attrs, "objectClass=dnsNode");
- if (ret != LDB_SUCCESS) {
- talloc_free(tmp_ctx);
- return false;
- }
-
- el = ldb_msg_find_element(res->msgs[0], "dnsRecord");
- if (el == NULL) {
+ werr = dns_common_lookup(state->samdb, tmp_ctx, dn,
+ &records, &num_records, NULL);
+ if (!W_ERROR_IS_OK(werr)) {
talloc_free(tmp_ctx);
return false;
}
- for (i=0; i<el->num_values; i++) {
- struct dnsp_DnssrvRpcRecord rec;
- enum ndr_err_code ndr_err;
- ndr_err = ndr_pull_struct_blob(&el->values[i], tmp_ctx, &rec,
- (ndr_pull_flags_fn_t)ndr_pull_dnsp_DnssrvRpcRecord);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- continue;
- }
- if (rec.wType == DNS_TYPE_SOA) {
+ for (i=0; i < num_records; i++) {
+ if (records[i].wType == DNS_TYPE_SOA) {
talloc_free(tmp_ctx);
return true;
}
diff --git a/source4/dns_server/wscript_build b/source4/dns_server/wscript_build
index 66e6b7224dd..a92ab67a40f 100644
--- a/source4/dns_server/wscript_build
+++ b/source4/dns_server/wscript_build
@@ -24,7 +24,7 @@ bld.SAMBA_LIBRARY('dlz_bind9',
link_name='modules/bind9/dlz_bind9.so',
realname='dlz_bind9.so',
install_path='${MODULESDIR}/bind9',
- deps='samba-hostconfig samdb-common gensec popt',
+ deps='samba-hostconfig samdb-common gensec popt dnsserver_common',
enabled=bld.AD_DC_BUILD_IS_ENABLED())
bld.SAMBA_LIBRARY('dlz_bind9_9',
@@ -34,12 +34,12 @@ bld.SAMBA_LIBRARY('dlz_bind9_9',
link_name='modules/bind9/dlz_bind9_9.so',
realname='dlz_bind9_9.so',
install_path='${MODULESDIR}/bind9',
- deps='samba-hostconfig samdb-common gensec popt',
+ deps='samba-hostconfig samdb-common gensec popt dnsserver_common',
enabled=bld.AD_DC_BUILD_IS_ENABLED())
bld.SAMBA_LIBRARY('dlz_bind9_for_torture',
source='dlz_bind9.c',
cflags='-DBIND_VERSION_9_8',
private_library=True,
- deps='samba-hostconfig samdb-common gensec popt',
+ deps='samba-hostconfig samdb-common gensec popt dnsserver_common',
enabled=bld.AD_DC_BUILD_IS_ENABLED())