summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2012-02-27 17:09:10 +1100
committerAmitay Isaacs <amitay@gmail.com>2012-03-02 00:24:49 +1100
commitf5b041fc04f158d0462995d592359fa6bd74b2ff (patch)
tree8186922585e1462fc2792be2ec0b67db3049dfe0 /source4
parent9c11c0cde04efd0d101a09eb93fed6f432477772 (diff)
downloadsamba-f5b041fc04f158d0462995d592359fa6bd74b2ff.tar.gz
samba-f5b041fc04f158d0462995d592359fa6bd74b2ff.tar.bz2
samba-f5b041fc04f158d0462995d592359fa6bd74b2ff.zip
dlz_bind9: This fixes the problem with adding/deleting rdataset
Fix commit 169db333033b72b6f9ac1e7b23f0f2c151218c1f. This change allowed for LDB records without dnsRecord attribute to exist to prevent large number of deleted records. This change fixes the handling of missing dnsRecord attribute and correctly deleting dnsRecord attribute.
Diffstat (limited to 'source4')
-rw-r--r--source4/dns_server/dlz_bind9.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/source4/dns_server/dlz_bind9.c b/source4/dns_server/dlz_bind9.c
index 34320e01f6..6b38bc31dc 100644
--- a/source4/dns_server/dlz_bind9.c
+++ b/source4/dns_server/dlz_bind9.c
@@ -1458,17 +1458,20 @@ _PUBLIC_ isc_result_t dlz_addrdataset(const char *name, const char *rdatastr, vo
return result;
}
- /* there are existing records. We need to see if this will
- * replace a record or add to it
- */
el = ldb_msg_find_element(res->msgs[0], "dnsRecord");
if (el == NULL) {
- state->log(ISC_LOG_ERROR, "samba_dlz: no dnsRecord attribute for %s",
- ldb_dn_get_linearized(dn));
- talloc_free(rec);
- return ISC_R_FAILURE;
+ ret = ldb_msg_add_empty(res->msgs[0], "dnsRecord", LDB_FLAG_MOD_ADD, &el);
+ if (ret != LDB_SUCCESS) {
+ state->log(ISC_LOG_ERROR, "samba_dlz: failed to add dnsRecord for %s",
+ ldb_dn_get_linearized(dn));
+ talloc_free(rec);
+ return ISC_R_FAILURE;
+ }
}
+ /* there are existing records. We need to see if this will
+ * replace a record or add to it
+ */
for (i=0; i<el->num_values; i++) {
struct dnsp_DnssrvRpcRecord rec2;
@@ -1614,9 +1617,10 @@ _PUBLIC_ isc_result_t dlz_subrdataset(const char *name, const char *rdatastr, vo
}
if (el->num_values == 0) {
- ldb_msg_remove_element(res->msgs[0], el);
+ el->flags = LDB_FLAG_MOD_DELETE;
+ } else {
+ el->flags = LDB_FLAG_MOD_REPLACE;
}
- el->flags = LDB_FLAG_MOD_REPLACE;
ret = ldb_modify(state->samdb, res->msgs[0]);
b9_reset_session_info(state);
@@ -1719,9 +1723,10 @@ _PUBLIC_ isc_result_t dlz_delrdataset(const char *name, const char *type, void *
}
if (el->num_values == 0) {
- ldb_msg_remove_element(res->msgs[0], el);
+ el->flags = LDB_FLAG_MOD_DELETE;
+ } else {
+ el->flags = LDB_FLAG_MOD_REPLACE;
}
- el->flags = LDB_FLAG_MOD_REPLACE;
ret = ldb_modify(state->samdb, res->msgs[0]);
b9_reset_session_info(state);