dsdb:schema_load: make use of ldb_relative_path() in partition_metadata_open()
authorGary Lockyer <gary@catalyst.net.nz>
Tue, 6 Mar 2018 00:40:21 +0000 (13:40 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 3 May 2018 06:17:45 +0000 (08:17 +0200)
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source4/dsdb/samdb/ldb_modules/schema_load.c

index 7cbbeb699ee25e208b79dc97743f5848180d6025..fd19d1051621186bed7c5a049619179c412b8eaf 100644 (file)
@@ -32,6 +32,7 @@
 #include <tdb.h>
 #include "lib/tdb_wrap/tdb_wrap.h"
 #include "dsdb/samdb/ldb_modules/util.h"
+#include "lib/ldb-samba/ldb_wrap.h"
 
 #include "system/filesys.h"
 struct schema_load_private_data {
@@ -63,7 +64,6 @@ static int schema_metadata_open(struct ldb_module *module)
        struct ldb_context *ldb = ldb_module_get_ctx(module);
        TALLOC_CTX *tmp_ctx;
        struct loadparm_context *lp_ctx;
-       const char *sam_name;
        char *filename;
        int open_flags;
        struct stat statbuf;
@@ -79,19 +79,9 @@ static int schema_metadata_open(struct ldb_module *module)
                return ldb_module_oom(module);
        }
 
-       sam_name = (const char *)ldb_get_opaque(ldb, "ldb_url");
-       if (!sam_name) {
-               talloc_free(tmp_ctx);
-               return ldb_operr(ldb);
-       }
-       if (strncmp("tdb://", sam_name, 6) == 0) {
-               sam_name += 6;
-       }
-       filename = talloc_asprintf(tmp_ctx, "%s.d/metadata.tdb", sam_name);
-       if (!filename) {
-               talloc_free(tmp_ctx);
-               return ldb_oom(ldb);
-       }
+       filename = ldb_relative_path(ldb,
+                                    tmp_ctx,
+                                    "sam.ldb.d/metadata.tdb");
 
        open_flags = O_RDWR;
        if (stat(filename, &statbuf) != 0) {