The branch, master has been updated
       via  8d8678f... s4:dsdb Allow calling dsdb_convert_object_ex() directly
       via  72486a6... s4:dsdb Add debug
       via  088d5b7... s4:dsdb Simplfy match of objectclass in 
dsdb_schema_set_el_from_ldb_msg
       via  57b6979... s4:provision Allow both additional and override 
prefixmaps in Schema
       via  6336f24... s4:dsdb Allow a binary prefix map to be specified in the 
LDIF
       via  d6f5c1a... s4:dsdb Provide a function to convert from DRS prefix 
maps to the LDB prefixmap
       via  e828364... s4:dsdb Add more debugs to help track down failures to 
parse the prefixmap
       via  c6bf8e4... s4:dsdb Put back the reference and set_attributes in 
dsdb_reference_schema
      from  7aa8af1... check if LD_AS_NEEDED breaks linking with libreadline 
fixes #7209

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 8d8678fcfd8017a679ec9ce442f050a43689fcaa
Author: Andrew Bartlett <[email protected]>
Date:   Sat Jun 12 11:03:36 2010 +1000

    s4:dsdb Allow calling dsdb_convert_object_ex() directly
    
    This will allow the libnet_vampire code to manually convert individual
    schema objects.
    
    Andrew Bartlett

commit 72486a6dd16608465e1b76bf838d3f5b019dac8f
Author: Andrew Bartlett <[email protected]>
Date:   Thu Jun 10 21:34:48 2010 +1000

    s4:dsdb Add debug

commit 088d5b76ca416e798b505d9fd9266db73a0a8450
Author: Andrew Bartlett <[email protected]>
Date:   Thu Jun 10 21:29:57 2010 +1000

    s4:dsdb Simplfy match of objectclass in dsdb_schema_set_el_from_ldb_msg
    
    There is no need to do a full ldb_match_msg() for a simple case
    insensitive string.
    
    Andrew Bartlett

commit 57b6979ad034b50debd47979e05b925daa54b5a4
Author: Andrew Bartlett <[email protected]>
Date:   Thu Jun 10 08:58:44 2010 +1000

    s4:provision Allow both additional and override prefixmaps in Schema
    
    The idea here is to allow some callers to specify a new prefixMap that
    will override the values loaded from the prefixMap.txt.
    
    Andrew Bartlett

commit 6336f244758e78dfce61715b5de403e3db7fb02e
Author: Andrew Bartlett <[email protected]>
Date:   Thu Jun 10 08:51:30 2010 +1000

    s4:dsdb Allow a binary prefix map to be specified in the LDIF
    
    This allows it to be specified in either binary or as a string.
    
    Andrew Bartlett

commit d6f5c1ace215131dc09611abcd2a52254bdab4d6
Author: Andrew Bartlett <[email protected]>
Date:   Thu Jun 10 08:27:59 2010 +1000

    s4:dsdb Provide a function to convert from DRS prefix maps to the LDB 
prefixmap
    
    This allows us to push a prefixmap directly into the schema we
    generate in the provision code.
    
    Andrew Bartlett

commit e82836467c2ecdcb2c89c2b6eb4dae51bd2f22a2
Author: Andrew Bartlett <[email protected]>
Date:   Thu Jun 10 08:25:49 2010 +1000

    s4:dsdb Add more debugs to help track down failures to parse the prefixmap

commit c6bf8e4cadea563011630af2fa673e3ea5e3b2ee
Author: Andrew Bartlett <[email protected]>
Date:   Wed Jun 9 20:21:19 2010 +1000

    s4:dsdb Put back the reference and set_attributes in dsdb_reference_schema
    
    I'm not sure why I removed these in fe3e1af901c970f738bee92baac5d7d4f5736e17
    
    Andrew Bartlett

-----------------------------------------------------------------------

Summary of changes:
 source4/dsdb/repl/replicated_objects.c             |   12 ++--
 source4/dsdb/schema/schema_init.c                  |   58 ++++++++++++++------
 source4/dsdb/schema/schema_set.c                   |   30 +++++------
 source4/lib/ldb-samba/ldif_handlers.c              |   14 +++++
 source4/libnet/libnet_vampire.c                    |    1 +
 source4/scripting/python/samba/provisionbackend.py |    2 +-
 source4/scripting/python/samba/schema.py           |   11 +++--
 7 files changed, 83 insertions(+), 45 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/repl/replicated_objects.c 
