summaryrefslogtreecommitdiff
path: root/source3/nsswitch/idmap_rid.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2007-01-22 16:54:02 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:17:21 -0500
commit37cc3e3d62a5bfad80a666839b8b0b78472ac11d (patch)
treec9b4b005cc340e566a6568db8a6fec89cbb14a76 /source3/nsswitch/idmap_rid.c
parent0de21e951544b5ee85b074427bda30fff3a1c9f4 (diff)
downloadsamba-37cc3e3d62a5bfad80a666839b8b0b78472ac11d.tar.gz
samba-37cc3e3d62a5bfad80a666839b8b0b78472ac11d.tar.bz2
samba-37cc3e3d62a5bfad80a666839b8b0b78472ac11d.zip
r20951: Remove the DOM_SID field in the struct idmap_domain and bounce
domain SID lookups through the struct winbindd_domain *domain_list by searching by name. Refactor the order lookup when searching for the correct idmap_domain to a single function and remove the requirement that the default domain be listed first in the config file. I would still like to make the idmap_domain array a linked list and remove the existing code which makes use of indexes into the list. Basic testing with tdb pans out ok. (This used to be commit e6c300829ff08dd354f6e9460d396261681e4809)
Diffstat (limited to 'source3/nsswitch/idmap_rid.c')
-rw-r--r--source3/nsswitch/idmap_rid.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/source3/nsswitch/idmap_rid.c b/source3/nsswitch/idmap_rid.c
index 5949aa4ba5..298d6fed35 100644
--- a/source3/nsswitch/idmap_rid.c
+++ b/source3/nsswitch/idmap_rid.c
@@ -26,13 +26,17 @@
#define DBGC_CLASS DBGC_IDMAP
struct idmap_rid_context {
- DOM_SID dom_sid;
+ const char *domain_name;
uint32_t low_id;
uint32_t high_id;
uint32_t base_rid;
};
-/* compat params can't be used because of the completely different way we support multiple domains in the new idmap */
+/******************************************************************************
+ compat params can't be used because of the completely different way
+ we support multiple domains in the new idmap
+ *****************************************************************************/
+
static NTSTATUS idmap_rid_initialize(struct idmap_domain *dom, const char *compat_params)
{
NTSTATUS ret;
@@ -40,8 +44,7 @@ static NTSTATUS idmap_rid_initialize(struct idmap_domain *dom, const char *compa
char *config_option = NULL;
const char *range;
- ctx = talloc_zero(dom, struct idmap_rid_context);
- if ( ! ctx) {
+ if ( (ctx = talloc_zero(dom, struct idmap_rid_context)) == NULL ) {
DEBUG(0, ("Out of memory!\n"));
return NT_STATUS_NO_MEMORY;
}
@@ -54,23 +57,23 @@ static NTSTATUS idmap_rid_initialize(struct idmap_domain *dom, const char *compa
}
range = lp_parm_const_string(-1, config_option, "range", NULL);
- if (( ! range) ||
+ if ( !range ||
(sscanf(range, "%u - %u", &ctx->low_id, &ctx->high_id) != 2) ||
- (ctx->low_id > ctx->high_id)) {
+ (ctx->low_id > ctx->high_id))
+ {
ctx->low_id = 0;
ctx->high_id = 0;
}
- if (( ! ctx->low_id) || ( ! ctx->high_id)) {
+ if ( !ctx->low_id || !ctx->high_id ) {
DEBUG(1, ("ERROR: Invalid configuration, ID range missing\n"));
ret = NT_STATUS_UNSUCCESSFUL;
goto failed;
}
ctx->base_rid = lp_parm_int(-1, config_option, "base_rid", 0);
-
- sid_copy(&ctx->dom_sid, dom->sid);
-
+ ctx->domain_name = talloc_strdup( ctx, dom->name );
+
dom->private_data = ctx;
talloc_free(config_option);
@@ -86,6 +89,7 @@ static NTSTATUS idmap_rid_id_to_sid(TALLOC_CTX *memctx, struct idmap_rid_context
const char *domname, *name;
enum lsa_SidType sid_type;
BOOL ret;
+ struct winbindd_domain *domain;
/* apply filters before checking */
if ((map->xid.id < ctx->low_id) || (map->xid.id > ctx->high_id)) {
@@ -94,7 +98,11 @@ static NTSTATUS idmap_rid_id_to_sid(TALLOC_CTX *memctx, struct idmap_rid_context
return NT_STATUS_NONE_MAPPED;
}
- sid_compose(map->sid, &ctx->dom_sid, map->xid.id - ctx->low_id + ctx->base_rid);
+ if ( (domain = find_domain_from_name_noinit(ctx->domain_name)) == NULL ) {
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+
+ sid_compose(map->sid, &domain->sid, map->xid.id - ctx->low_id + ctx->base_rid);
/* by default calls to winbindd are disabled
the following call will not recurse so this is safe */