2 Unix SMB/CIFS implementation.
4 idmap TDB2 backend, used for clustered Samba setups.
6 This uses dbwrap to access tdb files. The location can be set
7 using tdb:idmap2.tdb =" in smb.conf
9 Copyright (C) Andrew Tridgell 2007
11 This is heavily based upon idmap_tdb.c, which is:
13 Copyright (C) Tim Potter 2000
14 Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
15 Copyright (C) Jeremy Allison 2006
16 Copyright (C) Simo Sorce 2003-2006
18 This program is free software; you can redistribute it and/or modify
19 it under the terms of the GNU General Public License as published by
20 the Free Software Foundation; either version 2 of the License, or
21 (at your option) any later version.
23 This program is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 GNU General Public License for more details.
28 You should have received a copy of the GNU General Public License
29 along with this program; if not, write to the Free Software
30 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
37 #define DBGC_CLASS DBGC_IDMAP
39 /* High water mark keys */
40 #define HWM_GROUP "GROUP HWM"
41 #define HWM_USER "USER HWM"
43 static struct idmap_tdb2_state {
44 /* User and group id pool */
45 uid_t low_uid, high_uid; /* Range of uids to allocate */
46 gid_t low_gid, high_gid; /* Range of gids to allocate */
47 const char *idmap_script;
52 /* handle to the permanent tdb */
53 static struct db_context *idmap_tdb2;
55 static NTSTATUS idmap_tdb2_alloc_load(void);
57 static NTSTATUS idmap_tdb2_load_ranges(void)
64 if (!lp_idmap_uid(&low_uid, &high_uid)) {
65 DEBUG(1, ("idmap uid missing\n"));
66 return NT_STATUS_UNSUCCESSFUL;
69 if (!lp_idmap_gid(&low_gid, &high_gid)) {
70 DEBUG(1, ("idmap gid missing\n"));
71 return NT_STATUS_UNSUCCESSFUL;
74 idmap_tdb2_state.low_uid = low_uid;
75 idmap_tdb2_state.high_uid = high_uid;
76 idmap_tdb2_state.low_gid = low_gid;
77 idmap_tdb2_state.high_gid = high_gid;
79 if (idmap_tdb2_state.high_uid <= idmap_tdb2_state.low_uid) {
80 DEBUG(1, ("idmap uid range missing or invalid\n"));
81 DEBUGADD(1, ("idmap will be unable to map foreign SIDs\n"));
82 return NT_STATUS_UNSUCCESSFUL;
85 if (idmap_tdb2_state.high_gid <= idmap_tdb2_state.low_gid) {
86 DEBUG(1, ("idmap gid range missing or invalid\n"));
87 DEBUGADD(1, ("idmap will be unable to map foreign SIDs\n"));
88 return NT_STATUS_UNSUCCESSFUL;
95 open the permanent tdb
97 static NTSTATUS idmap_tdb2_open_db(void)
102 /* its already open */
106 db_path = lp_parm_talloc_string(-1, "tdb", "idmap2.tdb", NULL);
107 if (db_path == NULL) {
108 /* fall back to the private directory, which, despite
109 its name, is usually on shared storage */
110 db_path = talloc_asprintf(NULL, "%s/idmap2.tdb", lp_private_dir());
112 NT_STATUS_HAVE_NO_MEMORY(db_path);
114 /* Open idmap repository */
115 idmap_tdb2 = db_open(NULL, db_path, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0644);
116 TALLOC_FREE(db_path);
118 if (idmap_tdb2 == NULL) {
119 DEBUG(0, ("Unable to open idmap_tdb2 database '%s'\n",
121 return NT_STATUS_UNSUCCESSFUL;
124 /* load the ranges and high/low water marks */
125 return idmap_tdb2_alloc_load();
130 load the idmap allocation ranges and high/low water marks
132 static NTSTATUS idmap_tdb2_alloc_load(void)
137 /* see if a idmap script is configured */
138 idmap_tdb2_state.idmap_script = lp_parm_const_string(-1, "idmap",
141 if (idmap_tdb2_state.idmap_script) {
142 DEBUG(1, ("using idmap script '%s'\n",
143 idmap_tdb2_state.idmap_script));
148 status = idmap_tdb2_load_ranges();
149 if (!NT_STATUS_IS_OK(status)) {
153 /* Create high water marks for group and user id */
155 low_id = dbwrap_fetch_int32(idmap_tdb2, HWM_USER);
156 if ((low_id == -1) || (low_id < idmap_tdb2_state.low_uid)) {
157 if (!NT_STATUS_IS_OK(dbwrap_trans_store_int32(
158 idmap_tdb2, HWM_USER,
159 idmap_tdb2_state.low_uid))) {
160 DEBUG(0, ("Unable to initialise user hwm in idmap "
162 return NT_STATUS_INTERNAL_DB_ERROR;
166 low_id = dbwrap_fetch_int32(idmap_tdb2, HWM_GROUP);
167 if ((low_id == -1) || (low_id < idmap_tdb2_state.low_gid)) {
168 if (!NT_STATUS_IS_OK(dbwrap_trans_store_int32(
169 idmap_tdb2, HWM_GROUP,
170 idmap_tdb2_state.low_gid))) {
171 DEBUG(0, ("Unable to initialise group hwm in idmap "
173 return NT_STATUS_INTERNAL_DB_ERROR;
182 Initialise idmap alloc database.
184 static NTSTATUS idmap_tdb2_alloc_init(const char *params)
186 /* nothing to do - we want to avoid opening the permanent
187 database if possible. Instead we load the params when we
197 struct idmap_tdb2_allocate_id_context {
204 static NTSTATUS idmap_tdb2_allocate_id_action(struct db_context *db,
209 struct idmap_tdb2_allocate_id_context *state;
212 state = (struct idmap_tdb2_allocate_id_context *)private_data;
214 hwm = dbwrap_fetch_int32(db, state->hwmkey);
216 ret = NT_STATUS_INTERNAL_DB_ERROR;
220 /* check it is in the range */
221 if (hwm > state->high_hwm) {
222 DEBUG(1, ("Fatal Error: %s range full!! (max: %lu)\n",
223 state->hwmtype, (unsigned long)state->high_hwm));
224 ret = NT_STATUS_UNSUCCESSFUL;
228 /* fetch a new id and increment it */
229 res = dbwrap_change_uint32_atomic(db, state->hwmkey, &hwm, 1);
231 DEBUG(1, ("Fatal error while fetching a new %s value\n!",
233 ret = NT_STATUS_UNSUCCESSFUL;
237 /* recheck it is in the range */
238 if (hwm > state->high_hwm) {
239 DEBUG(1, ("Fatal Error: %s range full!! (max: %lu)\n",
240 state->hwmtype, (unsigned long)state->high_hwm));
241 ret = NT_STATUS_UNSUCCESSFUL;
252 static NTSTATUS idmap_tdb2_allocate_id(struct unixid *xid)
259 struct idmap_tdb2_allocate_id_context state;
261 status = idmap_tdb2_open_db();
262 NT_STATUS_NOT_OK_RETURN(status);
264 /* Get current high water mark */
270 high_hwm = idmap_tdb2_state.high_uid;
276 high_hwm = idmap_tdb2_state.high_gid;
280 DEBUG(2, ("Invalid ID type (0x%x)\n", xid->type));
281 return NT_STATUS_INVALID_PARAMETER;
285 state.high_hwm = high_hwm;
286 state.hwmtype = hwmtype;
287 state.hwmkey = hwmkey;
289 status = dbwrap_trans_do(idmap_tdb2, idmap_tdb2_allocate_id_action,
292 if (NT_STATUS_IS_OK(status)) {
294 DEBUG(10,("New %s = %d\n", hwmtype, hwm));
296 DEBUG(1, ("Error allocating a new %s\n", hwmtype));
303 Get current highest id.
305 static NTSTATUS idmap_tdb2_get_hwm(struct unixid *xid)
313 status = idmap_tdb2_open_db();
314 NT_STATUS_NOT_OK_RETURN(status);
316 /* Get current high water mark */
322 high_hwm = idmap_tdb2_state.high_uid;
328 high_hwm = idmap_tdb2_state.high_gid;
332 return NT_STATUS_INVALID_PARAMETER;
335 if ((hwm = dbwrap_fetch_int32(idmap_tdb2, hwmkey)) == -1) {
336 return NT_STATUS_INTERNAL_DB_ERROR;
341 /* Warn if it is out of range */
342 if (hwm >= high_hwm) {
343 DEBUG(0, ("Warning: %s range full!! (max: %lu)\n",
344 hwmtype, (unsigned long)high_hwm));
353 static NTSTATUS idmap_tdb2_set_hwm(struct unixid *xid)
355 /* not supported, or we would invalidate the cache tdb on
357 DEBUG(0,("idmap_tdb2_set_hwm not supported\n"));
358 return NT_STATUS_NOT_SUPPORTED;
364 static NTSTATUS idmap_tdb2_alloc_close(void)
366 /* don't actually close it */
371 IDMAP MAPPING TDB BACKEND
373 struct idmap_tdb2_context {
374 uint32_t filter_low_id;
375 uint32_t filter_high_id;
379 Initialise idmap database.
381 static NTSTATUS idmap_tdb2_db_init(struct idmap_domain *dom,
385 struct idmap_tdb2_context *ctx;
388 status = idmap_tdb2_open_db();
389 NT_STATUS_NOT_OK_RETURN(status);
391 ctx = talloc(dom, struct idmap_tdb2_context);
393 DEBUG(0, ("Out of memory!\n"));
394 return NT_STATUS_NO_MEMORY;
397 if (strequal(dom->name, "*")) {
403 ctx->filter_low_id = 0;
404 ctx->filter_high_id = 0;
406 if (lp_idmap_uid(&low_uid, &high_uid)) {
407 ctx->filter_low_id = low_uid;
408 ctx->filter_high_id = high_uid;
410 DEBUG(3, ("Warning: 'idmap uid' not set!\n"));
413 if (lp_idmap_gid(&low_gid, &high_gid)) {
414 if ((low_gid != low_uid) || (high_gid != high_uid)) {
415 DEBUG(1, ("Warning: 'idmap uid' and 'idmap gid'"
416 " ranges do not agree -- building "
418 ctx->filter_low_id = MAX(ctx->filter_low_id,
420 ctx->filter_high_id = MIN(ctx->filter_high_id,
424 DEBUG(3, ("Warning: 'idmap gid' not set!\n"));
427 char *config_option = NULL;
429 config_option = talloc_asprintf(ctx, "idmap config %s", dom->name);
430 if ( ! config_option) {
431 DEBUG(0, ("Out of memory!\n"));
432 ret = NT_STATUS_NO_MEMORY;
436 range = lp_parm_const_string(-1, config_option, "range", NULL);
438 (sscanf(range, "%u - %u", &ctx->filter_low_id, &ctx->filter_high_id) != 2))
440 ctx->filter_low_id = 0;
441 ctx->filter_high_id = 0;
444 talloc_free(config_option);
447 if (ctx->filter_low_id > ctx->filter_high_id) {
448 ctx->filter_low_id = 0;
449 ctx->filter_high_id = 0;
452 dom->private_data = ctx;
461 struct idmap_tdb2_set_mapping_context {
466 static NTSTATUS idmap_tdb2_set_mapping_action(struct db_context *db,
471 struct idmap_tdb2_set_mapping_context *state;
472 TALLOC_CTX *tmp_ctx = talloc_stackframe();
474 DEBUG(10, ("Storing %s <-> %s map\n", state->ksidstr, state->kidstr));
476 state = (struct idmap_tdb2_set_mapping_context *)private_data;
478 /* check wheter sid mapping is already present in db */
479 data = dbwrap_fetch_bystring(db, tmp_ctx, state->ksidstr);
481 ret = NT_STATUS_OBJECT_NAME_COLLISION;
485 ret = dbwrap_store_bystring(db, state->ksidstr,
486 string_term_tdb_data(state->kidstr),
488 if (!NT_STATUS_IS_OK(ret)) {
489 DEBUG(0, ("Error storing SID -> ID: %s\n", nt_errstr(ret)));
493 ret = dbwrap_store_bystring(db, state->kidstr,
494 string_term_tdb_data(state->ksidstr),
496 if (!NT_STATUS_IS_OK(ret)) {
497 DEBUG(0, ("Error storing ID -> SID: %s\n", nt_errstr(ret)));
498 /* try to remove the previous stored SID -> ID map */
499 dbwrap_delete_bystring(db, state->ksidstr);
503 DEBUG(10,("Stored %s <-> %s\n", state->ksidstr, state->kidstr));
506 talloc_free(tmp_ctx);
512 run a script to perform a mapping
514 The script should the following command lines:
520 and should return one of the following as a single line of text
526 static NTSTATUS idmap_tdb2_script(struct idmap_tdb2_context *ctx, struct id_map *map,
527 const char *fmt, ...)
535 cmd = talloc_asprintf(ctx, "%s ", idmap_tdb2_state.idmap_script);
536 NT_STATUS_HAVE_NO_MEMORY(cmd);
539 cmd = talloc_vasprintf_append(cmd, fmt, ap);
541 NT_STATUS_HAVE_NO_MEMORY(cmd);
546 return NT_STATUS_NONE_MAPPED;
549 if (fgets(line, sizeof(line)-1, p) == NULL) {
551 return NT_STATUS_NONE_MAPPED;
555 DEBUG(10,("idmap script gave: %s\n", line));
557 if (sscanf(line, "UID:%lu", &v) == 1) {
559 map->xid.type = ID_TYPE_UID;
560 } else if (sscanf(line, "GID:%lu", &v) == 1) {
562 map->xid.type = ID_TYPE_GID;
563 } else if (strncmp(line, "SID:S-", 6) == 0) {
564 if (!string_to_sid(map->sid, &line[4])) {
565 DEBUG(0,("Bad SID in '%s' from idmap script %s\n",
566 line, idmap_tdb2_state.idmap_script));
567 return NT_STATUS_NONE_MAPPED;
570 DEBUG(0,("Bad reply '%s' from idmap script %s\n",
571 line, idmap_tdb2_state.idmap_script));
572 return NT_STATUS_NONE_MAPPED;
581 Single id to sid lookup function.
583 static NTSTATUS idmap_tdb2_id_to_sid(struct idmap_tdb2_context *ctx, struct id_map *map)
590 status = idmap_tdb2_open_db();
591 NT_STATUS_NOT_OK_RETURN(status);
594 return NT_STATUS_INVALID_PARAMETER;
597 /* apply filters before checking */
598 if ((ctx->filter_low_id && (map->xid.id < ctx->filter_low_id)) ||
599 (ctx->filter_high_id && (map->xid.id > ctx->filter_high_id))) {
600 DEBUG(5, ("Requested id (%u) out of range (%u - %u). Filtered!\n",
601 map->xid.id, ctx->filter_low_id, ctx->filter_high_id));
602 return NT_STATUS_NONE_MAPPED;
605 switch (map->xid.type) {
608 keystr = talloc_asprintf(ctx, "UID %lu", (unsigned long)map->xid.id);
612 keystr = talloc_asprintf(ctx, "GID %lu", (unsigned long)map->xid.id);
616 DEBUG(2, ("INVALID unix ID type: 0x02%x\n", map->xid.type));
617 return NT_STATUS_INVALID_PARAMETER;
620 /* final SAFE_FREE safe */
623 if (keystr == NULL) {
624 DEBUG(0, ("Out of memory!\n"));
625 ret = NT_STATUS_NO_MEMORY;
629 DEBUG(10,("Fetching record %s\n", keystr));
631 /* Check if the mapping exists */
632 data = dbwrap_fetch_bystring(idmap_tdb2, keystr, keystr);
636 struct idmap_tdb2_set_mapping_context store_state;
638 DEBUG(10,("Record %s not found\n", keystr));
639 if (idmap_tdb2_state.idmap_script == NULL) {
640 ret = NT_STATUS_NONE_MAPPED;
644 ret = idmap_tdb2_script(ctx, map, "IDTOSID %s", keystr);
646 /* store it on shared storage */
647 if (!NT_STATUS_IS_OK(ret)) {
651 sidstr = sid_string_talloc(keystr, map->sid);
653 ret = NT_STATUS_NO_MEMORY;
657 store_state.ksidstr = sidstr;
658 store_state.kidstr = keystr;
660 ret = dbwrap_trans_do(idmap_tdb2, idmap_tdb2_set_mapping_action,
665 if (!string_to_sid(map->sid, (const char *)data.dptr)) {
666 DEBUG(10,("INVALID SID (%s) in record %s\n",
667 (const char *)data.dptr, keystr));
668 ret = NT_STATUS_INTERNAL_DB_ERROR;
672 DEBUG(10,("Found record %s -> %s\n", keystr, (const char *)data.dptr));
682 Single sid to id lookup function.
684 static NTSTATUS idmap_tdb2_sid_to_id(struct idmap_tdb2_context *ctx, struct id_map *map)
689 unsigned long rec_id = 0;
690 TALLOC_CTX *tmp_ctx = talloc_stackframe();
692 ret = idmap_tdb2_open_db();
693 NT_STATUS_NOT_OK_RETURN(ret);
695 keystr = sid_string_talloc(tmp_ctx, map->sid);
696 if (keystr == NULL) {
697 DEBUG(0, ("Out of memory!\n"));
698 ret = NT_STATUS_NO_MEMORY;
702 DEBUG(10,("Fetching record %s\n", keystr));
704 /* Check if sid is present in database */
705 data = dbwrap_fetch_bystring(idmap_tdb2, tmp_ctx, keystr);
709 DEBUG(10,(__location__ " Record %s not found\n", keystr));
711 if (idmap_tdb2_state.idmap_script == NULL) {
712 ret = NT_STATUS_NONE_MAPPED;
716 ret = idmap_tdb2_script(ctx, map, "SIDTOID %s", keystr);
717 /* store it on shared storage */
718 if (!NT_STATUS_IS_OK(ret)) {
722 snprintf(idstr, sizeof(idstr), "%cID %lu",
723 map->xid.type == ID_TYPE_UID?'U':'G',
724 (unsigned long)map->xid.id);
725 /* store both forward and reverse mappings */
726 dbwrap_store_bystring(idmap_tdb2, keystr, string_term_tdb_data(idstr),
728 dbwrap_store_bystring(idmap_tdb2, idstr, string_term_tdb_data(keystr),
733 /* What type of record is this ? */
734 if (sscanf((const char *)data.dptr, "UID %lu", &rec_id) == 1) { /* Try a UID record. */
735 map->xid.id = rec_id;
736 map->xid.type = ID_TYPE_UID;
737 DEBUG(10,("Found uid record %s -> %s \n", keystr, (const char *)data.dptr ));
740 } else if (sscanf((const char *)data.dptr, "GID %lu", &rec_id) == 1) { /* Try a GID record. */
741 map->xid.id = rec_id;
742 map->xid.type = ID_TYPE_GID;
743 DEBUG(10,("Found gid record %s -> %s \n", keystr, (const char *)data.dptr ));
746 } else { /* Unknown record type ! */
747 DEBUG(2, ("Found INVALID record %s -> %s\n", keystr, (const char *)data.dptr));
748 ret = NT_STATUS_INTERNAL_DB_ERROR;
751 /* apply filters before returning result */
752 if ((ctx->filter_low_id && (map->xid.id < ctx->filter_low_id)) ||
753 (ctx->filter_high_id && (map->xid.id > ctx->filter_high_id))) {
754 DEBUG(5, ("Requested id (%u) out of range (%u - %u). Filtered!\n",
755 map->xid.id, ctx->filter_low_id, ctx->filter_high_id));
756 ret = NT_STATUS_NONE_MAPPED;
760 talloc_free(tmp_ctx);
765 lookup a set of unix ids.
767 static NTSTATUS idmap_tdb2_unixids_to_sids(struct idmap_domain *dom, struct id_map **ids)
769 struct idmap_tdb2_context *ctx;
773 /* initialize the status to avoid suprise */
774 for (i = 0; ids[i]; i++) {
775 ids[i]->status = ID_UNKNOWN;
778 ctx = talloc_get_type(dom->private_data, struct idmap_tdb2_context);
780 for (i = 0; ids[i]; i++) {
781 ret = idmap_tdb2_id_to_sid(ctx, ids[i]);
782 if ( ! NT_STATUS_IS_OK(ret)) {
784 /* if it is just a failed mapping continue */
785 if (NT_STATUS_EQUAL(ret, NT_STATUS_NONE_MAPPED)) {
787 /* make sure it is marked as unmapped */
788 ids[i]->status = ID_UNMAPPED;
792 /* some fatal error occurred, return immediately */
796 /* all ok, id is mapped */
797 ids[i]->status = ID_MAPPED;
807 lookup a set of sids.
809 static NTSTATUS idmap_tdb2_sids_to_unixids(struct idmap_domain *dom, struct id_map **ids)
811 struct idmap_tdb2_context *ctx;
815 /* initialize the status to avoid suprise */
816 for (i = 0; ids[i]; i++) {
817 ids[i]->status = ID_UNKNOWN;
820 ctx = talloc_get_type(dom->private_data, struct idmap_tdb2_context);
822 for (i = 0; ids[i]; i++) {
823 ret = idmap_tdb2_sid_to_id(ctx, ids[i]);
824 if ( ! NT_STATUS_IS_OK(ret)) {
826 /* if it is just a failed mapping continue */
827 if (NT_STATUS_EQUAL(ret, NT_STATUS_NONE_MAPPED)) {
829 /* make sure it is marked as unmapped */
830 ids[i]->status = ID_UNMAPPED;
834 /* some fatal error occurred, return immediately */
838 /* all ok, id is mapped */
839 ids[i]->status = ID_MAPPED;
853 static NTSTATUS idmap_tdb2_set_mapping(struct idmap_domain *dom, const struct id_map *map)
855 struct idmap_tdb2_context *ctx;
857 char *ksidstr, *kidstr;
858 struct idmap_tdb2_set_mapping_context state;
860 if (!map || !map->sid) {
861 return NT_STATUS_INVALID_PARAMETER;
864 ksidstr = kidstr = NULL;
866 /* TODO: should we filter a set_mapping using low/high filters ? */
868 ctx = talloc_get_type(dom->private_data, struct idmap_tdb2_context);
870 switch (map->xid.type) {
873 kidstr = talloc_asprintf(ctx, "UID %lu", (unsigned long)map->xid.id);
877 kidstr = talloc_asprintf(ctx, "GID %lu", (unsigned long)map->xid.id);
881 DEBUG(2, ("INVALID unix ID type: 0x02%x\n", map->xid.type));
882 return NT_STATUS_INVALID_PARAMETER;
885 if (kidstr == NULL) {
886 DEBUG(0, ("ERROR: Out of memory!\n"));
887 ret = NT_STATUS_NO_MEMORY;
891 if (!(ksidstr = sid_string_talloc(ctx, map->sid))) {
892 DEBUG(0, ("Out of memory!\n"));
893 ret = NT_STATUS_NO_MEMORY;
897 state.ksidstr = ksidstr;
898 state.kidstr = kidstr;
900 ret = dbwrap_trans_do(idmap_tdb2, idmap_tdb2_set_mapping_action,
904 talloc_free(ksidstr);
912 static NTSTATUS idmap_tdb2_remove_mapping(struct idmap_domain *dom, const struct id_map *map)
914 /* not supported as it would invalidate the cache tdb on other
916 DEBUG(0,("idmap_tdb2_remove_mapping not supported\n"));
917 return NT_STATUS_NOT_SUPPORTED;
921 Close the idmap tdb instance
923 static NTSTATUS idmap_tdb2_close(struct idmap_domain *dom)
925 /* don't do anything */
931 Dump all mappings out
933 static NTSTATUS idmap_tdb2_dump_data(struct idmap_domain *dom, struct id_map **maps, int *num_maps)
935 DEBUG(0,("idmap_tdb2_dump_data not supported\n"));
936 return NT_STATUS_NOT_SUPPORTED;
939 static struct idmap_methods db_methods = {
940 .init = idmap_tdb2_db_init,
941 .unixids_to_sids = idmap_tdb2_unixids_to_sids,
942 .sids_to_unixids = idmap_tdb2_sids_to_unixids,
943 .set_mapping = idmap_tdb2_set_mapping,
944 .remove_mapping = idmap_tdb2_remove_mapping,
945 .dump_data = idmap_tdb2_dump_data,
946 .close_fn = idmap_tdb2_close
949 static struct idmap_alloc_methods db_alloc_methods = {
950 .init = idmap_tdb2_alloc_init,
951 .allocate_id = idmap_tdb2_allocate_id,
952 .get_id_hwm = idmap_tdb2_get_hwm,
953 .set_id_hwm = idmap_tdb2_set_hwm,
954 .close_fn = idmap_tdb2_alloc_close
957 NTSTATUS idmap_tdb2_init(void)
961 /* register both backends */
962 ret = smb_register_idmap_alloc(SMB_IDMAP_INTERFACE_VERSION, "tdb2", &db_alloc_methods);
963 if (! NT_STATUS_IS_OK(ret)) {
964 DEBUG(0, ("Unable to register idmap alloc tdb2 module: %s\n", get_friendly_nt_error_msg(ret)));
968 return smb_register_idmap(SMB_IDMAP_INTERFACE_VERSION, "tdb2", &db_methods);