From 1f28541a241d2dc4c5460344f817d56182a672ce Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 16 Dec 2008 09:21:55 +0100 Subject: s4:dsdb: split extended_dn into extended_dn_in, extended_dn_out and extended_dn_store. By splitting the module, the extended_dn_in and extended_dn_store moudles can use extended_dn_out to actually get the extended DN. This avoids code duplication. The extended_dn_out module also contains a client implementation of the OpenLDAP dereference control (draft-masarati-ldap-deref-00). This also introduces a new control 'DSDB_CONTROL_DN_STORAGE_FORMAT_OID' to ask the extended_dn_out module to return whatever the 'storage format' is. This allows us to work with both OpenLDAP (which performs a dereference at run time) and LDB (which stores the GUID and SID on disk). Signed-off-by: Stefan Metzmacher --- source4/scripting/python/samba/provision.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 823d5e6ff6..9ee77bd376 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -459,8 +459,9 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info, "ranged_results", "anr", "server_sort", - "extended_dn", "asq", + "extended_dn_store", + "extended_dn_in", "rdn_name", "objectclass", "samldb", -- cgit From ebe1e923c862798602b563211ec8c625fc4032ea Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 16 Dec 2008 09:18:21 +0100 Subject: s4:provision: use extended_dn_out_ldb or extended_dn_out_dereference depending on the backend This just changes the existing stratagy of loading different modules for the OpenLDAP backend to also include extended_dn_out_* When we provision the OpenLDAP backend, we make sure to include the 'deref' overlay (which must be made available by the OpenLDAP build) Signed-off-by: Stefan Metzmacher --- source4/scripting/python/samba/provision.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 9ee77bd376..5da073c563 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -471,7 +471,8 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info, tdb_modules_list = [ "subtree_rename", "subtree_delete", - "linked_attributes"] + "linked_attributes", + "extended_dn_out_ldb"] modules_list2 = ["show_deleted", "partition"] @@ -489,11 +490,11 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info, if ldap_backend_type == "fedora-ds": backend_modules = ["nsuniqueid", "paged_searches"] # We can handle linked attributes here, as we don't have directory-side subtree operations - tdb_modules_list = ["linked_attributes"] + tdb_modules_list = ["linked_attributes", "extended_dn_out_dereference"] elif ldap_backend_type == "openldap": - backend_modules = ["normalise", "entryuuid", "paged_searches"] + backend_modules = ["entryuuid", "paged_searches"] # OpenLDAP handles subtree renames, so we don't want to do any of these things - tdb_modules_list = None + tdb_modules_list = ["extended_dn_out_dereference"] elif ldap_backend is not None: raise "LDAP Backend specified, but LDAP Backend Type not specified" elif serverrole == "domain controller": -- cgit From 7a5b6a2ea194677c59ad6fab0aca3f102b5b2f46 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 18 Dec 2008 17:17:56 +1100 Subject: Handle different failure modes when we wipe the db in provision We didn't handle the mode where we can't load the main sam.ldb due to the modules being 'wrong', and when we did remove the file, we didn't wipe the partitions. --- source4/scripting/python/samba/provision.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 5da073c563..95bff74e75 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -432,17 +432,18 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info, """ assert session_info is not None - samdb = SamDB(samdb_path, session_info=session_info, - credentials=credentials, lp=lp) - - # Wipes the database try: + samdb = SamDB(samdb_path, session_info=session_info, + credentials=credentials, lp=lp) + # Wipes the database samdb.erase() except: os.unlink(samdb_path) - - samdb = SamDB(samdb_path, session_info=session_info, - credentials=credentials, lp=lp) + samdb = SamDB(samdb_path, session_info=session_info, + credentials=credentials, lp=lp) + # Wipes the database + samdb.erase() + #Add modules to the list to activate them by default #beware often order is important -- cgit From 61a2d5c8784a99d4d0419a00375be91a3e9bfc33 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 18 Dec 2008 16:49:33 +0000 Subject: Use plain Python C API for registry module, rather than SWIG. --- source4/scripting/python/samba/provision.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 95bff74e75..b81f618a48 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -653,7 +653,7 @@ def setup_registry(path, setup_path, session_info, credentials, lp): reg = registry.Registry() hive = registry.open_ldb(path, session_info=session_info, credentials=credentials, lp_ctx=lp) - reg.mount_hive(hive, "HKEY_LOCAL_MACHINE") + reg.mount_hive(hive, registry.HKEY_LOCAL_MACHINE) provision_reg = setup_path("provision.reg") assert os.path.exists(provision_reg) reg.diff_apply(provision_reg) -- cgit From 21702bfcdece4e71dcb4ab50e111911a5777f9a5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 18 Dec 2008 20:43:05 +0000 Subject: Cope with slight changes in tdb API. --- source4/scripting/python/samba/samba3.py | 77 +++++++++++++++++++------------- 1 file changed, 46 insertions(+), 31 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/python/samba/samba3.py b/source4/scripting/python/samba/samba3.py index 0e0c29dac8..a3dac27709 100644 --- a/source4/scripting/python/samba/samba3.py +++ b/source4/scripting/python/samba/samba3.py @@ -25,9 +25,28 @@ REGISTRY_VALUE_PREFIX = "SAMBA_REGVAL" REGISTRY_DB_VERSION = 1 import os +import struct import tdb +def fetch_uint32(tdb, key): + try: + data = tdb[key] + except KeyError: + return None + assert len(data) == 4 + return struct.unpack(" Date: Fri, 19 Dec 2008 09:47:59 +1100 Subject: Move aggregate schema stub to it's own file This should make it easier to import just the schema entries from the WSPP docs. Andrew Bartlett --- source4/scripting/python/samba/provision.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index b81f618a48..3711ed7bab 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -830,6 +830,8 @@ def setup_samdb(path, setup_path, session_info, credentials, lp, message("Setting up sam.ldb AD schema") setup_add_ldif(samdb, setup_path("schema.ldif"), {"SCHEMADN": names.schemadn}) + setup_add_ldif(samdb, setup_path("aggregate_schema.ldif"), + {"SCHEMADN": names.schemadn}) message("Setting up sam.ldb configuration data") setup_add_ldif(samdb, setup_path("provision_configuration.ldif"), { -- cgit