summaryrefslogtreecommitdiff
path: root/source4/lib/ldb-samba
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>2009-10-11 21:00:55 +0300
committerAnatoliy Atanasov <anatoliy.atanasov@postpath.com>2009-10-16 12:54:14 +0300
commit40a8a2268454a55103c5c675d6fc07efa3cb6f31 (patch)
treeb8adb8aaeccda66052c2b0ef9cbb38d91c5889e9 /source4/lib/ldb-samba
parent7e8fb4ad06a3e2e5ae17b06299c7c4cd4e87012e (diff)
downloadsamba-40a8a2268454a55103c5c675d6fc07efa3cb6f31.tar.gz
s4/drs: Propagate redefinition of drsuapi_DsReplicaOID into code base
The biggest change is that 'oid' field is transmited in binary format. Also the field name is changed to 'binary_oid' so that field format to be clear for callers. After those changes, Samba4 should work the way it works before - i.e. no added value here but we should not fail when partial-oid is part of prefixMap transmited from Win server. Also, thre is a bug in this patch - partial-binary-OIDs are not handled correctly. Partial-binary-OIDs received during replication will be encoded, but not handled correctly.
Diffstat (limited to 'source4/lib/ldb-samba')
-rw-r--r--source4/lib/ldb-samba/ldif_handlers.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/source4/lib/ldb-samba/ldif_handlers.c b/source4/lib/ldb-samba/ldif_handlers.c
index 4d8af75a51e..59f8622a376 100644
--- a/source4/lib/ldb-samba/ldif_handlers.c
+++ b/source4/lib/ldb-samba/ldif_handlers.c
@@ -33,6 +33,7 @@
#include "librpc/ndr/libndr.h"
#include "libcli/security/security.h"
#include "param/param.h"
+#include "../lib/util/asn1.h"
/*
use ndr_print_* to convert a NDR formatted blob to a ldif formatted blob
@@ -507,6 +508,7 @@ static int ldif_read_prefixMap(struct ldb_context *ldb, void *mem_ctx,
struct prefixMapBlob *blob;
enum ndr_err_code ndr_err;
char *string, *line, *p, *oid;
+ DATA_BLOB oid_blob;
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
@@ -563,8 +565,12 @@ static int ldif_read_prefixMap(struct ldb_context *ldb, void *mem_ctx,
/* we know there must be at least ":" */
oid++;
- blob->ctr.dsdb.mappings[blob->ctr.dsdb.num_mappings].oid.oid
- = talloc_strdup(blob->ctr.dsdb.mappings, oid);
+ if (!ber_write_partial_OID_String(blob->ctr.dsdb.mappings, &oid_blob, oid)) {
+ talloc_free(tmp_ctx);
+ return -1;
+ }
+ blob->ctr.dsdb.mappings[blob->ctr.dsdb.num_mappings].oid.length = oid_blob.length;
+ blob->ctr.dsdb.mappings[blob->ctr.dsdb.num_mappings].oid.binary_oid = oid_blob.data;
blob->ctr.dsdb.num_mappings++;
@@ -615,32 +621,47 @@ static int ldif_write_prefixMap(struct ldb_context *ldb, void *mem_ctx,
blob,
(ndr_pull_flags_fn_t)ndr_pull_prefixMapBlob);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- talloc_free(blob);
- return -1;
+ goto failed;
}
if (blob->version != PREFIX_MAP_VERSION_DSDB) {
- return -1;
+ goto failed;
}
string = talloc_strdup(mem_ctx, "");
if (string == NULL) {
- return -1;
+ goto failed;
}
for (i=0; i < blob->ctr.dsdb.num_mappings; i++) {
+ DATA_BLOB oid_blob;
+ const char *partial_oid = NULL;
+
if (i > 0) {
string = talloc_asprintf_append(string, ";");
}
+
+ oid_blob = data_blob_const(blob->ctr.dsdb.mappings[i].oid.binary_oid,
+ blob->ctr.dsdb.mappings[i].oid.length);
+ if (!ber_read_partial_OID_String(blob, oid_blob, &partial_oid)) {
+ DEBUG(0, ("ber_read_partial_OID failed on prefixMap item with id: 0x%X",
+ blob->ctr.dsdb.mappings[i].id_prefix));
+ goto failed;
+ }
string = talloc_asprintf_append(string, "%u:%s",
blob->ctr.dsdb.mappings[i].id_prefix,
- blob->ctr.dsdb.mappings[i].oid.oid);
+ partial_oid);
+ talloc_free(discard_const(partial_oid));
if (string == NULL) {
- return -1;
+ goto failed;
}
}
talloc_free(blob);
*out = data_blob_string_const(string);
return 0;
+
+failed:
+ talloc_free(blob);
+ return -1;
}
static bool ldif_comparision_prefixMap_isString(const struct ldb_val *v)