]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
dsdb: Remove OpenLDAP backend complexity from partitions module
authorAndrew Bartlett <abartlet@samba.org>
Mon, 11 Mar 2019 22:46:28 +0000 (11:46 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 30 Aug 2019 08:32:30 +0000 (08:32 +0000)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Nadezhda Ivanova <nivanova@symas.com>
source4/dsdb/samdb/ldb_modules/partition.h
source4/dsdb/samdb/ldb_modules/partition_init.c

index 5790838e31853e6c5aa88324b2a91d7414a0cbc0..e6b5187c7355de5c58ad3f931f6b8530629dd67c 100644 (file)
@@ -52,7 +52,6 @@ struct partition_private_data {
        struct partition_metadata *metadata;
        
        struct partition_module **modules;
-       const char *ldapBackend;
 
        uint64_t metadata_seq;
        uint32_t in_transaction;
index 19033b4f48fe2d28088775fef2d01c66f3876037..58c65ccedd099ebcfcbb00ba592d8e060054a321 100644 (file)
@@ -138,7 +138,7 @@ static int partition_reload_metadata(struct ldb_module *module, struct partition
        struct ldb_message *msg, *module_msg;
        struct ldb_result *res;
        struct ldb_context *ldb = ldb_module_get_ctx(module);
-       const char *attrs[] = { "partition", "replicateEntries", "modules", "ldapBackend",
+       const char *attrs[] = { "partition", "replicateEntries", "modules",
                                "partialReplica", "backendStore", NULL };
        /* perform search for @PARTITION, looking for module, replicateEntries and ldapBackend */
        ret = dsdb_module_search_dn(module, mem_ctx, &res, 
@@ -170,7 +170,6 @@ static int partition_reload_metadata(struct ldb_module *module, struct partition
                return ret;
        }
 
-       data->ldapBackend = talloc_steal(data, ldb_msg_find_attr_as_string(msg, "ldapBackend", NULL));
        if (_msg) {
                *_msg = msg;
        } else {
@@ -205,6 +204,7 @@ static int new_partition_from_dn(struct ldb_context *ldb, struct partition_priva
                                 struct dsdb_partition **partition) {
        struct dsdb_control_current_partition *ctrl;
        struct ldb_module *backend_module;
+       char *backend_path;
        struct ldb_module *module_chain;
        const char **modules;
        const char **options = NULL;
@@ -221,38 +221,33 @@ static int new_partition_from_dn(struct ldb_context *ldb, struct partition_priva
                return ldb_oom(ldb);
        }
 
-       /* See if an LDAP backend has been specified */
-       if (data->ldapBackend) {
-               (*partition)->backend_url = data->ldapBackend;
-       } else {
-               /* the backend LDB is the DN (base64 encoded if not 'plain') followed by .ldb */
-               char *backend_path = ldb_relative_path(ldb,
-                                                      *partition,
-                                                      filename);
-               if (!backend_path) {
-                       ldb_asprintf_errstring(ldb, 
-                                              "partition_init: unable to determine an relative path for partition: %s", filename);
-                       talloc_free(*partition);
-                       return LDB_ERR_OPERATIONS_ERROR;
-               }
-               (*partition)->backend_url = talloc_asprintf(*partition, "%s://%s",
-                                                           backend_db_store,
-                                                           backend_path);
-
-               if (!(ldb_module_flags(ldb) & LDB_FLG_RDONLY)) {
-                       char *p;
-                       char *backend_dir;
+       /* the backend LDB is the DN (base64 encoded if not 'plain') followed by .ldb */
+       backend_path = ldb_relative_path(ldb,
+                                        *partition,
+                                        filename);
+       if (!backend_path) {
+               ldb_asprintf_errstring(ldb,
+                                      "partition_init: unable to determine an relative path for partition: %s",
+                                      filename);
+               talloc_free(*partition);
+               return LDB_ERR_OPERATIONS_ERROR;
+       }
+       (*partition)->backend_url = talloc_asprintf(*partition, "%s://%s",
+                                                   backend_db_store,
+                                                   backend_path);
 
-                       p = strrchr(backend_path, '/');
-                       if (p) {
-                               p[0] = '\0';
-                       }
-                       backend_dir = backend_path;
+       if (!(ldb_module_flags(ldb) & LDB_FLG_RDONLY)) {
+               char *p;
+               char *backend_dir;
 
-                       /* Failure is quite reasonable, it might alredy exist */
-                       mkdir(backend_dir, 0700);
+               p = strrchr(backend_path, '/');
+               if (p) {
+                       p[0] = '\0';
                }
+               backend_dir = backend_path;
 
+               /* Failure is quite reasonable, it might alredy exist */
+               mkdir(backend_dir, 0700);
        }
 
        ctrl->version = DSDB_CONTROL_CURRENT_PARTITION_VERSION;
@@ -534,13 +529,6 @@ int partition_reload_if_required(struct ldb_module *module,
                        talloc_free(partition->ctrl->dn);
                        partition->ctrl->dn = talloc_steal(partition->ctrl, dn_res->msgs[0]->dn);
                        talloc_free(dn_res);
-                       if (data->ldapBackend) {
-                               ret = dsdb_fix_dn_rdncase(ldb, partition->ctrl->dn);
-                               if (ret) {
-                                       talloc_free(mem_ctx);
-                                       return ret;
-                               }
-                       }
                } else if (ret != LDB_ERR_NO_SUCH_OBJECT) {
                        ldb_asprintf_errstring(ldb,
                                               "Failed to search for partition base %s in new partition at %s: %s",