The branch, master has been updated via 74218726e89c297eb957b9df989dd42fd1601742 (commit) via a1da91174b8db082c42ec7e8a6438e11e0e56e91 (commit) via b9ec6bb1eb02121f43498681b99891dc17505512 (commit) via a52e7a2c65aef69a205a81b0c0c84abdd54e8f16 (commit) via 7e54b5e568ec630a85914cdc86ab62823190da9c (commit) via cda99a202dd2b9fbf230d35a32e2bc7a6b1d1f6d (commit) from a77b036f3b823a1de9ee05bfe5c620550097d037 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 74218726e89c297eb957b9df989dd42fd1601742 Author: Andrew Bartlett <abart...@samba.org> Date: Wed Aug 26 13:44:50 2009 +1000 s4:schema Rework dsdb_write_prefixes_from_schema_to_ldb() to use talloc This changes dsdb_write_prefixes_from_schema_to_ldb() to use an internal talloc hirarchy, so we can safely give it a NULL context from the python. It also fixes manual construction of the ldb_message - we now use the right helper functions. Andrew Bartlett commit a1da91174b8db082c42ec7e8a6438e11e0e56e91 Author: Andrew Bartlett <abart...@samba.org> Date: Wed Aug 26 13:43:33 2009 +1000 s4:provison Add prefixes to ldb using same code a later modify will use This allows us to test out the code that will do the modify of the prefixMap, and to provide the bindings that may assist a future upgrade script. Andrew Bartlett commit b9ec6bb1eb02121f43498681b99891dc17505512 Author: Andrew Bartlett <abart...@samba.org> Date: Wed Aug 26 12:39:44 2009 +1000 s4:provision Only create references to our server DN after the self join This will ensure that the GUID can be filled in correctly, and assist us to validate DN targets in the future. Andrew Bartlett commit a52e7a2c65aef69a205a81b0c0c84abdd54e8f16 Author: Andrew Bartlett <abart...@samba.org> Date: Wed Aug 26 12:32:47 2009 +1000 s4:scheam quiet a 'const' warning commit 7e54b5e568ec630a85914cdc86ab62823190da9c Author: Andrew Bartlett <abart...@samba.org> Date: Wed Aug 26 12:29:45 2009 +1000 s4:dsdb Rework dsdb_write_prefixes_to_ldb() to take a schema The aim is to create a function that is more easily wrapped for python, so that we can write the updated prefixMap in an upgrade script. Andrew Bartlett commit cda99a202dd2b9fbf230d35a32e2bc7a6b1d1f6d Author: Andrew Bartlett <abart...@samba.org> Date: Wed Aug 26 11:01:27 2009 +1000 s4:dsdb Use helper function to add 'show deleted' control This revises tridge's commit 61ca4c491e1c13eb7d97847f743b0f540f1117c4 to use ldb_request_add_control() instead of a manual construction. Andrew Bartlett ----------------------------------------------------------------------- Summary of changes: source4/dsdb/samdb/ldb_modules/objectclass.c | 30 ++++------- source4/dsdb/schema/schema_init.c | 61 +++++++++++---------- source4/scripting/python/pyglue.c | 26 +++++++++ source4/scripting/python/samba/__init__.py | 3 + source4/scripting/python/samba/provision.py | 24 +++++++-- source4/setup/provision.ldif | 2 - source4/setup/provision_basedn_modify.ldif | 3 - source4/setup/provision_configuration.ldif | 2 - source4/setup/provision_schema_basedn_modify.ldif | 5 -- source4/setup/provision_self_join_modify.ldif | 29 ++++++++++ 10 files changed, 120 insertions(+), 65 deletions(-) create mode 100644 source4/setup/provision_self_join_modify.ldif Changeset truncated at 500 lines: diff --git a/source4/dsdb/samdb/ldb_modules/objectclass.c b/source4/dsdb/samdb/ldb_modules/objectclass.c index eb35ad0..6dbafac 100644 --- a/source4/dsdb/samdb/ldb_modules/objectclass.c +++ b/source4/dsdb/samdb/ldb_modules/objectclass.c @@ -997,7 +997,6 @@ static int objectclass_rename(struct ldb_module *module, struct ldb_request *req struct oc_context *ac; struct ldb_dn *parent_dn; int ret; - struct ldb_control **ctrl; ldb = ldb_module_get_ctx(module); @@ -1026,36 +1025,27 @@ static int objectclass_rename(struct ldb_module *module, struct ldb_request *req return LDB_ERR_OPERATIONS_ERROR; } - /* we have to add the show deleted control, as otherwise DRS - deletes will be refused as we will think the target parent - does not exist */ - ctrl = talloc_array(req, struct ldb_control, 2); - if (!ctrl) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - ctrl[0] = talloc(ctrl, struct ldb_control); - if (!ctrl[0]) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - ctrl[0]->oid = LDB_CONTROL_SHOW_DELETED_OID; - ctrl[0]->critical = 0; - ctrl[0]->data = NULL; - ctrl[1] = NULL; - /* note that the results of this search are kept and used to update the parentGUID in objectclass_rename_callback() */ ret = ldb_build_search_req(&search_req, ldb, ac, parent_dn, LDB_SCOPE_BASE, "(objectClass=*)", - attrs, ctrl, + attrs, NULL, ac, get_search_callback, req); if (ret != LDB_SUCCESS) { return ret; } + /* we have to add the show deleted control, as otherwise DRS + deletes will be refused as we will think the target parent + does not exist */ + ret = ldb_request_add_control(search_req, LDB_CONTROL_SHOW_DELETED_OID, false, NULL); + + if (ret != LDB_SUCCESS) { + return ret; + } + ac->step_fn = objectclass_do_rename; return ldb_next_request(ac->module, search_req); diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c index c2d4597..3b701ad 100644 --- a/source4/dsdb/schema/schema_init.c +++ b/source4/dsdb/schema/schema_init.c @@ -340,8 +340,12 @@ WERROR dsdb_create_prefix_mapping(struct ldb_context *ldb, struct dsdb_schema *s return status; } + talloc_free(schema->prefixes); + schema->prefixes = talloc_steal(schema, prefixes); + schema->num_prefixes = num_prefixes; + /* Update prefixMap in ldb*/ - status = dsdb_write_prefixes_to_ldb(mem_ctx, ldb, num_prefixes, prefixes); + status = dsdb_write_prefixes_from_schema_to_ldb(mem_ctx, ldb, schema); if (!W_ERROR_IS_OK(status)) { DEBUG(0,("dsdb_create_prefix_mapping: dsdb_write_prefixes_to_ldb: %s\n", win_errstr(status))); @@ -349,10 +353,6 @@ WERROR dsdb_create_prefix_mapping(struct ldb_context *ldb, struct dsdb_schema *s return status; } - talloc_free(schema->prefixes); - schema->prefixes = talloc_steal(schema, prefixes); - schema->num_prefixes = num_prefixes; - DEBUG(2,(__location__ " Added prefixMap %s - now have %u prefixes\n", full_oid, num_prefixes)); @@ -455,59 +455,64 @@ WERROR dsdb_find_prefix_for_oid(uint32_t num_prefixes, const struct dsdb_schema_ return WERR_DS_NO_MSDS_INTID; } -WERROR dsdb_write_prefixes_to_ldb(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, - uint32_t num_prefixes, - const struct dsdb_schema_oid_prefix *prefixes) +WERROR dsdb_write_prefixes_from_schema_to_ldb(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, + const struct dsdb_schema *schema) { - struct ldb_message msg; + struct ldb_message *msg = ldb_msg_new(mem_ctx); struct ldb_dn *schema_dn; - struct ldb_message_element el; struct prefixMapBlob pm; struct ldb_val ndr_blob; enum ndr_err_code ndr_err; uint32_t i; int ret; + + if (!msg) { + return WERR_NOMEM; + } schema_dn = samdb_schema_dn(ldb); if (!schema_dn) { - DEBUG(0,("dsdb_write_prefixes_to_ldb: no schema dn present\n")); + DEBUG(0,("dsdb_write_prefixes_from_schema_to_ldb: no schema dn present\n")); return WERR_FOOBAR; } pm.version = PREFIX_MAP_VERSION_DSDB; - pm.ctr.dsdb.num_mappings = num_prefixes; - pm.ctr.dsdb.mappings = talloc_array(mem_ctx, + pm.ctr.dsdb.num_mappings = schema->num_prefixes; + pm.ctr.dsdb.mappings = talloc_array(msg, struct drsuapi_DsReplicaOIDMapping, pm.ctr.dsdb.num_mappings); if (!pm.ctr.dsdb.mappings) { + talloc_free(msg); return WERR_NOMEM; } - for (i=0; i < num_prefixes; i++) { - pm.ctr.dsdb.mappings[i].id_prefix = prefixes[i].id>>16; - pm.ctr.dsdb.mappings[i].oid.oid = talloc_strdup(pm.ctr.dsdb.mappings, prefixes[i].oid); + for (i=0; i < schema->num_prefixes; i++) { + pm.ctr.dsdb.mappings[i].id_prefix = schema->prefixes[i].id>>16; + pm.ctr.dsdb.mappings[i].oid.oid = talloc_strdup(pm.ctr.dsdb.mappings, schema->prefixes[i].oid); } - ndr_err = ndr_push_struct_blob(&ndr_blob, ldb, + ndr_err = ndr_push_struct_blob(&ndr_blob, msg, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &pm, (ndr_push_flags_fn_t)ndr_push_prefixMapBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(msg); return WERR_FOOBAR; } - el.num_values = 1; - el.values = &ndr_blob; - el.flags = LDB_FLAG_MOD_REPLACE; - el.name = talloc_strdup(mem_ctx, "prefixMap"); - - msg.dn = ldb_dn_copy(mem_ctx, schema_dn); - msg.num_elements = 1; - msg.elements = ⪙ + msg->dn = schema_dn; + ret = ldb_msg_add_value(msg, "prefixMap", &ndr_blob, NULL); + if (ret != 0) { + talloc_free(msg); + DEBUG(0,("dsdb_write_prefixes_from_schema_to_ldb: ldb_msg_add_value failed\n")); + return WERR_NOMEM; + } - ret = ldb_modify( ldb, &msg ); + ret = samdb_replace( ldb, msg, msg ); + talloc_free(msg); + if (ret != 0) { - DEBUG(0,("dsdb_write_prefixes_to_ldb: ldb_modify failed\n")); + DEBUG(0,("dsdb_write_prefixes_from_schema_to_ldb: samdb_replace failed\n")); return WERR_FOOBAR; } @@ -654,7 +659,7 @@ static int dsdb_schema_setup_ldb_schema_attribute(struct ldb_context *ldb, #define GET_STRING_LDB(msg, attr, mem_ctx, p, elem, strict) do { \ - struct ldb_val *get_string_val = ldb_msg_find_ldb_val(msg, attr); \ + const struct ldb_val *get_string_val = ldb_msg_find_ldb_val(msg, attr); \ if (get_string_val == NULL) { \ if (strict) { \ d_printf("%s: %s == NULL\n", __location__, attr); \ diff --git a/source4/scripting/python/pyglue.c b/source4/scripting/python/pyglue.c index f5694e1..55ba5c3 100644 --- a/source4/scripting/python/pyglue.c +++ b/source4/scripting/python/pyglue.c @@ -344,6 +344,30 @@ static PyObject *py_dsdb_convert_schema_to_openldap(PyObject *self, PyObject *ar return ret; } +static PyObject *py_dsdb_write_prefixes_from_schema_to_ldb(PyObject *self, PyObject *args) +{ + PyObject *py_ldb; + struct ldb_context *ldb; + WERROR result; + struct dsdb_schema *schema; + + if (!PyArg_ParseTuple(args, "O", &py_ldb)) + return NULL; + + PyErr_LDB_OR_RAISE(py_ldb, ldb); + + schema = dsdb_get_schema(ldb); + if (!schema) { + PyErr_SetString(PyExc_RuntimeError, "Failed to set find a schema on ldb!\n"); + return NULL; + } + + result = dsdb_write_prefixes_from_schema_to_ldb(NULL, ldb, schema); + PyErr_WERROR_IS_ERR_RAISE(result); + + Py_RETURN_NONE; +} + static PyObject *py_dsdb_set_schema_from_ldb(PyObject *self, PyObject *args) { PyObject *py_ldb; @@ -424,6 +448,8 @@ static PyMethodDef py_misc_methods[] = { NULL }, { "dsdb_set_schema_from_ldif", (PyCFunction)py_dsdb_set_schema_from_ldif, METH_VARARGS, NULL }, + { "dsdb_write_prefixes_from_schema_to_ldb", (PyCFunction)py_dsdb_write_prefixes_from_schema_to_ldb, METH_VARARGS, + NULL }, { "dsdb_set_schema_from_ldb", (PyCFunction)py_dsdb_set_schema_from_ldb, METH_VARARGS, NULL }, { "dsdb_convert_schema_to_openldap", (PyCFunction)py_dsdb_convert_schema_to_openldap, METH_VARARGS, diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py index 69a0320..4df3d6f 100644 --- a/source4/scripting/python/samba/__init__.py +++ b/source4/scripting/python/samba/__init__.py @@ -239,6 +239,9 @@ class Ldb(ldb.Ldb): def set_schema_from_ldb(self, ldb): glue.dsdb_set_schema_from_ldb(self, ldb) + def write_prefixes_from_schema(self): + glue.dsdb_write_prefixes_from_schema_to_ldb(self) + def convert_schema_to_openldap(self, target, mapping): return glue.dsdb_convert_schema_to_openldap(self, target, mapping) diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 39ae33b..a8cedaf 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -151,18 +151,21 @@ class Schema(object): self.schema_data += open(setup_path("schema_samba4.ldif"), 'r').read() self.schema_data = substitute_var(self.schema_data, {"SCHEMADN": schemadn}) check_all_substituted(self.schema_data) - prefixmap = open(setup_path("prefixMap.txt"), 'r').read() - prefixmap = b64encode(prefixmap) - + self.schema_dn_modify = read_and_sub_file(setup_path("provision_schema_basedn_modify.ldif"), {"SCHEMADN": schemadn, - "PREFIXMAP_B64": prefixmap, "SERVERDN": serverdn, }) self.schema_dn_add = read_and_sub_file(setup_path("provision_schema_basedn.ldif"), {"SCHEMADN": schemadn }) - self.ldb.set_schema_from_ldif(self.schema_dn_modify, self.schema_data) + + prefixmap = open(setup_path("prefixMap.txt"), 'r').read() + prefixmap = b64encode(prefixmap) + + # We don't actually add this ldif, just parse it + prefixmap_ldif = "dn: cn=schema\nprefixMap:: %s\n\n" % prefixmap + self.ldb.set_schema_from_ldif(prefixmap_ldif, self.schema_data) def check_install(lp, session_info, credentials): @@ -787,12 +790,22 @@ def setup_self_join(samdb, names, "DNSDOMAIN": names.dnsdomain, "SAMBA_VERSION_STRING": version, "DOMAIN_CONTROLLER_FUNCTIONALITY": str(domainControllerFunctionality)}) + setup_add_ldif(samdb, setup_path("provision_group_policy.ldif"), { "POLICYGUID": policyguid, "DNSDOMAIN": names.dnsdomain, "DOMAINSID": str(domainsid), "DOMAINDN": names.domaindn}) + # Setup fSMORoleOwner entries to point at the newly created DC entry + setup_modify_ldif(samdb, setup_path("provision_self_join_modify.ldif"), { + "DOMAINDN": names.domaindn, + "CONFIGDN": names.configdn, + "SCHEMADN": names.schemadn, + "DEFAULTSITE": names.sitename, + "SERVERDN": names.serverdn + }) + def setup_samdb(path, setup_path, session_info, credentials, lp, names, message, @@ -900,6 +913,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp, message("Setting up sam.ldb schema") samdb.add_ldif(schema.schema_dn_add) samdb.modify_ldif(schema.schema_dn_modify) + samdb.write_prefixes_from_schema() samdb.add_ldif(schema.schema_data) setup_add_ldif(samdb, setup_path("aggregate_schema.ldif"), {"SCHEMADN": names.schemadn}) diff --git a/source4/setup/provision.ldif b/source4/setup/provision.ldif index 07f02f9..4622112 100644 --- a/source4/setup/provision.ldif +++ b/source4/setup/provision.ldif @@ -49,7 +49,6 @@ dn: CN=Infrastructure,${DOMAINDN} objectClass: top objectClass: infrastructureUpdate systemFlags: -1946157056 -fSMORoleOwner: CN=NTDS Settings,${SERVERDN} isCriticalSystemObject: TRUE dn: CN=LostAndFound,${DOMAINDN} @@ -192,7 +191,6 @@ dn: CN=RID Manager$,CN=System,${DOMAINDN} objectClass: top objectClass: rIDManager systemFlags: -1946157056 -fSMORoleOwner: CN=NTDS Settings,${SERVERDN} rIDAvailablePool: 4611686014132423217 isCriticalSystemObject: TRUE diff --git a/source4/setup/provision_basedn_modify.ldif b/source4/setup/provision_basedn_modify.ldif index 29ba75b..4dd75bb 100644 --- a/source4/setup/provision_basedn_modify.ldif +++ b/source4/setup/provision_basedn_modify.ldif @@ -61,9 +61,6 @@ uASCompat: 1 replace: modifiedCount modifiedCount: 1 - -replace: fSMORoleOwner -fSMORoleOwner: CN=NTDS Settings,${SERVERDN} -- replace: systemFlags systemFlags: -1946157056 - diff --git a/source4/setup/provision_configuration.ldif b/source4/setup/provision_configuration.ldif index b3e0d83..2b900a7 100644 --- a/source4/setup/provision_configuration.ldif +++ b/source4/setup/provision_configuration.ldif @@ -656,7 +656,6 @@ objectClass: top objectClass: crossRefContainer systemFlags: -2147483648 msDS-Behavior-Version: ${FOREST_FUNCTIONALALITY} -fSMORoleOwner: CN=NTDS Settings,${SERVERDN} showInAdvancedViewOnly: TRUE dn: CN=Enterprise Configuration,CN=Partitions,${CONFIGDN} @@ -749,7 +748,6 @@ dn: CN=NTDS Site Settings,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN} objectClass: top objectClass: applicationSiteSettings objectClass: nTDSSiteSettings -interSiteTopologyGenerator: CN=NTDS Settings,${SERVERDN} dn: CN=Servers,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN} objectClass: top diff --git a/source4/setup/provision_schema_basedn_modify.ldif b/source4/setup/provision_schema_basedn_modify.ldif index d6c4589..5591f8b 100644 --- a/source4/setup/provision_schema_basedn_modify.ldif +++ b/source4/setup/provision_schema_basedn_modify.ldif @@ -3,12 +3,7 @@ ############################### dn: ${SCHEMADN} changetype: modify -replace: fSMORoleOwner -fSMORoleOwner: CN=NTDS Settings,${SERVERDN} - replace: objectVersion objectVersion: 30 -- -replace: prefixMap -prefixMap:: ${PREFIXMAP_B64} diff --git a/source4/setup/provision_self_join_modify.ldif b/source4/setup/provision_self_join_modify.ldif new file mode 100644 index 0000000..4ba291f --- /dev/null +++ b/source4/setup/provision_self_join_modify.ldif @@ -0,0 +1,29 @@ +dn: ${DOMAINDN} +changetype: modify +replace: fSMORoleOwner +fSMORoleOwner: CN=NTDS Settings,${SERVERDN} + +dn: ${SCHEMADN} +changetype: modify +replace: fSMORoleOwner +fSMORoleOwner: CN=NTDS Settings,${SERVERDN} + +dn: CN=Infrastructure,${DOMAINDN} +changetype: modify +replace: fSMORoleOwner +fSMORoleOwner: CN=NTDS Settings,${SERVERDN} + +dn: CN=RID Manager$,CN=System,${DOMAINDN} +changetype: modify +replace: fSMORoleOwner +fSMORoleOwner: CN=NTDS Settings,${SERVERDN} + +dn: CN=Partitions,${CONFIGDN} +changetype: modify +replace: fSMORoleOwner +fSMORoleOwner: CN=NTDS Settings,${SERVERDN} + +dn: CN=NTDS Site Settings,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN} +changetype: modify +replace: interSiteTopologyGenerator +interSiteTopologyGenerator: CN=NTDS Settings,${SERVERDN} -- Samba Shared Repository