b/source4/dsdb/repl/replicated_objects.c
index 5e69236..838dc84 100644
--- a/source4/dsdb/repl/replicated_objects.c
+++ b/source4/dsdb/repl/replicated_objects.c
@@ -31,12 +31,12 @@
 #include "libcli/auth/libcli_auth.h"
 #include "param/param.h"
 
-static WERROR dsdb_convert_object_ex(struct ldb_context *ldb,
-                                    const struct dsdb_schema *schema,
-                                    const struct 
drsuapi_DsReplicaObjectListItemEx *in,
-                                    const DATA_BLOB *gensec_skey,
-                                    TALLOC_CTX *mem_ctx,
-                                    struct dsdb_extended_replicated_object 
*out)
+WERROR dsdb_convert_object_ex(struct ldb_context *ldb,
+                             const struct dsdb_schema *schema,
+                             const struct drsuapi_DsReplicaObjectListItemEx 
*in,
+                             const DATA_BLOB *gensec_skey,
+                             TALLOC_CTX *mem_ctx,
+                             struct dsdb_extended_replicated_object *out)
 {
        NTSTATUS nt_status;
        WERROR status;
diff --git a/source4/dsdb/schema/schema_init.c 
b/source4/dsdb/schema/schema_init.c
index 55e78eb..8e47f12 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -81,17 +81,25 @@ static WERROR _dsdb_prefixmap_from_ldb_val(const struct 
ldb_val *pfm_ldb_val,
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err);
                talloc_free(temp_ctx);
+               DEBUG(0,("_dsdb_prefixmap_from_ldb_val: Failed to parse 
prefixmap of length %u: %s\n",
+                        (unsigned int)pfm_ldb_val->length, 
ndr_map_error2string(ndr_err)));
+               talloc_free(temp_ctx);
                return ntstatus_to_werror(nt_status);
        }
 
        if (pfm_blob.version != PREFIX_MAP_VERSION_DSDB) {
-               DEBUG(0,("_dsdb_prefixmap_from_ldb_val: pfm_blob->version 
incorrect\n"));
+               DEBUG(0,("_dsdb_prefixmap_from_ldb_val: pfm_blob->version %u 
incorrect\n", (unsigned int)pfm_blob.version));
                talloc_free(temp_ctx);
                return WERR_VERSION_PARSE_ERROR;
        }
 
        /* call the drsuapi version */
        werr = dsdb_schema_pfm_from_drsuapi_pfm(&pfm_blob.ctr.dsdb, false, 
mem_ctx, _pfm, NULL);
+       if (!W_ERROR_IS_OK(werr)) {
+               DEBUG(0, (__location__ " dsdb_schema_pfm_from_drsuapi_pfm 
failed: %s\n", win_errstr(werr)));
+               talloc_free(temp_ctx);
+               return werr;
+       }
 
        talloc_free(temp_ctx);
 
@@ -113,12 +121,20 @@ WERROR dsdb_load_oid_mappings_ldb(struct dsdb_schema 
*schema,
 
        /* parse schemaInfo blob to verify it is valid */
        werr = dsdb_schema_info_from_blob(schemaInfo, mem_ctx, &schi);
-       W_ERROR_NOT_OK_GOTO(werr, DONE);
+       if (!W_ERROR_IS_OK(werr)) {
+               DEBUG(0, (__location__ " dsdb_schema_info_from_blob failed: 
%s\n", win_errstr(werr)));
+               talloc_free(mem_ctx);
+               return werr;
+       }
 
        /* fetch prefixMap */
        werr = _dsdb_prefixmap_from_ldb_val(prefixMap,
                                            mem_ctx, &pfm);
-       W_ERROR_NOT_OK_GOTO(werr, DONE);
+       if (!W_ERROR_IS_OK(werr)) {
+               DEBUG(0, (__location__ " _dsdb_prefixmap_from_ldb_val failed: 
%s\n", win_errstr(werr)));
+               talloc_free(mem_ctx);
+               return werr;
+       }
 
        /* decode schema_info */
        schema_info = hex_encode_talloc(mem_ctx,
@@ -136,11 +152,10 @@ WERROR dsdb_load_oid_mappings_ldb(struct dsdb_schema 
*schema,
        talloc_free(discard_const(schema->schema_info));
        schema->schema_info = talloc_steal(schema, schema_info);
 
-DONE:
        /* clean up locally allocated mem */
        talloc_free(mem_ctx);
 
-       return werr;
+       return WERR_OK;
 }
 
 WERROR dsdb_get_oid_mappings_drsuapi(const struct dsdb_schema *schema,
@@ -153,30 +168,39 @@ WERROR dsdb_get_oid_mappings_drsuapi(const struct 
dsdb_schema *schema,
                                                mem_ctx, _ctr);
 }
 
-WERROR dsdb_get_oid_mappings_ldb(const struct dsdb_schema *schema,
-                                TALLOC_CTX *mem_ctx,
-                                struct ldb_val *prefixMap,
-                                struct ldb_val *schemaInfo)
+WERROR dsdb_get_drsuapi_prefixmap_as_blob(const struct 
drsuapi_DsReplicaOIDMapping_Ctr *ctr,
+                                         TALLOC_CTX *mem_ctx,
+                                         struct ldb_val *prefixMap)
 {
-       WERROR status;
-       enum ndr_err_code ndr_err;
-       struct drsuapi_DsReplicaOIDMapping_Ctr *ctr;
        struct prefixMapBlob pfm;
-
-       status = dsdb_get_oid_mappings_drsuapi(schema, false, mem_ctx, &ctr);
-       W_ERROR_NOT_OK_RETURN(status);
-
+       enum ndr_err_code ndr_err;
        pfm.version     = PREFIX_MAP_VERSION_DSDB;
        pfm.reserved    = 0;
        pfm.ctr.dsdb    = *ctr;
 
        ndr_err = ndr_push_struct_blob(prefixMap, mem_ctx, &pfm,
                                        
(ndr_push_flags_fn_t)ndr_push_prefixMapBlob);
-       talloc_free(ctr);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err);
                return ntstatus_to_werror(nt_status);
        }
+       return WERR_OK;
+}
+
+WERROR dsdb_get_oid_mappings_ldb(const struct dsdb_schema *schema,
+                                TALLOC_CTX *mem_ctx,
+                                struct ldb_val *prefixMap,
+                                struct ldb_val *schemaInfo)
+{
+       WERROR status;
+       struct drsuapi_DsReplicaOIDMapping_Ctr *ctr;
+
+       status = dsdb_get_oid_mappings_drsuapi(schema, false, mem_ctx, &ctr);
+       W_ERROR_NOT_OK_RETURN(status);
+
+       status = dsdb_get_drsuapi_prefixmap_as_blob(ctr, mem_ctx, prefixMap);
+       talloc_free(ctr);
+       W_ERROR_NOT_OK_RETURN(status);
 
        *schemaInfo = strhex_to_data_blob(mem_ctx, schema->schema_info);
        W_ERROR_HAVE_NO_MEMORY(schemaInfo->data);
diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c
index 07d75c4..5ecbad2 100644
--- a/source4/dsdb/schema/schema_set.c
+++ b/source4/dsdb/schema/schema_set.c
@@ -390,6 +390,15 @@ int dsdb_reference_schema(struct ldb_context *ldb, struct 
dsdb_schema *schema,
                return ret;
        }
 
+       if (talloc_reference(ldb, schema) == NULL) {
+               return LDB_ERR_OPERATIONS_ERROR;
+       }
+
+       ret = dsdb_schema_set_attributes(ldb, schema, write_attributes);
+       if (ret != LDB_SUCCESS) {
+               return ret;
+       }
+
        return LDB_SUCCESS;
 }
 
@@ -540,24 +549,11 @@ int dsdb_schema_fill_extended_dn(struct ldb_context *ldb, 
struct dsdb_schema *sc
 WERROR dsdb_schema_set_el_from_ldb_msg(struct ldb_context *ldb, struct 
dsdb_schema *schema, 
                                       struct ldb_message *msg) 
 {
-       static struct ldb_parse_tree *attr_tree, *class_tree;
-       if (!attr_tree) {
-               attr_tree = ldb_parse_tree(talloc_autofree_context(), 
"(objectClass=attributeSchema)");
-               if (!attr_tree) {
-                       return WERR_NOMEM;
-               }
-       }
-
-       if (!class_tree) {
-               class_tree = ldb_parse_tree(talloc_autofree_context(), 
"(objectClass=classSchema)");
-               if (!class_tree) {
-                       return WERR_NOMEM;
-               }
-       }
-
-       if (ldb_match_msg(ldb, msg, attr_tree, NULL, LDB_SCOPE_BASE)) {
+       if (samdb_find_attribute(ldb, msg,
+                                "objectclass", "attributeSchema") != NULL) {
                return dsdb_attribute_from_ldb(ldb, schema, msg);
-       } else if (ldb_match_msg(ldb, msg, class_tree, NULL, LDB_SCOPE_BASE)) {
+       } else if (samdb_find_attribute(ldb, msg,
+                                "objectclass", "classSchema") != NULL) {
                return dsdb_class_from_ldb(schema, msg);
        }
 
diff --git a/source4/lib/ldb-samba/ldif_handlers.c 
b/source4/lib/ldb-samba/ldif_handlers.c
index 91abefc..f335d6c 100644
--- a/source4/lib/ldb-samba/ldif_handlers.c
+++ b/source4/lib/ldb-samba/ldif_handlers.c
@@ -526,6 +526,20 @@ static int ldif_read_prefixMap(struct ldb_context *ldb, 
void *mem_ctx,
                return -1;
        }
 
+       ndr_err = ndr_pull_struct_blob(in, blob, blob,
+                                      
(ndr_pull_flags_fn_t)ndr_pull_prefixMapBlob);
+       if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               ndr_err = ndr_push_struct_blob(out, mem_ctx,
+                                              blob,
+                                              
(ndr_push_flags_fn_t)ndr_push_prefixMapBlob);
+               talloc_free(tmp_ctx);
+               if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+                       return -1;
+               }
+               return 0;
+       }
+
+       /* If this does not parse, then it is probably the text version, and we 
should try it that way */
        blob->version = PREFIX_MAP_VERSION_DSDB;
        
        string = talloc_strndup(mem_ctx, (const char *)in->data, in->length);
diff --git a/source4/libnet/libnet_vampire.c b/source4/libnet/libnet_vampire.c
index d083fc9..06387a9 100644
--- a/source4/libnet/libnet_vampire.c
+++ b/source4/libnet/libnet_vampire.c
@@ -288,6 +288,7 @@ static NTSTATUS vampire_apply_schema(struct vampire_state 
*s,
        /* attach the schema to the ldb */
        ret = dsdb_set_schema(s->ldb, s->self_made_schema);
        if (ret != LDB_SUCCESS) {
+               DEBUG(0,("Failed to attach schema from DRS.\n"));
                return NT_STATUS_FOOBAR;
        }
        /* we don't want to access the self made schema anymore */
diff --git a/source4/scripting/python/samba/provisionbackend.py 
b/source4/scripting/python/samba/provisionbackend.py
index 629bc28..b8abc28 100644
--- a/source4/scripting/python/samba/provisionbackend.py
+++ b/source4/scripting/python/samba/provisionbackend.py
@@ -604,7 +604,7 @@ class FDSBackend(LDAPBackend):
                 schemadn=self.names.schemadn,
                 serverdn=self.names.serverdn,
                 files=[setup_path("schema_samba4.ldif"), self.samba3_ldif],
-                prefixmap=["1000:1.3.6.1.4.1.7165.2.1", 
"1001:1.3.6.1.4.1.7165.2.2"])
+                additional_prefixmap=["1000:1.3.6.1.4.1.7165.2.1", 
"1001:1.3.6.1.4.1.7165.2.2"])
 
     def provision(self):
         from samba.provision import ProvisioningError
diff --git a/source4/scripting/python/samba/schema.py 
b/source4/scripting/python/samba/schema.py
index fc4f131..bdc09cf 100644
--- a/source4/scripting/python/samba/schema.py
+++ b/source4/scripting/python/samba/schema.py
@@ -53,7 +53,7 @@ def get_schema_descriptor(domain_sid):
 class Schema(object):
 
     def __init__(self, setup_path, domain_sid, invocationid=None, 
schemadn=None,
-                 serverdn=None, files=None, prefixmap=None, am_rodc=False):
+                 serverdn=None, files=None, override_prefixmap=None, 
additional_prefixmap=None, am_rodc=False):
         """Load schema for the SamDB from the AD schema files and 
samba4_schema.ldif
         
         :param samdb: Load a schema into a SamDB.
@@ -92,10 +92,13 @@ class Schema(object):
             setup_path("provision_schema_basedn.ldif"),
             {"SCHEMADN": schemadn, "DESCRIPTOR": descr})
 
-        self.prefixmap_data = open(setup_path("prefixMap.txt"), 'r').read()
+        if override_prefixmap is not None:
+            self.prefixmap_data = override_prefixmap
+        else:
+            self.prefixmap_data = open(setup_path("prefixMap.txt"), 'r').read()
 
-        if prefixmap is not None:
-            for map in prefixmap:
+        if additional_prefixmap is not None:
+            for map in additional_prefixmap:
                 self.prefixmap_data += "%s\n" % map
 
         self.prefixmap_data = b64encode(self.prefixmap_data)


-- 
Samba Shared Repository

Reply via email to