diff options
author | Atul Kulkarni <atul.kulkarni@in.ibm.com> | 2013-08-30 13:35:49 +0530 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2013-10-02 00:06:18 +0200 |
commit | 7cacc48563f6d16a74669bf572437b13f6f54250 (patch) | |
tree | 38e91279323a0a3cd6161a0d92762d0446f84b1e | |
parent | 65d7df105587fe14d057c3fa84c889f2c8c4500e (diff) | |
download | samba-7cacc48563f6d16a74669bf572437b13f6f54250.tar.gz samba-7cacc48563f6d16a74669bf572437b13f6f54250.tar.bz2 samba-7cacc48563f6d16a74669bf572437b13f6f54250.zip |
idmap_autorid: remove autorid_global_config member from autorid_range_config
global config is not part of range config.
By removing this, autorid_range_config becomes more suitable
for using it 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>
-rw-r--r-- | source3/include/idmap_autorid_tdb.h | 1 | ||||
-rw-r--r-- | source3/winbindd/idmap_autorid.c | 11 | ||||
-rw-r--r-- | source3/winbindd/idmap_autorid_tdb.c | 20 |
3 files changed, 17 insertions, 15 deletions
diff --git a/source3/include/idmap_autorid_tdb.h b/source3/include/idmap_autorid_tdb.h index e385f493b6..f4286f0315 100644 --- a/source3/include/idmap_autorid_tdb.h +++ b/source3/include/idmap_autorid_tdb.h @@ -50,7 +50,6 @@ struct autorid_range_config { uint32_t rangenum; uint32_t domain_range_index; uint32_t low_id; - struct autorid_global_config *globalcfg; }; NTSTATUS idmap_autorid_get_domainrange(struct db_context *db, 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; } |