From 1d8d3fd7c3c2e6c46a3e01983dc26a5a650f6f84 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 27 Aug 2009 14:55:41 +0200 Subject: s3:winbind: Convert WINBINDD_GETUSERSIDS to the new API --- source3/winbindd/winbindd_async.c | 165 -------------------------------------- 1 file changed, 165 deletions(-) (limited to 'source3/winbindd/winbindd_async.c') diff --git a/source3/winbindd/winbindd_async.c b/source3/winbindd/winbindd_async.c index 58080a8800..d16a1f8288 100644 --- a/source3/winbindd/winbindd_async.c +++ b/source3/winbindd/winbindd_async.c @@ -824,171 +824,6 @@ void winbindd_getsidaliases_async(struct winbindd_domain *domain, (void *)cont, private_data); } -struct gettoken_state { - TALLOC_CTX *mem_ctx; - DOM_SID user_sid; - struct winbindd_domain *alias_domain; - struct winbindd_domain *local_alias_domain; - struct winbindd_domain *builtin_domain; - DOM_SID *sids; - size_t num_sids; - void (*cont)(void *private_data, bool success, DOM_SID *sids, size_t num_sids); - void *private_data; -}; - -static void gettoken_recvdomgroups(TALLOC_CTX *mem_ctx, bool success, - struct winbindd_response *response, - void *c, void *private_data); -static void gettoken_recvaliases(void *private_data, bool success, - const DOM_SID *aliases, - size_t num_aliases); - - -void winbindd_gettoken_async(TALLOC_CTX *mem_ctx, const DOM_SID *user_sid, - void (*cont)(void *private_data, bool success, - DOM_SID *sids, size_t num_sids), - void *private_data) -{ - struct winbindd_domain *domain; - struct winbindd_request request; - struct gettoken_state *state; - - state = TALLOC_ZERO_P(mem_ctx, struct gettoken_state); - if (state == NULL) { - DEBUG(0, ("talloc failed\n")); - cont(private_data, False, NULL, 0); - return; - } - - state->mem_ctx = mem_ctx; - sid_copy(&state->user_sid, user_sid); - state->alias_domain = find_our_domain(); - state->local_alias_domain = find_domain_from_name( get_global_sam_name() ); - state->builtin_domain = find_builtin_domain(); - state->cont = cont; - state->private_data = private_data; - - domain = find_domain_from_sid_noinit(user_sid); - if (domain == NULL) { - DEBUG(5, ("Could not find domain from SID %s\n", - sid_string_dbg(user_sid))); - cont(private_data, False, NULL, 0); - return; - } - - ZERO_STRUCT(request); - request.cmd = WINBINDD_GETUSERDOMGROUPS; - sid_to_fstring(request.data.sid, user_sid); - - do_async_domain(mem_ctx, domain, &request, gettoken_recvdomgroups, - NULL, state); -} - -static void gettoken_recvdomgroups(TALLOC_CTX *mem_ctx, bool success, - struct winbindd_response *response, - void *c, void *private_data) -{ - struct gettoken_state *state = - talloc_get_type_abort(private_data, struct gettoken_state); - char *sids_str; - - if (!success) { - DEBUG(10, ("Could not get domain groups\n")); - state->cont(state->private_data, False, NULL, 0); - return; - } - - sids_str = (char *)response->extra_data.data; - - if (sids_str == NULL) { - /* This could be normal if we are dealing with a - local user and local groups */ - - if ( !sid_check_is_in_our_domain( &state->user_sid ) ) { - DEBUG(10, ("Received no domain groups\n")); - state->cont(state->private_data, True, NULL, 0); - return; - } - } - - state->sids = NULL; - state->num_sids = 0; - - if (!NT_STATUS_IS_OK(add_sid_to_array(mem_ctx, &state->user_sid, - &state->sids, &state->num_sids))) - { - DEBUG(0, ("Out of memory\n")); - state->cont(state->private_data, False, NULL, 0); - return; - } - - if (sids_str && !parse_sidlist(mem_ctx, sids_str, &state->sids, - &state->num_sids)) { - DEBUG(0, ("Could not parse sids\n")); - state->cont(state->private_data, False, NULL, 0); - return; - } - - if (state->alias_domain == NULL) { - DEBUG(10, ("Don't expand domain local groups\n")); - state->cont(state->private_data, True, state->sids, - state->num_sids); - return; - } - - winbindd_getsidaliases_async(state->alias_domain, mem_ctx, - state->sids, state->num_sids, - gettoken_recvaliases, state); -} - -static void gettoken_recvaliases(void *private_data, bool success, - const DOM_SID *aliases, - size_t num_aliases) -{ - struct gettoken_state *state = (struct gettoken_state *)private_data; - size_t i; - - if (!success) { - DEBUG(10, ("Could not receive domain local groups\n")); - state->cont(state->private_data, False, NULL, 0); - return; - } - - for (i=0; imem_ctx, - &aliases[i], - &state->sids, - &state->num_sids))) - { - DEBUG(0, ("Out of memory\n")); - state->cont(state->private_data, False, NULL, 0); - return; - } - } - - if (state->local_alias_domain != NULL) { - struct winbindd_domain *local_domain = state->local_alias_domain; - DEBUG(10, ("Expanding our own local groups\n")); - state->local_alias_domain = NULL; - winbindd_getsidaliases_async(local_domain, state->mem_ctx, - state->sids, state->num_sids, - gettoken_recvaliases, state); - return; - } - - if (state->builtin_domain != NULL) { - struct winbindd_domain *builtin_domain = state->builtin_domain; - DEBUG(10, ("Expanding our own BUILTIN groups\n")); - state->builtin_domain = NULL; - winbindd_getsidaliases_async(builtin_domain, state->mem_ctx, - state->sids, state->num_sids, - gettoken_recvaliases, state); - return; - } - - state->cont(state->private_data, True, state->sids, state->num_sids); -} - static void query_user_recv(TALLOC_CTX *mem_ctx, bool success, struct winbindd_response *response, void *c, void *private_data) -- cgit