diff options
author | Andrew Bartlett <abartlet@samba.org> | 2007-04-28 15:18:25 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:51:43 -0500 |
commit | f34c57f4fc1a1817735ddb653011e6deb0edf912 (patch) | |
tree | 2582876276ed24bd2e88090886204d53168cbed3 /source4/dsdb/samdb | |
parent | b006d86e659b318bb73360cd537905e2cd801992 (diff) | |
download | samba-f34c57f4fc1a1817735ddb653011e6deb0edf912.tar.gz samba-f34c57f4fc1a1817735ddb653011e6deb0edf912.tar.bz2 samba-f34c57f4fc1a1817735ddb653011e6deb0edf912.zip |
r22557: Simo has long bugged me that the paths in the sam.ldb partitions were
not relative to the location of the sam.ldb, but instead
lp_private_dir().
This fixes that issue.
Andrew Bartlett
(This used to be commit c0fd6f63399d55a1938e31ae7b10689cc02ff2fa)
Diffstat (limited to 'source4/dsdb/samdb')
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/partition.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c index 614431c563..b301a98534 100644 --- a/source4/dsdb/samdb/ldb_modules/partition.c +++ b/source4/dsdb/samdb/ldb_modules/partition.c @@ -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); |