diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2011-10-28 17:03:03 +0200 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2011-10-31 08:13:35 -0400 |
commit | 774c582f0cb479947d4d6fc06a9d521f9e645eb1 (patch) | |
tree | cb864f79e0b727f32070f7ee4ca51ca563d1add7 | |
parent | c417f0b8cde38ff5cc10241383f1481e3440879c (diff) | |
download | sssd-774c582f0cb479947d4d6fc06a9d521f9e645eb1.tar.gz sssd-774c582f0cb479947d4d6fc06a9d521f9e645eb1.tar.xz sssd-774c582f0cb479947d4d6fc06a9d521f9e645eb1.zip |
RFC2307bis initgroups: fix nested groups processing
Due to incorrectly written loop, SSSD would go into infitite loop if it
processed the same group on two different levels of membership.
-rw-r--r-- | src/providers/ldap/sdap_async_accounts.c | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/src/providers/ldap/sdap_async_accounts.c b/src/providers/ldap/sdap_async_accounts.c index edd4f68c5..0fad83c57 100644 --- a/src/providers/ldap/sdap_async_accounts.c +++ b/src/providers/ldap/sdap_async_accounts.c @@ -4881,17 +4881,23 @@ static void rfc2307bis_nested_groups_process(struct tevent_req *subreq) * Move on to the next group */ state->group_iter++; - if (state->group_iter < state->num_groups) { - do { - ret = rfc2307bis_nested_groups_step(req); - if (ret != EOK && ret != EAGAIN) { - tevent_req_error(req, ret); - return; - } - } while (ret == EOK); + while (state->group_iter < state->num_groups) { + ret = rfc2307bis_nested_groups_step(req); + if (ret == EAGAIN) { + /* Looking up parent groups.. */ + return; + } else if (ret != EOK) { + tevent_req_error(req, ret); + return; + } + /* EOK means this group has already been processed - * in another level */ - } else { + * in another nesting level */ + state->group_iter++; + } + + if (state->group_iter == state->num_groups) { + /* All groups processed. Done. */ tevent_req_done(req); } return; @@ -4936,18 +4942,25 @@ static void rfc2307bis_nested_groups_done(struct tevent_req *subreq) } state->group_iter++; - if (state->group_iter < state->num_groups) { - do { - ret = rfc2307bis_nested_groups_step(req); - if (ret != EOK && ret != EAGAIN) { - tevent_req_error(req, ret); - return; - } - } while (ret == EOK); + while (state->group_iter < state->num_groups) { + ret = rfc2307bis_nested_groups_step(req); + if (ret == EAGAIN) { + /* Looking up parent groups.. */ + return; + } else if (ret != EOK) { + tevent_req_error(req, ret); + return; + } + /* EOK means this group has already been processed - * in another level */ - } else { + * in another nesting level */ + state->group_iter++; + } + + if (state->group_iter == state->num_groups) { + /* All groups processed. Done. */ tevent_req_done(req); + return; } } |