From 7b9a567b8943e0c3d0b6fa97bea72f1b89aea4ab Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 25 Apr 2013 20:12:39 +0200 Subject: s3:idmap:autorid: calculate the range's low_id in idmap_autorid_get_domainrange() This way, the calculation needs to be don only in one central place and the formulas get simpler. Signed-off-by: Michael Adam Reviewed-by: Christian Ambach --- source3/winbindd/idmap_autorid.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'source3') diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c index d0a7b675e3..32d5860ae6 100644 --- a/source3/winbindd/idmap_autorid.c +++ b/source3/winbindd/idmap_autorid.c @@ -54,6 +54,7 @@ struct autorid_range_config { fstring keystr; uint32_t rangenum; uint32_t domain_range_index; + uint32_t low_id; struct autorid_global_config *globalcfg; }; @@ -170,9 +171,13 @@ static NTSTATUS idmap_autorid_get_domainrange(struct autorid_range_config *range idmap_autorid_get_domainrange_action, range); } + range->low_id = range->globalcfg->minvalue + + range->rangenum * range->globalcfg->rangesize; + DEBUG(10, ("Using range #%d for domain %s " - "(domain_range_index=%"PRIu32")\n", - range->rangenum, range->domsid, range->domain_range_index)); + "(domain_range_index=%"PRIu32", low_id=%"PRIu32")\n", + range->rangenum, range->domsid, range->domain_range_index, + range->low_id)); return ret; } @@ -220,9 +225,7 @@ static NTSTATUS idmap_autorid_allocate_id(struct idmap_domain *dom, return ret; } - xid->id = globalcfg->minvalue + - globalcfg->rangesize * range.rangenum + - xid->id; + xid->id = xid->id + range.low_id; DEBUG(10, ("Returned new %s %d from allocation range\n", (xid->type==ID_TYPE_UID)?"uid":"gid", xid->id)); @@ -352,14 +355,12 @@ static NTSTATUS idmap_autorid_sid_to_id(struct autorid_global_config *global, { uint32_t rid; uint32_t reduced_rid; - uint32_t range_start; sid_peek_rid(map->sid, &rid); reduced_rid = rid % global->rangesize; - range_start = global->minvalue + range->rangenum * global->rangesize; - map->xid.id = reduced_rid + range_start; + map->xid.id = reduced_rid + range->low_id; map->xid.type = ID_TYPE_BOTH; /* We **really** should have some way of validating -- cgit