summaryrefslogtreecommitdiff
path: root/source3/winbindd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/winbindd')
-rw-r--r--source3/winbindd/idmap_autorid.c11
-rw-r--r--source3/winbindd/idmap_autorid_tdb.c20
2 files changed, 17 insertions, 14 deletions
diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c
index fb0985b9dd..fa16c1383a 100644
--- a/source3/winbindd/idmap_autorid.c
+++ b/source3/winbindd/idmap_autorid.c
@@ -91,17 +91,8 @@ static NTSTATUS idmap_autorid_allocate_id(struct idmap_domain *dom,
struct unixid *xid) {
NTSTATUS ret;
- struct idmap_tdb_common_context *commoncfg;
- struct autorid_global_config *globalcfg;
struct autorid_range_config range;
- commoncfg =
- talloc_get_type_abort(dom->private_data,
- struct idmap_tdb_common_context);
-
- globalcfg = talloc_get_type(commoncfg->private_data,
- struct autorid_global_config);
-
if (dom->read_only) {
DEBUG(3, ("Backend is read-only, refusing "
"new allocation request\n"));
@@ -112,7 +103,6 @@ static NTSTATUS idmap_autorid_allocate_id(struct idmap_domain *dom,
ZERO_STRUCT(range);
- range.globalcfg = globalcfg;
fstrcpy(range.domsid, ALLOC_RANGE);
ret = idmap_autorid_get_domainrange(autorid_db, &range, dom->read_only);
@@ -492,7 +482,6 @@ static NTSTATUS idmap_autorid_sids_to_unixids(struct idmap_domain *dom,
}
TALLOC_FREE(domain);
- range.globalcfg = global;
sid_to_fstring(range.domsid, &domainsid);
/* Calculate domain_range_index for multi-range support */
diff --git a/source3/winbindd/idmap_autorid_tdb.c b/source3/winbindd/idmap_autorid_tdb.c
index 95fb048095..daeb1c3758 100644
--- a/source3/winbindd/idmap_autorid_tdb.c
+++ b/source3/winbindd/idmap_autorid_tdb.c
@@ -32,6 +32,7 @@ static NTSTATUS idmap_autorid_get_domainrange_action(struct db_context *db,
uint32_t rangenum, hwm;
char *numstr;
struct autorid_range_config *range;
+ struct autorid_global_config *globalcfg;
range = (struct autorid_range_config *)private_data;
@@ -56,12 +57,19 @@ static NTSTATUS idmap_autorid_get_domainrange_action(struct db_context *db,
goto error;
}
+ ret = idmap_autorid_loadconfig(db, talloc_tos(), &globalcfg);
+ if (!NT_STATUS_IS_OK(ret)) {
+ return ret;
+ }
+
/* do we have a range left? */
- if (hwm >= range->globalcfg->maxranges) {
+ if (hwm >= globalcfg->maxranges) {
DEBUG(1, ("No more domain ranges available!\n"));
+ talloc_free(globalcfg);
ret = NT_STATUS_NO_MEMORY;
goto error;
}
+ TALLOC_FREE(globalcfg);
/* increase the HWM */
ret = dbwrap_change_uint32_atomic_bystring(db, HWM, &rangenum, 1);
@@ -112,6 +120,7 @@ NTSTATUS idmap_autorid_get_domainrange(struct db_context *db,
bool read_only)
{
NTSTATUS ret;
+ struct autorid_global_config *globalcfg;
/*
* try to find mapping without locking the database,
@@ -136,14 +145,19 @@ NTSTATUS idmap_autorid_get_domainrange(struct db_context *db,
idmap_autorid_get_domainrange_action, range);
}
- range->low_id = range->globalcfg->minvalue
- + range->rangenum * range->globalcfg->rangesize;
+ 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;
}