summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/lib/ldb-samba/ldb_wrap.c16
-rw-r--r--source4/param/secrets.c43
2 files changed, 13 insertions, 46 deletions
diff --git a/source4/lib/ldb-samba/ldb_wrap.c b/source4/lib/ldb-samba/ldb_wrap.c
index d7503829b1..80256c9a94 100644
--- a/source4/lib/ldb-samba/ldb_wrap.c
+++ b/source4/lib/ldb-samba/ldb_wrap.c
@@ -168,14 +168,18 @@ static int ldb_wrap_destructor(struct ldb_wrap *w)
"%s/ldb",
lp_modulesdir(lp_ctx)));
- if (ldb_set_opaque(ldb, "sessionInfo", session_info)) {
- talloc_free(ldb);
- return NULL;
+ if (session_info) {
+ if (ldb_set_opaque(ldb, "sessionInfo", session_info)) {
+ talloc_free(ldb);
+ return NULL;
+ }
}
- if (ldb_set_opaque(ldb, "credentials", credentials)) {
- talloc_free(ldb);
- return NULL;
+ if (credentials) {
+ if (ldb_set_opaque(ldb, "credentials", credentials)) {
+ talloc_free(ldb);
+ return NULL;
+ }
}
if (ldb_set_opaque(ldb, "loadparm", lp_ctx)) {
diff --git a/source4/param/secrets.c b/source4/param/secrets.c
index 47a3f6b842..8c135dc2c6 100644
--- a/source4/param/secrets.c
+++ b/source4/param/secrets.c
@@ -26,6 +26,7 @@
#include "param/param.h"
#include "system/filesys.h"
#include "tdb_wrap.h"
+#include "lib/ldb-samba/ldb_wrap.h"
#include "lib/ldb/include/ldb.h"
#include "../tdb/include/tdb.h"
#include "../lib/util/util_tdb.h"
@@ -92,46 +93,8 @@ struct ldb_context *secrets_db_connect(TALLOC_CTX *mem_ctx,
struct tevent_context *ev_ctx,
struct loadparm_context *lp_ctx)
{
- char *path;
- const char *url;
- struct ldb_context *ldb;
-
- url = lp_secrets_url(lp_ctx);
- if (!url || !url[0]) {
- return NULL;
- }
-
- path = private_path(mem_ctx, lp_ctx, url);
- if (!path) {
- return NULL;
- }
-
- /* Secrets.ldb *must* always be local. If we call for a
- * system_session() we will recurse */
- ldb = ldb_init(mem_ctx, ev_ctx);
- if (!ldb) {
- talloc_free(path);
- return NULL;
- }
-
- ldb_set_modules_dir(ldb,
- talloc_asprintf(ldb, "%s/ldb", lp_modulesdir(lp_ctx)));
-
- if (ldb_connect(ldb, path, 0, NULL) != 0) {
- talloc_free(path);
- return NULL;
- }
-
- /* the update_keytab module relies on this being setup */
- if (ldb_set_opaque(ldb, "loadparm", lp_ctx) != LDB_SUCCESS) {
- talloc_free(path);
- talloc_free(ldb);
- return NULL;
- }
-
- talloc_free(path);
-
- return ldb;
+ return ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx, lp_secrets_url(lp_ctx),
+ NULL, NULL, 0);
}
/**