From c5a98a8b6f8dfe203f84580f13695b3726336e7c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 2 Dec 2009 16:04:50 -0500 Subject: Fix memberof plugin A loop was badly built and was skipping entries. This left some memberof attributes in place that should have been removed. --- server/ldb_modules/memberof.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'server') diff --git a/server/ldb_modules/memberof.c b/server/ldb_modules/memberof.c index bd32d0acd..76914133e 100644 --- a/server/ldb_modules/memberof.c +++ b/server/ldb_modules/memberof.c @@ -82,7 +82,7 @@ struct mbof_del_operation { struct mbof_del_operation *parent; struct mbof_del_operation **children; int num_children; - int cur_child; + int next_child; struct ldb_dn *entry_dn; @@ -1760,23 +1760,26 @@ static int mbof_del_get_next(struct mbof_del_operation *delop, /* Find next one */ for (top = delop; top; top = top->parent) { - if (top->num_children && - top->cur_child < top->num_children) { + if (top->num_children == 0 || top->next_child >= top->num_children) { + /* no children, go for next one */ + continue; + } - cop = top->children[top->cur_child]; - top->cur_child++; + while (top->next_child < top->num_children) { + cop = top->children[top->next_child]; + top->next_child++; /* verify this operation has not already been performed */ for (tmp = del_ctx->history; tmp; tmp = tmp->next) { - if (ldb_dn_compare(tmp->dn, cop->entry_dn) == 0) break; + if (ldb_dn_compare(tmp->dn, cop->entry_dn) == 0) { + break; + } } - if (tmp) { - /* it's a dup */ - continue; + if (tmp == NULL) { + /* and return the current one */ + *nextop = cop; + return LDB_SUCCESS; } - - *nextop = cop; - return LDB_SUCCESS; } } -- cgit