Lines Matching refs:state
190 static int ipa_netgr_process_all(struct ipa_get_netgroups_state *state);
204 struct ipa_get_netgroups_state *state;
207 req = tevent_req_create(memctx, &state, struct ipa_get_netgroups_state);
210 state->ev = ev;
211 state->opts = opts;
212 state->ipa_opts = ipa_options;
213 state->sh = sh;
214 state->sysdb = sysdb;
215 state->attrs = attrs;
216 state->timeout = timeout;
217 state->base_filter = filter;
218 state->netgr_base_iter = 0;
219 state->dom = dom;
228 ret = sss_hash_create(state, 32, &state->new_netgroups);
230 ret = sss_hash_create(state, 32, &state->new_users);
232 ret = sss_hash_create(state, 32, &state->new_hosts);
250 struct ipa_get_netgroups_state *state;
253 state = tevent_req_data(req, struct ipa_get_netgroups_state);
254 netgr_bases = state->ipa_opts->id->sdom->netgroup_search_bases;
256 talloc_zfree(state->filter);
257 state->filter = sdap_combine_filters(
258 state,
259 state->base_filter,
260 netgr_bases[state->netgr_base_iter]->filter);
261 if (!state->filter) {
267 netgr_bases[state->netgr_base_iter]->basedn);
270 state, state->ev, state->opts, state->sh,
271 netgr_bases[state->netgr_base_iter]->basedn,
272 netgr_bases[state->netgr_base_iter]->scope,
273 state->filter, state->attrs,
274 state->opts->netgroup_map, IPA_OPTS_NETGROUP,
275 state->timeout,
285 static int ipa_netgr_fetch_netgroups(struct ipa_get_netgroups_state *state,
287 static int ipa_netgr_fetch_users(struct ipa_get_netgroups_state *state,
289 static int ipa_netgr_fetch_hosts(struct ipa_get_netgroups_state *state,
297 struct ipa_get_netgroups_state *state = tevent_req_data(req,
311 netgr_bases = state->ipa_opts->id->sdom->netgroup_search_bases;
313 ret = sdap_get_generic_recv(subreq, state, &netgroups_count, &netgroups);
324 state->netgr_base_iter++;
325 if (netgr_bases[state->netgr_base_iter]) {
338 filter = talloc_strdup(state, "(|");
348 if (el->num_values) state->entities_found |= ENTITY_NG;
353 if (el->num_values) state->entities_found |= ENTITY_USER;
358 if (el->num_values) state->entities_found |= ENTITY_HOST;
369 ret = hash_enter(state->new_netgroups, &key, &value);
375 if (state->entities_found == 0) {
379 ret = sss_filter_sanitize(state, orig_dn, &dn);
385 state->opts->netgroup_map[IPA_AT_NETGROUP_MEMBER_OF].name,
395 ret = ipa_netgr_process_all(state);
404 state->filter = talloc_asprintf_append(filter, ")");
405 if (state->filter == NULL) {
410 if (state->entities_found & ENTITY_NG) {
411 state->netgr_base_iter = 0;
412 ret = ipa_netgr_fetch_netgroups(state, req);
414 } else if (state->entities_found & ENTITY_USER) {
415 ret = ipa_netgr_fetch_users(state, req);
417 } else if (state->entities_found & ENTITY_HOST) {
418 ret = ipa_netgr_fetch_hosts(state, req);
428 static int ipa_netgr_fetch_netgroups(struct ipa_get_netgroups_state *state,
436 bases = state->ipa_opts->id->sdom->netgroup_search_bases;
437 if (bases[state->netgr_base_iter] == NULL) {
441 base_filter = bases[state->netgr_base_iter]->filter;
443 filter = talloc_asprintf(state, "(&%s%s(objectclass=%s))",
444 state->filter,
446 state->opts->netgroup_map[SDAP_OC_NETGROUP].name);
450 subreq = sdap_get_generic_send(state, state->ev, state->opts, state->sh,
451 bases[state->netgr_base_iter]->basedn,
452 bases[state->netgr_base_iter]->scope,
453 filter, state->attrs, state->opts->netgroup_map,
454 IPA_OPTS_NETGROUP, state->timeout, true);
456 state->current_entity = ENTITY_NG;
466 static int ipa_netgr_fetch_users(struct ipa_get_netgroups_state *state,
469 const char *attrs[] = { state->opts->user_map[SDAP_AT_USER_NAME].name,
470 state->opts->user_map[SDAP_AT_USER_MEMBEROF].name,
477 bases = state->ipa_opts->id->sdom->user_search_bases;
478 if (bases[state->user_base_iter] == NULL) {
481 base_filter = bases[state->user_base_iter]->filter;
483 filter = talloc_asprintf(state, "(&%s%s(objectclass=%s))",
484 state->filter,
486 state->opts->user_map[SDAP_OC_USER].name);
490 subreq = sdap_get_generic_send(state, state->ev, state->opts, state->sh,
491 dp_opt_get_string(state->opts->basic,
494 filter, attrs, state->opts->user_map,
495 state->opts->user_map_cnt,
496 state->timeout, true);
498 state->current_entity = ENTITY_USER;
509 static int ipa_netgr_fetch_hosts(struct ipa_get_netgroups_state *state,
519 bases = state->ipa_opts->host_search_bases;
520 if (bases[state->host_base_iter] == NULL) {
523 base_filter = bases[state->host_base_iter]->filter;
525 filter = talloc_asprintf(state, "(&%s%s(objectclass=%s))",
526 state->filter,
528 state->ipa_opts->host_map[IPA_OC_HOST].name);
532 ret = build_attrs_from_map(state, state->ipa_opts->host_map,
539 subreq = sdap_get_generic_send(state, state->ev, state->opts, state->sh,
540 bases[state->host_base_iter]->basedn,
541 bases[state->host_base_iter]->scope,
542 filter, attrs, state->ipa_opts->host_map,
543 IPA_OPTS_HOST, state->timeout, true);
545 state->current_entity = ENTITY_HOST;
560 struct ipa_get_netgroups_state *state = tevent_req_data(req,
573 ret = sdap_get_generic_recv(subreq, state, &count, &entities);
590 if (state->current_entity == ENTITY_NG) {
592 state->netgr_base_iter++;
593 ret = ipa_netgr_fetch_netgroups(state, req);
594 table = state->new_netgroups;
600 } else if (state->current_entity == ENTITY_USER) {
602 state->user_base_iter++;
603 ret = ipa_netgr_fetch_users(state, req);
604 table = state->new_users;
605 if (state->entities_found & ENTITY_HOST ||
606 state->entities_found & ENTITY_NG) {
609 } else if (state->current_entity == ENTITY_HOST) {
611 state->host_base_iter++;
612 ret = ipa_netgr_fetch_hosts(state, req);
613 table = state->new_hosts;
617 state->current_entity);
662 ret = next_call(state, req);
666 ret = ipa_netgr_process_all(state);
681 struct ipa_get_netgroups_state *state;
682 state = talloc_get_type(pvt, struct ipa_get_netgroups_state);
684 state->netgroups[state->netgroups_count] = talloc_get_type(entry->value.ptr,
686 state->netgroups_count++;
702 struct extract_state *state;
707 state = talloc_get_type(pvt, struct extract_state);
710 ret = sysdb_attrs_get_el(member, state->appropriateMemberOf, &el);
721 if (strcmp((char *)el->values[j].data, state->group) == 0) {
722 state->entries = talloc_realloc(state, state->entries,
724 state->entries_count + 1);
725 if (state->entries == NULL) {
729 state->entries[state->entries_count] = (char *)name_el->values[0].data;
730 state->entries_count++;
746 struct extract_state *state;
760 state = talloc_zero(mem_ctx, struct extract_state);
761 if (state == NULL) {
766 state->appropriateMemberOf = appropriateMemberOf;
806 state->group = process[pi];
807 hash_iterate(lookup_table, extract_entities, state);
808 if (state->entries_count > 0) {
810 ret_count + state->entries_count);
815 memcpy(&ret_array[ret_count], state->entries,
816 state->entries_count*sizeof(const char *));
817 ret_count += state->entries_count;
819 state->entries_count = 0;
820 talloc_zfree(state->entries);
835 static int ipa_netgr_process_all(struct ipa_get_netgroups_state *state)
853 state->netgroups = talloc_zero_array(state, struct sysdb_attrs *,
854 hash_count(state->new_netgroups));
855 if (state->netgroups == NULL) {
859 extract_state = talloc_zero(state, struct extract_state);
868 hash_iterate(state->new_netgroups, extract_netgroups, state);
869 for (i = 0; i < state->netgroups_count; i++) {
872 ret = sysdb_attrs_get_string_array(state->netgroups[i],
874 state, &members);
883 ret = hash_lookup(state->new_netgroups, &key, &value);
895 ret = sysdb_attrs_add_string(state->netgroups[i],
908 ret = extract_members(state, state->netgroups[i],
910 state->ipa_opts->id->user_map[SDAP_AT_USER_MEMBEROF].sys_name,
911 state->new_users,
919 ret = extract_members(state, state->netgroups[i],
921 state->ipa_opts->host_map[IPA_AT_HOST_MEMBER_OF].sys_name,
922 state->new_hosts,
929 ret = sysdb_attrs_get_el(state->netgroups[i],
937 hosts = talloc_realloc(state, hosts, const char *,
954 ret = sysdb_attrs_get_string(state->netgroups[i], SYSDB_NETGROUP_DOMAIN,
975 triple = talloc_asprintf(state, "(%s,%s,%s)",
983 ret = sysdb_attrs_add_string(state->netgroups[i],
993 ret = ipa_save_netgroup(state, state->dom,
994 state->opts, state->netgroups[i]);
1010 struct ipa_get_netgroups_state *state = tevent_req_data(req,
1016 *reply_count = state->netgroups_count;
1020 *reply = talloc_steal(mem_ctx, state->netgroups);