>From c57774fda0e13fc393a02abc173e1ef349e5a2c3 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Tue, 21 Jan 2014 23:40:17 +0100 Subject: [PATCH 5/7] LDAP: Don't clobber original_member during enumeration --- src/providers/ldap/sdap_async_groups.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/providers/ldap/sdap_async_groups.c b/src/providers/ldap/sdap_async_groups.c index 4ae772636863acf4c1fd59a20a20d1ad3a28ace0..f203bc962957d469a97a9c114617a0b160ebc4b3 100644 --- a/src/providers/ldap/sdap_async_groups.c +++ b/src/providers/ldap/sdap_async_groups.c @@ -804,6 +804,7 @@ static int sdap_save_groups(TALLOC_CTX *memctx, int num_groups, bool populate_members, hash_table_t *ghosts, + bool save_orig_member, char **_usn_value) { TALLOC_CTX *tmpctx; @@ -862,7 +863,8 @@ static int sdap_save_groups(TALLOC_CTX *memctx, /* if 2 pass savemembers = false */ ret = sdap_save_group(tmpctx, opts, dom, groups[i], - populate_members, has_nesting, + populate_members, + has_nesting && save_orig_member, ghosts, &usn_value, now); /* Do not fail completely on errors. @@ -1828,7 +1830,7 @@ static void sdap_get_groups_process(struct tevent_req *subreq) "to allow unrolling of nested groups.\n")); ret = sdap_save_groups(state, state->sysdb, state->dom, state->opts, state->groups, state->count, false, - NULL, NULL); + NULL, true, NULL); if (ret) { DEBUG(2, ("Failed to store groups.\n")); tevent_req_error(req, ret); @@ -1880,10 +1882,14 @@ static void sdap_get_groups_done(struct tevent_req *subreq) /* If ignore_group_members is set for the domain, don't update * group memberships in the cache. + * + * If enumeration is on, don't overwrite orig_members as they've been + * saved earlier. */ ret = sdap_save_groups(state, state->sysdb, state->dom, state->opts, state->groups, state->count, !state->dom->ignore_group_members, NULL, + !state->enumeration, &state->higher_usn); if (ret) { DEBUG(2, ("Failed to store groups.\n")); @@ -2007,7 +2013,7 @@ static void sdap_ad_match_rule_members_process(struct tevent_req *subreq) /* Now save the group, users and ghosts to the cache */ ret = sdap_save_groups(tmp_ctx, state->sysdb, state->dom, state->opts, state->groups, 1, - false, ghosts, NULL); + false, ghosts, true, NULL); if (ret != EOK) { DEBUG(SSSDBG_MINOR_FAILURE, ("Could not save group to the cache: [%s]\n", @@ -2083,7 +2089,7 @@ static void sdap_nested_done(struct tevent_req *subreq) } ret = sdap_save_groups(state, state->sysdb, state->dom, state->opts, - groups, group_count, false, ghosts, + groups, group_count, false, ghosts, true, &state->higher_usn); if (ret != EOK) { goto fail; -- 1.8.4.2