[SCM] Samba Shared Repository - branch master updated
Anatoliy Atanasov
anatoliy at samba.org
Fri Oct 16 04:27:14 MDT 2009
The branch, master has been updated
via 421191a... s4/drs(tort): prefixMap unit test initial implementatoin
via 784e0c1... s4/drs: prefixMap module initial definition
via 47f30fd... s4/drs(tort): fix compile time warning
via 1d3342e... s4/drs(tort): _drs_util_verify_attids() to verify ATTIDs in objects received
via e3b707d... s4/drs(tort): drs_util_DsAttributeId_to_string() function
via 8631548... s4/drs(tort): _drs_ldap_attr_by_oid() implementation
via 8639ba2... s4/drs(tort): ignore drs/proto.h file
via 3c3f66f... s4/drs(tort): oid_from_attid() reference implementation
via 6a680ce... s4/drs(tort): TORTURE_DRS torture module - initial implementation
via 40a8a22... s4/drs: Propagate redefinition of drsuapi_DsReplicaOID into code base
via 7e8fb4a... s4/drs(NDR): Print implementation for drsuapi_DsReplicaOID
via 4bfd132... s4/drs(NDR): Remove push/pull code for drsuapi_DsReplicaOID struct
via f11cdc1... s4/asn1: Use explicite TALLOC_CTX in ber_write_OID functions
via cb71e8a... s4/drs(idl): Regenerate idl
via cf51787... s4/drs(idl): Redefine drsuapi_DsReplicaOID in drsuapi.idl
from a85799d... s3-libnetapi: add nltest tool.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 421191a4433e289adf6c2d9739d1ce091af3774f
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date: Thu Oct 8 02:56:22 2009 +0300
s4/drs(tort): prefixMap unit test initial implementatoin
commit 784e0c199e8b083865ac96930c3b55d709a2bec5
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date: Thu Oct 8 02:55:28 2009 +0300
s4/drs: prefixMap module initial definition
commit 47f30fd3e785f51f3a14c407e20cf1dcaa747660
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date: Wed Oct 7 18:32:43 2009 +0300
s4/drs(tort): fix compile time warning
commit 1d3342e9fa0850f21fc51f357d9f868d112fc349
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date: Tue Oct 6 11:42:02 2009 +0300
s4/drs(tort): _drs_util_verify_attids() to verify ATTIDs in objects received
commit e3b707da948c30b3eca1c2a5d363c7bfb2ecb8e2
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date: Tue Oct 6 11:38:42 2009 +0300
s4/drs(tort): drs_util_DsAttributeId_to_string() function
commit 8631548f1209b21a35398f391ee7ec698cedd874
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date: Sun Sep 27 17:04:04 2009 +0300
s4/drs(tort): _drs_ldap_attr_by_oid() implementation
Utility function to be used to fetch Attribute name and DN
giving attribute OID
commit 8639ba2237246a1759d7d1c18db6d7ae1662b151
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date: Tue Oct 6 11:35:51 2009 +0300
s4/drs(tort): ignore drs/proto.h file
commit 3c3f66f0dfbbea1315cb8e814f48b2d39c1928a0
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date: Tue Oct 6 08:40:15 2009 +0300
s4/drs(tort): oid_from_attid() reference implementation
Decode Attribute OID using prefixMap and
ATTID received during replication
Based on MS documentation. See MS-DRSR.pdf - 5.16.4
commit 6a680cea6a58f4a0d980be8ba47286293ab6f9ab
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date: Mon Oct 5 18:39:13 2009 +0300
s4/drs(tort): TORTURE_DRS torture module - initial implementation
Drsuapi tests module registers two suites:
- DRS-RPC - tests to be executed against remote machine
- DRS-UNIT - unit test for internal testing
commit 40a8a2268454a55103c5c675d6fc07efa3cb6f31
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date: Sun Oct 11 21:00:55 2009 +0300
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.
commit 7e8fb4ad06a3e2e5ae17b06299c7c4cd4e87012e
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date: Mon Oct 5 13:28:12 2009 +0300
s4/drs(NDR): Print implementation for drsuapi_DsReplicaOID
Custom ndr_print functions is implemented so that transmited
partia-binary-oid to be printed both in hex and
partial-oid formats
commit 4bfd132b0820644bb41c6d1c3075875d94b9cdd7
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date: Mon Oct 5 13:23:48 2009 +0300
s4/drs(NDR): Remove push/pull code for drsuapi_DsReplicaOID struct
New structure definition is automarshaled so custom marshaling
code is not used anymore
commit f11cdc19d1123ca0f7ac909e7c5307a7a3ad5fdb
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date: Mon Oct 5 04:46:20 2009 +0300
s4/asn1: Use explicite TALLOC_CTX in ber_write_OID functions
commit cb71e8a73105f7dbeff42738b9c32194ed9a4023
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date: Fri Oct 2 18:30:14 2009 +0300
s4/drs(idl): Regenerate idl
commit cf51787382f587795f90b5d1b2ca2ede73b67acd
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date: Fri Oct 2 18:29:44 2009 +0300
s4/drs(idl): Redefine drsuapi_DsReplicaOID in drsuapi.idl
Structure redefined to be more similar with OID_t structure
defined in [ref. MS-DRSR.pdf - p.496].
-----------------------------------------------------------------------
Summary of changes:
.gitignore | 1 +
lib/util/asn1.c | 22 ++--
lib/util/asn1.h | 4 +-
lib/util/tests/asn1_tests.c | 6 +-
librpc/gen_ndr/drsuapi.h | 6 +-
librpc/gen_ndr/ndr_drsuapi.c | 57 +++++++--
librpc/gen_ndr/ndr_drsuapi.h | 2 -
librpc/idl/drsuapi.idl | 6 +-
librpc/ndr/ndr_drsuapi.c | 110 +++-------------
librpc/ndr/ndr_drsuapi.h | 3 -
source4/dsdb/config.mk | 3 +-
source4/dsdb/schema/prefixmap.h | 45 +++++++
source4/dsdb/schema/schema_init.c | 166 +++++++++++++++---------
source4/dsdb/schema/schema_prefixmap.c | 22 +++
source4/lib/ldb-samba/ldif_handlers.c | 37 ++++-
source4/torture/config.mk | 4 +
source4/torture/drs/config.mk | 24 ++++
source4/torture/drs/drs_init.c | 71 ++++++++++
source4/torture/drs/drs_util.c | 168 ++++++++++++++++++++++++
source4/torture/drs/internal/prefixmap_tests.c | 80 +++++++++++
source4/torture/rpc/dssync.c | 99 ++++++++++++++
source4/torture/torture.c | 1 +
22 files changed, 736 insertions(+), 201 deletions(-)
create mode 100644 source4/dsdb/schema/prefixmap.h
create mode 100644 source4/dsdb/schema/schema_prefixmap.c
create mode 100644 source4/torture/drs/config.mk
create mode 100644 source4/torture/drs/drs_init.c
create mode 100644 source4/torture/drs/drs_util.c
create mode 100644 source4/torture/drs/internal/prefixmap_tests.c
Changeset truncated at 500 lines:
diff --git a/.gitignore b/.gitignore
index 9ed25e7..1d6420a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -298,6 +298,7 @@ source4/torture/proto.h
source4/torture/rap/proto.h
source4/torture/raw/proto.h
source4/torture/rpc/proto.h
+source4/torture/drs/proto.h
source4/torture/smb2/proto.h
source4/torture.tdb
source4/torture/unix/proto.h
diff --git a/lib/util/asn1.c b/lib/util/asn1.c
index ec8ef3f..946f713 100644
--- a/lib/util/asn1.c
+++ b/lib/util/asn1.c
@@ -214,7 +214,7 @@ bool asn1_write_BitString(struct asn1_data *data, const void *p, size_t length,
return asn1_pop_tag(data);
}
-bool ber_write_OID_String(DATA_BLOB *blob, const char *OID)
+bool ber_write_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char *OID)
{
uint_t v, v2;
const char *p = (const char *)OID;
@@ -230,7 +230,7 @@ bool ber_write_OID_String(DATA_BLOB *blob, const char *OID)
p = newp + 1;
/*the ber representation can't use more space then the string one */
- *blob = data_blob(NULL, strlen(OID));
+ *blob = data_blob_talloc(mem_ctx, NULL, strlen(OID));
if (!blob->data) return false;
blob->data[0] = 40*v + v2;
@@ -264,10 +264,10 @@ bool ber_write_OID_String(DATA_BLOB *blob, const char *OID)
* 1:2.5.6:0x81
* 1:2.5.6:0x8182
*/
-bool ber_write_partial_OID_String(DATA_BLOB *blob, const char *partial_oid)
+bool ber_write_partial_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char *partial_oid)
{
- TALLOC_CTX *mem_ctx = talloc_new(NULL);
- char *oid = talloc_strdup(mem_ctx, partial_oid);
+ TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+ char *oid = talloc_strdup(tmp_ctx, partial_oid);
char *p;
/* truncate partial part so ber_write_OID_String() works */
@@ -277,18 +277,18 @@ bool ber_write_partial_OID_String(DATA_BLOB *blob, const char *partial_oid)
p++;
}
- if (!ber_write_OID_String(blob, oid)) {
- talloc_free(mem_ctx);
+ if (!ber_write_OID_String(mem_ctx, blob, oid)) {
+ talloc_free(tmp_ctx);
return false;
}
/* Add partially endcoded subidentifier */
if (p) {
- DATA_BLOB tmp_blob = strhex_to_data_blob(mem_ctx, p);
- data_blob_append(NULL, blob, tmp_blob.data, tmp_blob.length);
+ DATA_BLOB tmp_blob = strhex_to_data_blob(tmp_ctx, p);
+ data_blob_append(mem_ctx, blob, tmp_blob.data, tmp_blob.length);
}
- talloc_free(mem_ctx);
+ talloc_free(tmp_ctx);
return true;
}
@@ -300,7 +300,7 @@ bool asn1_write_OID(struct asn1_data *data, const char *OID)
if (!asn1_push_tag(data, ASN1_OID)) return false;
- if (!ber_write_OID_String(&blob, OID)) {
+ if (!ber_write_OID_String(NULL, &blob, OID)) {
data->has_error = true;
return false;
}
diff --git a/lib/util/asn1.h b/lib/util/asn1.h
index 3d8e37b..ded3244 100644
--- a/lib/util/asn1.h
+++ b/lib/util/asn1.h
@@ -61,8 +61,8 @@ bool asn1_pop_tag(struct asn1_data *data);
bool asn1_write_implicit_Integer(struct asn1_data *data, int i);
bool asn1_write_Integer(struct asn1_data *data, int i);
bool asn1_write_BitString(struct asn1_data *data, const void *p, size_t length, uint8_t padding);
-bool ber_write_OID_String(DATA_BLOB *blob, const char *OID);
-bool ber_write_partial_OID_String(DATA_BLOB *blob, const char *partial_oid);
+bool ber_write_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char *OID);
+bool ber_write_partial_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char *partial_oid);
bool asn1_write_OID(struct asn1_data *data, const char *OID);
bool asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length);
bool asn1_write_LDAPString(struct asn1_data *data, const char *s);
diff --git a/lib/util/tests/asn1_tests.c b/lib/util/tests/asn1_tests.c
index eea34da..25c8222 100644
--- a/lib/util/tests/asn1_tests.c
+++ b/lib/util/tests/asn1_tests.c
@@ -105,7 +105,7 @@ static bool test_ber_write_OID_String(struct torture_context *tctx)
mem_ctx = talloc_new(tctx);
for (i = 0; i < ARRAY_SIZE(oid_data_ok); i++) {
- torture_assert(tctx, ber_write_OID_String(&blob, data[i].oid),
+ torture_assert(tctx, ber_write_OID_String(mem_ctx, &blob, data[i].oid),
"ber_write_OID_String failed");
hex_str = hex_encode_talloc(mem_ctx, blob.data, blob.length);
@@ -163,7 +163,7 @@ static bool test_ber_write_partial_OID_String(struct torture_context *tctx)
/* ber_write_partial_OID_String() should work with not partial OIDs also */
for (i = 0; i < ARRAY_SIZE(oid_data_ok); i++) {
- torture_assert(tctx, ber_write_partial_OID_String(&blob, data[i].oid),
+ torture_assert(tctx, ber_write_partial_OID_String(mem_ctx, &blob, data[i].oid),
"ber_write_partial_OID_String failed");
hex_str = hex_encode_talloc(mem_ctx, blob.data, blob.length);
@@ -178,7 +178,7 @@ static bool test_ber_write_partial_OID_String(struct torture_context *tctx)
/* ber_write_partial_OID_String() test with partial OIDs */
data = partial_oid_data_ok;
for (i = 0; i < ARRAY_SIZE(partial_oid_data_ok); i++) {
- torture_assert(tctx, ber_write_partial_OID_String(&blob, data[i].oid),
+ torture_assert(tctx, ber_write_partial_OID_String(mem_ctx, &blob, data[i].oid),
"ber_write_partial_OID_String failed");
hex_str = hex_encode_talloc(mem_ctx, blob.data, blob.length);
diff --git a/librpc/gen_ndr/drsuapi.h b/librpc/gen_ndr/drsuapi.h
index 0a03004..96b0651 100644
--- a/librpc/gen_ndr/drsuapi.h
+++ b/librpc/gen_ndr/drsuapi.h
@@ -293,9 +293,9 @@ struct drsuapi_DsGetNCChangesRequest5 {
};
struct drsuapi_DsReplicaOID {
- uint32_t __ndr_size;/* [value(ndr_size_drsuapi_DsReplicaOID_oid(oid,0)),range(0,10000)] */
- const char *oid;/* [unique,charset(DOS),size_is(__ndr_size)] */
-}/* [nopush,nopull] */;
+ uint32_t length;/* [range(0,10000)] */
+ uint8_t *binary_oid;/* [unique,size_is(length)] */
+}/* [noprint] */;
struct drsuapi_DsReplicaOIDMapping {
uint32_t id_prefix;
diff --git a/librpc/gen_ndr/ndr_drsuapi.c b/librpc/gen_ndr/ndr_drsuapi.c
index ec799b6..f09affc 100644
--- a/librpc/gen_ndr/ndr_drsuapi.c
+++ b/librpc/gen_ndr/ndr_drsuapi.c
@@ -1167,18 +1167,55 @@ _PUBLIC_ void ndr_print_drsuapi_DsGetNCChangesRequest5(struct ndr_print *ndr, co
ndr->depth--;
}
-_PUBLIC_ void ndr_print_drsuapi_DsReplicaOID(struct ndr_print *ndr, const char *name, const struct drsuapi_DsReplicaOID *r)
+static enum ndr_err_code ndr_push_drsuapi_DsReplicaOID(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsReplicaOID *r)
{
- ndr_print_struct(ndr, name, "drsuapi_DsReplicaOID");
- ndr->depth++;
- ndr_print_uint32(ndr, "__ndr_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_drsuapi_DsReplicaOID_oid(r->oid, 0):r->__ndr_size);
- ndr_print_ptr(ndr, "oid", r->oid);
- ndr->depth++;
- if (r->oid) {
- ndr_print_string(ndr, "oid", r->oid);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 5));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->length));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->binary_oid));
+ NDR_CHECK(ndr_push_trailer_align(ndr, 5));
}
- ndr->depth--;
- ndr->depth--;
+ if (ndr_flags & NDR_BUFFERS) {
+ if (r->binary_oid) {
+ NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, r->length));
+ NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->binary_oid, r->length));
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_drsuapi_DsReplicaOID(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsReplicaOID *r)
+{
+ uint32_t _ptr_binary_oid;
+ TALLOC_CTX *_mem_save_binary_oid_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 5));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->length));
+ if (r->length > 10000) {
+ return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range");
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_binary_oid));
+ if (_ptr_binary_oid) {
+ NDR_PULL_ALLOC(ndr, r->binary_oid);
+ } else {
+ r->binary_oid = NULL;
+ }
+ NDR_CHECK(ndr_pull_trailer_align(ndr, 5));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ if (r->binary_oid) {
+ _mem_save_binary_oid_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->binary_oid, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->binary_oid));
+ NDR_PULL_ALLOC_N(ndr, r->binary_oid, ndr_get_array_size(ndr, &r->binary_oid));
+ NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->binary_oid, ndr_get_array_size(ndr, &r->binary_oid)));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_binary_oid_0, 0);
+ }
+ if (r->binary_oid) {
+ NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->binary_oid, r->length));
+ }
+ }
+ return NDR_ERR_SUCCESS;
}
static enum ndr_err_code ndr_push_drsuapi_DsReplicaOIDMapping(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsReplicaOIDMapping *r)
diff --git a/librpc/gen_ndr/ndr_drsuapi.h b/librpc/gen_ndr/ndr_drsuapi.h
index 8c4a9e3..bf82ab8 100644
--- a/librpc/gen_ndr/ndr_drsuapi.h
+++ b/librpc/gen_ndr/ndr_drsuapi.h
@@ -96,8 +96,6 @@ void ndr_print_drsuapi_DsReplicaNeighbourFlags(struct ndr_print *ndr, const char
void ndr_print_drsuapi_DsExtendedOperation(struct ndr_print *ndr, const char *name, enum drsuapi_DsExtendedOperation r);
void ndr_print_drsuapi_DsExtendedError(struct ndr_print *ndr, const char *name, enum drsuapi_DsExtendedError r);
void ndr_print_drsuapi_DsGetNCChangesRequest5(struct ndr_print *ndr, const char *name, const struct drsuapi_DsGetNCChangesRequest5 *r);
-enum ndr_err_code ndr_push_drsuapi_DsReplicaOID(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsReplicaOID *r);
-enum ndr_err_code ndr_pull_drsuapi_DsReplicaOID(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsReplicaOID *r);
void ndr_print_drsuapi_DsReplicaOID(struct ndr_print *ndr, const char *name, const struct drsuapi_DsReplicaOID *r);
void ndr_print_drsuapi_DsReplicaOIDMapping(struct ndr_print *ndr, const char *name, const struct drsuapi_DsReplicaOIDMapping *r);
enum ndr_err_code ndr_push_drsuapi_DsReplicaOIDMapping_Ctr(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsReplicaOIDMapping_Ctr *r);
diff --git a/librpc/idl/drsuapi.idl b/librpc/idl/drsuapi.idl
index 27cb14e..f53db00 100644
--- a/librpc/idl/drsuapi.idl
+++ b/librpc/idl/drsuapi.idl
@@ -414,9 +414,9 @@ interface drsuapi
*
* 2.5.5.17 => dom_sid
*/
- typedef [nopush,nopull] struct {
- [range(0,10000),value(ndr_size_drsuapi_DsReplicaOID_oid(oid, 0))] uint32 __ndr_size;
- [size_is(__ndr_size),charset(DOS)] uint8 *oid; /* it's encoded with asn1_write_OID_String() */
+ typedef [noprint] struct {
+ [range(0,10000)] uint32 length;
+ [size_is(length)] uint8 *binary_oid; /* partial-binary-OID encoded with asn1_write_partial_OID_String() */
} drsuapi_DsReplicaOID;
typedef struct {
diff --git a/librpc/ndr/ndr_drsuapi.c b/librpc/ndr/ndr_drsuapi.c
index 0c790e5..bfc3c75 100644
--- a/librpc/ndr/ndr_drsuapi.c
+++ b/librpc/ndr/ndr_drsuapi.c
@@ -82,102 +82,24 @@ void ndr_print_drsuapi_DsReplicaObjectListItemEx(struct ndr_print *ndr, const ch
} \
} while (0)
-enum ndr_err_code ndr_push_drsuapi_DsReplicaOID(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsReplicaOID *r)
+_PUBLIC_ void ndr_print_drsuapi_DsReplicaOID(struct ndr_print *ndr, const char *name, const struct drsuapi_DsReplicaOID *r)
{
- if (ndr_flags & NDR_SCALARS) {
- NDR_CHECK(ndr_push_align(ndr, 4));
- NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_drsuapi_DsReplicaOID_oid(r->oid, 0)));
- NDR_CHECK(ndr_push_unique_ptr(ndr, r->oid));
- }
- if (ndr_flags & NDR_BUFFERS) {
- if (r->oid) {
- DATA_BLOB blob;
-
- if (strncasecmp("ff", r->oid, 2) == 0) {
- blob = strhex_to_data_blob(ndr, r->oid);
- if (!blob.data) {
- return ndr_push_error(ndr, NDR_ERR_SUBCONTEXT,
- "HEX String Conversion Error: %s\n",
- __location__);
- }
- } else {
- _OID_PUSH_CHECK(ber_write_OID_String(&blob, r->oid));
- talloc_steal(ndr, blob.data);
- }
-
- NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, blob.length));
- NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, blob.data, blob.length));
- }
- }
- return NDR_ERR_SUCCESS;
-}
-
-enum ndr_err_code ndr_pull_drsuapi_DsReplicaOID(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsReplicaOID *r)
-{
- uint32_t _ptr_oid;
- TALLOC_CTX *_mem_save_oid_0;
- if (ndr_flags & NDR_SCALARS) {
- NDR_CHECK(ndr_pull_align(ndr, 4));
- NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->__ndr_size));
- if (r->__ndr_size < 0 || r->__ndr_size > 10000) {
- return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range");
- }
- NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_oid));
- if (_ptr_oid) {
- NDR_PULL_ALLOC(ndr, r->oid);
- } else {
- r->oid = NULL;
- }
- }
- if (ndr_flags & NDR_BUFFERS) {
- if (r->oid) {
- DATA_BLOB _oid_array;
- const char *_oid;
-
- _mem_save_oid_0 = NDR_PULL_GET_MEM_CTX(ndr);
- NDR_PULL_SET_MEM_CTX(ndr, ndr, 0);
- NDR_CHECK(ndr_pull_array_size(ndr, &r->oid));
- _oid_array.length = ndr_get_array_size(ndr, &r->oid);
- NDR_PULL_ALLOC_N(ndr, _oid_array.data, _oid_array.length);
- NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, _oid_array.data, _oid_array.length));
- NDR_PULL_SET_MEM_CTX(ndr, _mem_save_oid_0, 0);
-
- if (_oid_array.length && _oid_array.data[0] == 0xFF) {
- _oid = data_blob_hex_string(ndr, &_oid_array);
- NDR_ERR_HAVE_NO_MEMORY(_oid);
- } else {
- _OID_PULL_CHECK(ber_read_OID_String(ndr, _oid_array, &_oid));
- }
- data_blob_free(&_oid_array);
- talloc_steal(r->oid, _oid);
- r->oid = _oid;
- }
- if (r->oid) {
- NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->oid, r->__ndr_size));
- }
- }
- return NDR_ERR_SUCCESS;
-}
-
-size_t ndr_size_drsuapi_DsReplicaOID_oid(const char *oid, int flags)
-{
- DATA_BLOB _blob;
- size_t ret = 0;
-
- if (!oid) return 0;
-
- if (strncasecmp("ff", oid, 2) == 0) {
- _blob = strhex_to_data_blob(NULL, oid);
- if (_blob.data) {
- ret = _blob.length;
- }
- } else {
- if (ber_write_OID_String(&_blob, oid)) {
- ret = _blob.length;
- }
+ ndr_print_struct(ndr, name, "drsuapi_DsReplicaOID");
+ ndr->depth++;
+ ndr_print_uint32(ndr, "length", r->length);
+ ndr->print(ndr, "%-25s: length=%u", "oid", r->length);
+ if (r->binary_oid) {
+ char *partial_oid = NULL;
+ DATA_BLOB oid_blob = data_blob_const(r->binary_oid, r->length);
+ char *hex_str = data_blob_hex_string(ndr, &oid_blob);
+ ber_read_partial_OID_String(ndr, oid_blob, (const char **)&partial_oid);
+ ndr->depth++;
+ ndr->print(ndr, "%-25s: 0x%s (%s)", "binary_oid", hex_str, partial_oid);
+ ndr->depth--;
+ talloc_free(hex_str);
+ talloc_free(partial_oid);
}
- data_blob_free(&_blob);
- return ret;
+ ndr->depth--;
}
enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr1(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesMSZIPCtr1 *r)
diff --git a/librpc/ndr/ndr_drsuapi.h b/librpc/ndr/ndr_drsuapi.h
index 12c2c78..179879a 100644
--- a/librpc/ndr/ndr_drsuapi.h
+++ b/librpc/ndr/ndr_drsuapi.h
@@ -28,8 +28,5 @@ void ndr_print_drsuapi_DsReplicaObjectListItem(struct ndr_print *ndr, const char
void ndr_print_drsuapi_DsReplicaObjectListItemEx(struct ndr_print *ndr, const char *name,
const struct drsuapi_DsReplicaObjectListItemEx *r);
-enum ndr_err_code ndr_push_drsuapi_DsReplicaOID(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsReplicaOID *r);
-enum ndr_err_code ndr_pull_drsuapi_DsReplicaOID(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsReplicaOID *r);
-size_t ndr_size_drsuapi_DsReplicaOID_oid(const char *oid, int flags);
#endif /* _LIBRPC_NDR_NDR_DRSUAPI_H */
diff --git a/source4/dsdb/config.mk b/source4/dsdb/config.mk
index eec4f95..59daa74 100644
--- a/source4/dsdb/config.mk
+++ b/source4/dsdb/config.mk
@@ -39,7 +39,8 @@ SAMDB_SCHEMA_OBJ_FILES = $(addprefix $(dsdbsrcdir)/schema/, \
schema_syntax.o \
schema_description.o \
schema_convert_to_ol.o \
- schema_inferiors.o)
+ schema_inferiors.o \
+ schema_prefixmap.o)
$(eval $(call proto_header_template,$(dsdbsrcdir)/schema/proto.h,$(SAMDB_SCHEMA_OBJ_FILES:.o=.c)))
# PUBLIC_HEADERS += dsdb/schema/schema.h
diff --git a/source4/dsdb/schema/prefixmap.h b/source4/dsdb/schema/prefixmap.h
new file mode 100644
index 0000000..7b28c88
--- /dev/null
+++ b/source4/dsdb/schema/prefixmap.h
@@ -0,0 +1,45 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ DRS::prefixMap data structures
+
+ Copyright (C) Kamen Mazdrashki <kamen.mazdrashki at postpath.com> 2009
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _DSDB_PREFIXMAP_H
+#define _DSDB_PREFIXMAP_H
+
+/**
+ * oid-prefix in prefixmap
+ */
+struct dsdb_schema_prefixmap_oid {
+ uint32_t id;
+ DATA_BLOB *bin_oid; /* partial binary-oid prefix */
+};
+
+/**
+ * DSDB prefixMap internal presentation
+ */
+struct dsdb_schema_prefixmap {
+ uint32_t length;
+ struct dsdb_schema_prefixmap_oid *prefixes;
+};
+
+
+#include "dsdb/schema/proto.h"
+
+
+#endif /* _DSDB_PREFIXMAP_H */
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c
index 9dd3ce0..f8b7d5d 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -29,6 +29,7 @@
#include "librpc/gen_ndr/ndr_drsblobs.h"
#include "param/param.h"
#include "lib/ldb/include/ldb_module.h"
+#include "../lib/util/asn1.h"
static WERROR dsdb_read_prefixes_from_ldb(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, uint32_t* num_prefixes, struct dsdb_schema_oid_prefix **prefixes);
@@ -52,11 +53,11 @@ WERROR dsdb_load_oid_mappings_drsuapi(struct dsdb_schema *schema, const struct d
W_ERROR_HAVE_NO_MEMORY(schema->prefixes);
for (i=0, j=0; i < ctr->num_mappings; i++) {
- if (ctr->mappings[i].oid.oid == NULL) {
+ if (ctr->mappings[i].oid.binary_oid == NULL) {
return WERR_INVALID_PARAM;
}
- if (strncasecmp(ctr->mappings[i].oid.oid, "ff", 2) == 0) {
+ if (ctr->mappings[i].oid.binary_oid[0] == 0xFF) {
if (ctr->mappings[i].id_prefix != 0) {
return WERR_INVALID_PARAM;
}
@@ -66,21 +67,33 @@ WERROR dsdb_load_oid_mappings_drsuapi(struct dsdb_schema *schema, const struct d
return WERR_INVALID_PARAM;
}
- if (ctr->mappings[i].oid.__ndr_size != 21) {
+ if (ctr->mappings[i].oid.length != 21) {
return WERR_INVALID_PARAM;
}
- schema->schema_info = talloc_strdup(schema, ctr->mappings[i].oid.oid);
+ schema->schema_info = hex_encode_talloc(schema,
+ ctr->mappings[i].oid.binary_oid,
+ ctr->mappings[i].oid.length);
W_ERROR_HAVE_NO_MEMORY(schema->schema_info);
} else {
+ DATA_BLOB oid_blob;
+ const char *partial_oid = NULL;
+
/* the last array member should contain the magic value not a oid */
if (i == (ctr->num_mappings - 1)) {
return WERR_INVALID_PARAM;
}
+ oid_blob = data_blob_const(ctr->mappings[i].oid.binary_oid,
+ ctr->mappings[i].oid.length);
+ if (!ber_read_partial_OID_String(schema->prefixes, oid_blob, &partial_oid)) {
+ DEBUG(0, ("ber_read_partial_OID failed on prefixMap item with id: 0x%X",
+ ctr->mappings[i].id_prefix));
+ return WERR_INVALID_PARAM;
--
Samba Shared Repository
More information about the samba-cvs
mailing list