summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--librpc/ndr/libndr.h10
-rw-r--r--librpc/ndr/ndr.c25
-rw-r--r--source4/dsdb/repl/drepl_out_helpers.c6
-rw-r--r--source4/dsdb/repl/drepl_partitions.c34
-rw-r--r--source4/dsdb/repl/drepl_periodic.c3
-rw-r--r--source4/dsdb/samdb/ldb_modules/partition.c9
-rw-r--r--source4/rpc_server/drsuapi/getncchanges.c2
7 files changed, 67 insertions, 22 deletions
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h
index 7b981f9171..d01b68ef51 100644
--- a/librpc/ndr/libndr.h
+++ b/librpc/ndr/libndr.h
@@ -254,6 +254,16 @@ enum ndr_compression_alg {
} \
} while (0)
+/* if the call fails then free the ndr pointer */
+#define NDR_CHECK_FREE(call) do { \
+ enum ndr_err_code _status; \
+ _status = call; \
+ if (!NDR_ERR_CODE_IS_SUCCESS(_status)) { \
+ talloc_free(ndr); \
+ return _status; \
+ } \
+} while (0)
+
#define NDR_PULL_GET_MEM_CTX(ndr) (ndr->current_mem_ctx)
#define NDR_PULL_SET_MEM_CTX(ndr, mem_ctx, flgs) do {\
diff --git a/librpc/ndr/ndr.c b/librpc/ndr/ndr.c
index 837690b484..2b3493b2e3 100644
--- a/librpc/ndr/ndr.c
+++ b/librpc/ndr/ndr.c
@@ -846,7 +846,8 @@ _PUBLIC_ enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CT
struct ndr_pull *ndr;
ndr = ndr_pull_init_blob(blob, mem_ctx, iconv_convenience);
NDR_ERR_HAVE_NO_MEMORY(ndr);
- NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
+ NDR_CHECK_FREE(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
+ talloc_free(ndr);
return NDR_ERR_SUCCESS;
}
@@ -860,12 +861,13 @@ _PUBLIC_ enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLO
struct ndr_pull *ndr;
ndr = ndr_pull_init_blob(blob, mem_ctx, iconv_convenience);
NDR_ERR_HAVE_NO_MEMORY(ndr);
- NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
+ NDR_CHECK_FREE(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
if (ndr->offset < ndr->data_size) {
return ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES,
"not all bytes consumed ofs[%u] size[%u]",
ndr->offset, ndr->data_size);
}
+ talloc_free(ndr);
return NDR_ERR_SUCCESS;
}
@@ -879,8 +881,9 @@ _PUBLIC_ enum ndr_err_code ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX
struct ndr_pull *ndr;
ndr = ndr_pull_init_blob(blob, mem_ctx, iconv_convenience);
NDR_ERR_HAVE_NO_MEMORY(ndr);
- NDR_CHECK(ndr_pull_set_switch_value(ndr, p, level));
- NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
+ NDR_CHECK_FREE(ndr_pull_set_switch_value(ndr, p, level));
+ NDR_CHECK_FREE(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
+ talloc_free(ndr);
return NDR_ERR_SUCCESS;
}
@@ -895,13 +898,17 @@ _PUBLIC_ enum ndr_err_code ndr_pull_union_blob_all(const DATA_BLOB *blob, TALLOC
struct ndr_pull *ndr;
ndr = ndr_pull_init_blob(blob, mem_ctx, iconv_convenience);
NDR_ERR_HAVE_NO_MEMORY(ndr);
- NDR_CHECK(ndr_pull_set_switch_value(ndr, p, level));
- NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
+ NDR_CHECK_FREE(ndr_pull_set_switch_value(ndr, p, level));
+ NDR_CHECK_FREE(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
if (ndr->offset < ndr->data_size) {
- return ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES,
- "not all bytes consumed ofs[%u] size[%u]",
- ndr->offset, ndr->data_size);
+ enum ndr_err_code ret;
+ ret = ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES,
+ "not all bytes consumed ofs[%u] size[%u]",
+ ndr->offset, ndr->data_size);
+ talloc_free(ndr);
+ return ret;
}
+ talloc_free(ndr);
return NDR_ERR_SUCCESS;
}
diff --git a/source4/dsdb/repl/drepl_out_helpers.c b/source4/dsdb/repl/drepl_out_helpers.c
index 59b3176444..e90f2783b1 100644
--- a/source4/dsdb/repl/drepl_out_helpers.c
+++ b/source4/dsdb/repl/drepl_out_helpers.c
@@ -464,10 +464,8 @@ static void dreplsrv_update_refs_recv(struct rpc_request *req)
c->status = dcerpc_ndr_request_recv(req);
if (!composite_is_ok(c)) {
- DEBUG(0,("UpdateRefs failed with %s for %s %s\n",
- nt_errstr(c->status),
- r->in.req.req1.dest_dsa_dns_name,
- r->in.req.req1.naming_context->dn));
+ DEBUG(0,("UpdateRefs failed with %s\n",
+ nt_errstr(c->status)));
return;
}
diff --git a/source4/dsdb/repl/drepl_partitions.c b/source4/dsdb/repl/drepl_partitions.c
index 88c4bbf065..85412a793c 100644
--- a/source4/dsdb/repl/drepl_partitions.c
+++ b/source4/dsdb/repl/drepl_partitions.c
@@ -148,7 +148,7 @@ static WERROR dreplsrv_partition_add_source_dsa(struct dreplsrv_service *s,
{
WERROR status;
enum ndr_err_code ndr_err;
- struct dreplsrv_partition_source_dsa *source;
+ struct dreplsrv_partition_source_dsa *source, *s2;
source = talloc_zero(p, struct dreplsrv_partition_source_dsa);
W_ERROR_HAVE_NO_MEMORY(source);
@@ -158,10 +158,12 @@ static WERROR dreplsrv_partition_add_source_dsa(struct dreplsrv_service *s,
(ndr_pull_flags_fn_t)ndr_pull_repsFromToBlob);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err);
+ talloc_free(source);
return ntstatus_to_werror(nt_status);
}
/* NDR_PRINT_DEBUG(repsFromToBlob, &source->_repsFromBlob); */
if (source->_repsFromBlob.version != 1) {
+ talloc_free(source);
return WERR_DS_DRA_INTERNAL_ERROR;
}
@@ -171,13 +173,24 @@ static WERROR dreplsrv_partition_add_source_dsa(struct dreplsrv_service *s,
status = dreplsrv_out_connection_attach(s, source->repsFrom1, &source->conn);
W_ERROR_NOT_OK_RETURN(status);
+ /* remove any existing source with the same GUID */
+ for (s2=p->sources; s2; s2=s2->next) {
+ if (GUID_compare(&s2->repsFrom1->source_dsa_obj_guid,
+ &source->repsFrom1->source_dsa_obj_guid) == 0) {
+ talloc_free(s2->repsFrom1->other_info);
+ *s2->repsFrom1 = *source->repsFrom1;
+ talloc_steal(s2, s2->repsFrom1->other_info);
+ talloc_free(source);
+ return WERR_OK;
+ }
+ }
+
DLIST_ADD_END(p->sources, source, struct dreplsrv_partition_source_dsa *);
return WERR_OK;
}
static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s,
- struct dreplsrv_partition *p,
- TALLOC_CTX *mem_ctx)
+ struct dreplsrv_partition *p)
{
WERROR status;
const struct ldb_val *ouv_value;
@@ -187,6 +200,7 @@ static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s,
struct ldb_result *r;
uint32_t i;
int ret;
+ TALLOC_CTX *mem_ctx = talloc_new(p);
static const char *attrs[] = {
"objectSid",
"objectGUID",
@@ -201,12 +215,14 @@ static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s,
ret = ldb_search(s->samdb, mem_ctx, &r, p->dn, LDB_SCOPE_BASE, attrs,
"(objectClass=*)");
if (ret != LDB_SUCCESS) {
+ talloc_free(mem_ctx);
return WERR_FOOBAR;
} else if (r->count != 1) {
- talloc_free(r);
+ talloc_free(mem_ctx);
return WERR_FOOBAR;
}
-
+
+ talloc_free(discard_const(p->nc.dn));
ZERO_STRUCT(p->nc);
p->nc.dn = ldb_dn_alloc_linearized(p, p->dn);
W_ERROR_HAVE_NO_MEMORY(p->nc.dn);
@@ -214,6 +230,7 @@ static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s,
nc_sid = samdb_result_dom_sid(p, r->msgs[0], "objectSid");
if (nc_sid) {
p->nc.sid = *nc_sid;
+ talloc_free(nc_sid);
}
ouv_value = ldb_msg_find_ldb_val(r->msgs[0], "replUpToDateVector");
@@ -224,15 +241,18 @@ static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s,
(ndr_pull_flags_fn_t)ndr_pull_replUpToDateVectorBlob);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err);
+ talloc_free(mem_ctx);
return ntstatus_to_werror(nt_status);
}
/* NDR_PRINT_DEBUG(replUpToDateVectorBlob, &ouv); */
if (ouv.version != 2) {
+ talloc_free(mem_ctx);
return WERR_DS_DRA_INTERNAL_ERROR;
}
p->uptodatevector.count = ouv.ctr.ctr2.count;
p->uptodatevector.reserved = ouv.ctr.ctr2.reserved;
+ talloc_free(p->uptodatevector.cursors);
p->uptodatevector.cursors = talloc_steal(p, ouv.ctr.ctr2.cursors);
}
@@ -249,7 +269,7 @@ static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s,
}
}
- talloc_free(r);
+ talloc_free(mem_ctx);
return WERR_OK;
}
@@ -260,7 +280,7 @@ WERROR dreplsrv_refresh_partitions(struct dreplsrv_service *s)
struct dreplsrv_partition *p;
for (p = s->partitions; p; p = p->next) {
- status = dreplsrv_refresh_partition(s, p, p);
+ status = dreplsrv_refresh_partition(s, p);
W_ERROR_NOT_OK_RETURN(status);
}
diff --git a/source4/dsdb/repl/drepl_periodic.c b/source4/dsdb/repl/drepl_periodic.c
index 36d5f924be..2cfcb310dc 100644
--- a/source4/dsdb/repl/drepl_periodic.c
+++ b/source4/dsdb/repl/drepl_periodic.c
@@ -103,7 +103,8 @@ static void dreplsrv_periodic_run(struct dreplsrv_service *service)
dreplsrv_schedule_pull_replication(service, mem_ctx);
talloc_free(mem_ctx);
- DEBUG(2,("dreplsrv_periodic_run(): run pending_ops\n"));
+ DEBUG(2,("dreplsrv_periodic_run(): run pending_ops memory=%u\n",
+ (unsigned)talloc_total_blocks(service)));
/* the KCC might have changed repsFrom */
dreplsrv_refresh_partitions(service);
diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c
index dec905e000..d4a69952e8 100644
--- a/source4/dsdb/samdb/ldb_modules/partition.c
+++ b/source4/dsdb/samdb/ldb_modules/partition.c
@@ -763,6 +763,15 @@ static int partition_sequence_number(struct ldb_module *module, struct ldb_reque
struct ldb_seqnum_result *tseqr;
struct ldb_extended *ext;
struct ldb_result *res;
+ struct dsdb_partition *p;
+
+ p = find_partition(NULL, NULL, req);
+ if (p != NULL) {
+ /* the caller specified what partition they want the
+ * sequence number operation on - just pass it on
+ */
+ return ldb_next_request(p->module, req);
+ }
seq = talloc_get_type(req->op.extended.data, struct ldb_seqnum_request);
diff --git a/source4/rpc_server/drsuapi/getncchanges.c b/source4/rpc_server/drsuapi/getncchanges.c
index 4dce07e24a..6f7637a970 100644
--- a/source4/rpc_server/drsuapi/getncchanges.c
+++ b/source4/rpc_server/drsuapi/getncchanges.c
@@ -391,7 +391,7 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_
}
- DEBUG(4,("DsGetNCChanges with uSNChanged >= %llu on %s gave %u objects\n",
+ DEBUG(3,("DsGetNCChanges with uSNChanged >= %llu on %s gave %u objects\n",
(unsigned long long)(r->in.req->req8.highwatermark.highest_usn+1),
ncRoot->dn, r->out.ctr->ctr6.object_count));