s3:idmap_tdb: have idmap_tdb_open_db take an idmap_domain struct as argument
authorMichael Adam <obnox@samba.org>
Wed, 23 Jun 2010 08:53:29 +0000 (10:53 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 23 Jun 2010 10:22:13 +0000 (12:22 +0200)
the other arguments are not needed any more and are removed.

source3/winbindd/idmap_tdb.c

index d924afc7a103e1653fcfb5e04960eb21a0da95cf..3e3546a7e80d9ffc667aa6877dee5b6e74563e1c 100644 (file)
@@ -242,27 +242,20 @@ static NTSTATUS idmap_tdb_load_ranges(void)
        return NT_STATUS_OK;
 }
 
-static NTSTATUS idmap_tdb_open_db(TALLOC_CTX *memctx,
-                                 bool check_config,
-                                 struct db_context **dbctx)
+static NTSTATUS idmap_tdb_open_db(struct idmap_domain *dom)
 {
        NTSTATUS ret;
-       TALLOC_CTX *ctx;
+       TALLOC_CTX *mem_ctx;
        char *tdbfile = NULL;
        struct db_context *db = NULL;
        int32_t version;
        bool config_error = false;
+       struct idmap_tdb_context *ctx;
 
-       ret = idmap_tdb_load_ranges();
-       if (!NT_STATUS_IS_OK(ret)) {
-               config_error = true;
-               if (check_config) {
-                       return ret;
-               }
-       }
+       ctx = talloc_get_type(dom->private_data, struct idmap_tdb_context);
 
        /* use our own context here */
-       ctx = talloc_stackframe();
+       mem_ctx = talloc_stackframe();
 
        /* use the old database if present */
        tdbfile = state_path("winbindd_idmap.tdb");
@@ -275,7 +268,7 @@ static NTSTATUS idmap_tdb_open_db(TALLOC_CTX *memctx,
        DEBUG(10,("Opening tdbfile %s\n", tdbfile ));
 
        /* Open idmap repository */
-       db = db_open(ctx, tdbfile, 0, TDB_DEFAULT, O_RDWR | O_CREAT, 0644);
+       db = db_open(mem_ctx, tdbfile, 0, TDB_DEFAULT, O_RDWR | O_CREAT, 0644);
        if (!db) {
                DEBUG(0, ("Unable to open idmap database\n"));
                ret = NT_STATUS_UNSUCCESSFUL;
@@ -312,11 +305,11 @@ static NTSTATUS idmap_tdb_open_db(TALLOC_CTX *memctx,
                }
        }
 
-       *dbctx = talloc_move(memctx, &db);
+       ctx->db = talloc_move(ctx, &db);
        ret = NT_STATUS_OK;
 
 done:
-       talloc_free(ctx);
+       talloc_free(mem_ctx);
        return ret;
 }
 
@@ -552,13 +545,13 @@ static NTSTATUS idmap_tdb_db_init(struct idmap_domain *dom, const char *params)
        }
 #endif
 
-       ret = idmap_tdb_open_db(ctx, false, &ctx->db);
+       dom->private_data = ctx;
+
+       ret = idmap_tdb_open_db(dom);
        if ( ! NT_STATUS_IS_OK(ret)) {
                goto failed;
        }
 
-       dom->private_data = ctx;
-
        return NT_STATUS_OK;
 
 failed: