summaryrefslogtreecommitdiffstats
path: root/source3/winbindd
diff options
context:
space:
mode:
authorAtul Kulkarni <atul.kulkarni@in.ibm.com>2013-08-30 16:18:39 +0530
committerMichael Adam <obnox@samba.org>2013-10-02 00:06:21 +0200
commit7d2fdaac6e9b04c0d738b6f682d384149ae0d165 (patch)
tree483826e99c7478059a26c82e41d8f4fed093813f /source3/winbindd
parent94ca5dc0bd99999921fb0dfb05e4f3d90e7a85b5 (diff)
downloadsamba-7d2fdaac6e9b04c0d738b6f682d384149ae0d165.tar.gz
samba-7d2fdaac6e9b04c0d738b6f682d384149ae0d165.tar.xz
samba-7d2fdaac6e9b04c0d738b6f682d384149ae0d165.zip
idmap_autorid: factor out domain range fetching part from idmap_autorid_get_domainrange()
Fatored out read-only function idmap_autorid_getrange() will be used elsewhere. 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_tdb.c58
1 files changed, 38 insertions, 20 deletions
diff --git a/source3/winbindd/idmap_autorid_tdb.c b/source3/winbindd/idmap_autorid_tdb.c
index 07020ba09f..2126a67e1b 100644
--- a/source3/winbindd/idmap_autorid_tdb.c
+++ b/source3/winbindd/idmap_autorid_tdb.c
@@ -128,6 +128,9 @@ static NTSTATUS idmap_autorid_get_domainrange_action(struct db_context *db,
range->rangenum = rangenum;
+ range->low_id = globalcfg->minvalue
+ + range->rangenum * globalcfg->rangesize;
+
return NT_STATUS_OK;
error:
@@ -135,25 +138,48 @@ error:
}
-NTSTATUS idmap_autorid_get_domainrange(struct db_context *db,
- struct autorid_range_config *range,
- bool read_only)
+static NTSTATUS idmap_autorid_getrange_int(struct db_context *db,
+ struct autorid_range_config *range)
{
- NTSTATUS ret;
- struct autorid_global_config *globalcfg;
+ NTSTATUS status = NT_STATUS_INVALID_PARAMETER;
+ struct autorid_global_config *globalcfg = NULL;
fstring keystr;
- /*
- * try to find mapping without locking the database,
- * if it is not found create a mapping in a transaction unless
- * read-only mode has been set
- */
+ if (db == NULL || range == NULL) {
+ DEBUG(3, ("Invalid arguments received\n"));
+ goto done;
+ }
+
idmap_autorid_build_keystr(range->domsid, range->domain_range_index,
keystr);
- ret = dbwrap_fetch_uint32_bystring(db, keystr,
- &(range->rangenum));
+ DEBUG(10, ("reading domain range for key %s\n", keystr));
+ status = dbwrap_fetch_uint32_bystring(db, keystr, &(range->rangenum));
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("Failed to read database for key %s\n", keystr));
+ goto done;
+ }
+
+ status = idmap_autorid_loadconfig(db, talloc_tos(), &globalcfg);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("Failed to read global configuration"));
+ goto done;
+ }
+ range->low_id = globalcfg->minvalue
+ + range->rangenum * globalcfg->rangesize;
+
+ TALLOC_FREE(globalcfg);
+done:
+ return status;
+}
+
+NTSTATUS idmap_autorid_get_domainrange(struct db_context *db,
+ struct autorid_range_config *range,
+ bool read_only)
+{
+ NTSTATUS ret;
+ ret = idmap_autorid_getrange_int(db, range);
if (!NT_STATUS_IS_OK(ret)) {
if (read_only) {
return NT_STATUS_NOT_FOUND;
@@ -162,19 +188,11 @@ NTSTATUS idmap_autorid_get_domainrange(struct db_context *db,
idmap_autorid_get_domainrange_action, range);
}
- ret = idmap_autorid_loadconfig(db, talloc_tos(), &globalcfg);
- if (!NT_STATUS_IS_OK(ret)) {
- return ret;
- }
- range->low_id = globalcfg->minvalue
- + range->rangenum * globalcfg->rangesize;
-
DEBUG(10, ("Using range #%d for domain %s "
"(domain_range_index=%"PRIu32", low_id=%"PRIu32")\n",
range->rangenum, range->domsid, range->domain_range_index,
range->low_id));
- TALLOC_FREE(globalcfg);
return ret;
}