From 954d9fbd45dd37cf99fa65c0ffc7ef2f43b353ca Mon Sep 17 00:00:00 2001 From: Atul Kulkarni Date: Fri, 30 Aug 2013 13:29:01 +0200 Subject: idmap_autorid: add path, and db parameters to idmap_autorid_db_init() In preparation of calling this from net for different dbs. Pair-Programmed-With: Michael Adam Signed-off-by: Atul Kulkarni Signed-off-by: Michael Adam Reviewed-by: Volker Lendecke --- source3/winbindd/idmap_autorid.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'source3/winbindd') diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c index 62beb1d669..b3cd8f3f05 100644 --- a/source3/winbindd/idmap_autorid.c +++ b/source3/winbindd/idmap_autorid.c @@ -718,35 +718,35 @@ static NTSTATUS idmap_autorid_init_hwm(struct db_context *db, const char *hwm) /* * open and initialize the database which stores the ranges for the domains */ -static NTSTATUS idmap_autorid_db_init(void) +static NTSTATUS idmap_autorid_db_init(const char *path, + TALLOC_CTX *mem_ctx, + struct db_context **db) { NTSTATUS status; - if (autorid_db) { + if (*db != NULL) { /* its already open */ return NT_STATUS_OK; } /* Open idmap repository */ - autorid_db = db_open(NULL, state_path("autorid.tdb"), 0, - TDB_DEFAULT, O_RDWR | O_CREAT, 0644, - DBWRAP_LOCK_ORDER_1); + *db = db_open(mem_ctx, path, 0, TDB_DEFAULT, O_RDWR | O_CREAT, 0644, + DBWRAP_LOCK_ORDER_1); - if (!autorid_db) { - DEBUG(0, ("Unable to open idmap_autorid database '%s'\n", - state_path("autorid.tdb"))); + if (*db == NULL) { + DEBUG(0, ("Unable to open idmap_autorid database '%s'\n", path)); return NT_STATUS_UNSUCCESSFUL; } /* Initialize high water mark for the currently used range to 0 */ - status = idmap_autorid_init_hwm(autorid_db, HWM); + status = idmap_autorid_init_hwm(*db, HWM); NT_STATUS_NOT_OK_RETURN(status); - status = idmap_autorid_init_hwm(autorid_db, ALLOC_HWM_UID); + status = idmap_autorid_init_hwm(*db, ALLOC_HWM_UID); NT_STATUS_NOT_OK_RETURN(status); - status = idmap_autorid_init_hwm(autorid_db, ALLOC_HWM_GID); + status = idmap_autorid_init_hwm(*db, ALLOC_HWM_GID); return status; } @@ -899,7 +899,9 @@ static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom) return NT_STATUS_NO_MEMORY; } - status = idmap_autorid_db_init(); + status = idmap_autorid_db_init(state_path("autorid.tdb"), + NULL, /* TALLOC_CTX */ + &autorid_db); if (!NT_STATUS_IS_OK(status)) { goto error; } -- cgit