s3:idmap_tdb: add idmap_rw_ops to idmap_tdb_context and initialize them in init_db
authorMichael Adam <obnox@samba.org>
Wed, 23 Jun 2010 10:12:37 +0000 (12:12 +0200)
committerMichael Adam <obnox@samba.org>
Sat, 14 Aug 2010 00:10:57 +0000 (02:10 +0200)
source3/Makefile.in
source3/winbindd/idmap_tdb.c

index 88dd21a38a31d48cab1a0bef4f9255e602295492..9feabfbcedb80591122065ec655030c56a931ce9 100644 (file)
@@ -1202,7 +1202,9 @@ PAM_SMBPASS_OBJ = $(PAM_SMBPASS_OBJ_0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(PASSDB_
                $(SMBLDAP_OBJ) $(LIBSAMBA_OBJ) \
                $(LIBTSOCKET_OBJ)
 
-IDMAP_OBJ     = winbindd/idmap.o winbindd/idmap_util.o @IDMAP_STATIC@
+IDMAP_RW_OBJ = winbindd/idmap_rw.o
+
+IDMAP_OBJ     = winbindd/idmap.o winbindd/idmap_util.o $(IDMAP_RW_OBJ) @IDMAP_STATIC@
 
 NSS_INFO_OBJ = winbindd/nss_info.o @NSS_INFO_STATIC@
 
@@ -2683,9 +2685,9 @@ bin/adex.@SHLIBEXT@: $(BINARY_PREREQS) $(IDMAP_ADEX_OBJ)
        @echo "Building plugin $@"
        @$(SHLD_MODULE) $(IDMAP_ADEX_OBJ)
 
-bin/tdb2.@SHLIBEXT@: $(BINARY_PREREQS) winbindd/idmap_tdb2.o winbindd/idmap_rw.o
+bin/tdb2.@SHLIBEXT@: $(BINARY_PREREQS) winbindd/idmap_tdb2.o $(IDMAP_RW_OBJ)
        @echo "Building plugin $@"
-       @$(SHLD_MODULE) winbindd/idmap_tdb2.o winbindd/idmap_rw.o
+       @$(SHLD_MODULE) winbindd/idmap_tdb2.o $(IDMAP_RW_OBJ)
 
 bin/ldap.@SHLIBEXT@: $(BINARY_PREREQS) winbindd/idmap_ldap.o
        @echo "Building plugin $@"
index 75a5e442742dd2f83fa0ed48e69775f424642fb5..66d9701bcfc16e7cf209bb1417bcfe264bcdcf07 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "includes.h"
 #include "winbindd.h"
+#include "idmap_rw.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_IDMAP
@@ -36,6 +37,7 @@
 
 struct idmap_tdb_context {
        struct db_context *db;
+       struct idmap_rw_ops *rw_ops;
 };
 
 /* High water mark keys */
@@ -478,6 +480,9 @@ static NTSTATUS idmap_tdb_get_new_id(struct idmap_domain *dom,
  Initialise idmap database. 
 *****************************/
 
+static NTSTATUS idmap_tdb_set_mapping(struct idmap_domain *dom,
+                                     const struct id_map *map);
+
 static NTSTATUS idmap_tdb_db_init(struct idmap_domain *dom, const char *params)
 {
        NTSTATUS ret;
@@ -498,6 +503,16 @@ static NTSTATUS idmap_tdb_db_init(struct idmap_domain *dom, const char *params)
        }
 #endif
 
+       ctx->rw_ops = talloc_zero(ctx, struct idmap_rw_ops);
+       if (ctx->rw_ops == NULL) {
+               DEBUG(0, ("Out of memory!\n"));
+               ret = NT_STATUS_NO_MEMORY;
+               goto failed;
+       }
+
+       ctx->rw_ops->get_new_id = idmap_tdb_get_new_id;
+       ctx->rw_ops->set_mapping = idmap_tdb_set_mapping;
+
        dom->private_data = ctx;
 
        ret = idmap_tdb_open_db(dom);