r22557: Simo has long bugged me that the paths in the sam.ldb partitions were
authorAndrew Bartlett <abartlet@samba.org>
Sat, 28 Apr 2007 15:18:25 +0000 (15:18 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:51:43 +0000 (14:51 -0500)
not relative to the location of the sam.ldb, but instead
lp_private_dir().

This fixes that issue.

Andrew Bartlett

source/dsdb/samdb/ldb_modules/partition.c
source/lib/ldb/common/ldb.c

index 614431c5630fc46683f27186b9f991e8f57f16ac..b301a985342b22ba12fd03a0279d6f1fbe241503 100644 (file)
@@ -703,6 +703,33 @@ static int sort_compare(void *void1,
        return ldb_dn_compare(partition1->dn, partition2->dn);
 }
 
+static const char *relative_path(struct ldb_module *module, 
+                                TALLOC_CTX *mem_ctx, 
+                                const char *name) 
+{
+       const char *base_url = ldb_get_opaque(module->ldb, "ldb_url");
+       char *path, *p, *full_name;
+       if (name == NULL) {
+               return NULL;
+       }
+       if (name[0] == 0 || name[0] == '/' || strstr(name, ":/")) {
+               return talloc_strdup(mem_ctx, name);
+       }
+       path = talloc_strdup(mem_ctx, base_url);
+       if (path == NULL) {
+               return NULL;
+       }
+       if ( (p = strrchr(path, '/')) != NULL) {
+               p[0] = '\0';
+       } else {
+               talloc_free(path);
+               return NULL;
+       }
+       full_name = talloc_asprintf(mem_ctx, "%s/%s", path, name);
+       talloc_free(path);
+       return full_name;
+}
+
 static int partition_init(struct ldb_module *module)
 {
        int ret, i;
@@ -791,7 +818,9 @@ static int partition_init(struct ldb_module *module)
                        return LDB_ERR_CONSTRAINT_VIOLATION;
                }
 
-               data->partitions[i]->backend = private_path(data->partitions[i], p);
+               data->partitions[i]->backend = relative_path(module, 
+                                                            data->partitions[i], 
+                                                            p);
                ret = ldb_connect_backend(module->ldb, data->partitions[i]->backend, NULL, &data->partitions[i]->module);
                if (ret != LDB_SUCCESS) {
                        talloc_free(mem_ctx);
index c317fe57faff77316143a32d1db34c98135b2df7..26213facf2a2d7ea471633a606d49e9713b17ae2 100644 (file)
@@ -231,12 +231,22 @@ struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb)
 int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[])
 {
        int ret;
-
+       const char *url2;
        /* We seem to need to do this here, or else some utilities don't get ldb backends */
        ldb_global_init();
 
        ldb->flags = flags;
 
+       url2 = talloc_strdup(ldb, url);
+       if (!url2) {
+               ldb_oom(ldb);
+               return LDB_ERR_OPERATIONS_ERROR;
+       }
+       ret = ldb_set_opaque(ldb, "ldb_url", talloc_strdup(ldb, url2));
+       if (ret != LDB_SUCCESS) {
+               return ret;
+       }
+
        ret = ldb_connect_backend(ldb, url, options, &ldb->modules);
        if (ret != LDB_SUCCESS) {
                return ret;