summaryrefslogtreecommitdiff
path: root/src/providers
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2011-10-28 16:54:02 +0200
committerStephen Gallagher <sgallagh@redhat.com>2011-10-31 08:03:28 -0400
commit9aac6b1a195159d5aa0bbbe91fc72ce2c2b021aa (patch)
treead6381bfeedb8d3a286c89a00ba903a3c41d09e3 /src/providers
parent8db778c4a34b38224712bec0701303550781dcd5 (diff)
downloadsssd-9aac6b1a195159d5aa0bbbe91fc72ce2c2b021aa.tar.gz
sssd-9aac6b1a195159d5aa0bbbe91fc72ce2c2b021aa.tar.bz2
sssd-9aac6b1a195159d5aa0bbbe91fc72ce2c2b021aa.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.
Diffstat (limited to 'src/providers')
-rw-r--r--src/providers/ldap/sdap_async_initgroups.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/src/providers/ldap/sdap_async_initgroups.c b/src/providers/ldap/sdap_async_initgroups.c
index f36080d4..26bc34f0 100644
--- a/src/providers/ldap/sdap_async_initgroups.c
+++ b/src/providers/ldap/sdap_async_initgroups.c
@@ -1885,17 +1885,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;
@@ -1940,18 +1946,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;
}
}