summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2013-04-25 20:12:39 +0200
committerChristian Ambach <ambi@samba.org>2013-05-06 16:33:39 +0200
commit7b9a567b8943e0c3d0b6fa97bea72f1b89aea4ab (patch)
tree7fdf14ae5cb0df723a4eca854e09c0d2744859b9
parent30a27ba428f346ff2fd56f9727ce0f1fb18a5a41 (diff)
downloadsamba-7b9a567b8943e0c3d0b6fa97bea72f1b89aea4ab.tar.gz
samba-7b9a567b8943e0c3d0b6fa97bea72f1b89aea4ab.tar.bz2
samba-7b9a567b8943e0c3d0b6fa97bea72f1b89aea4ab.zip
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 <obnox@samba.org> Reviewed-by: Christian Ambach <ambi@samba.org>
-rw-r--r--source3/winbindd/idmap_autorid.c17
1 files changed, 9 insertions, 8 deletions
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