s4:secrets Ensure secrets.ldb uses the same hooks as the rest of Samba
authorAndrew Bartlett <abartlet@samba.org>
Wed, 23 Jun 2010 11:15:43 +0000 (21:15 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 29 Jun 2010 06:59:31 +0000 (16:59 +1000)
This ensures that, for example, the utf8 functions are the same,
the GUID handler is the same and the NOSYNC flag is applied.

Andrew Bartlett

source4/lib/ldb-samba/ldb_wrap.c
source4/param/secrets.c

index d7503829b1a4a12efc247d44e7d182d39ea3cbff..80256c9a940a7e4000e9dcd8d418ddfce7db0100 100644 (file)
@@ -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)) {
index 47a3f6b842c961052c541621f07a93f497a26abe..8c135dc2c661847d4630ac8ca46452712d38d95a 100644 (file)
@@ -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);
 }
 
 /**