summaryrefslogtreecommitdiff
path: root/source3/winbindd
diff options
context:
space:
mode:
authorAtul Kulkarni <atul.kulkarni@in.ibm.com>2013-08-30 13:29:01 +0200
committerVolker Lendecke <vl@samba.org>2013-10-01 11:23:52 +0000
commit954d9fbd45dd37cf99fa65c0ffc7ef2f43b353ca (patch)
tree9bb778683a70f879234fee13b012ba36be34a771 /source3/winbindd
parent105475c77e8a721476010a1cf9be8998cebd48bb (diff)
downloadsamba-954d9fbd45dd37cf99fa65c0ffc7ef2f43b353ca.tar.gz
samba-954d9fbd45dd37cf99fa65c0ffc7ef2f43b353ca.tar.bz2
samba-954d9fbd45dd37cf99fa65c0ffc7ef2f43b353ca.zip
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 <obnox@samba.org> Signed-off-by: Atul Kulkarni <atul.kulkarni@in.ibm.com> Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source3/winbindd')
-rw-r--r--source3/winbindd/idmap_autorid.c26
1 files changed, 14 insertions, 12 deletions
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;
}