>From a6a1f85fd581ddf31fc3379048e227327634602f Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Mon, 26 Nov 2012 18:22:12 +0100 Subject: [PATCH 2/4] MEMBEROF: Split the del ghost attribute op into a reusable function This new function is going to be reused by the modify operation --- src/ldb_modules/memberof.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/ldb_modules/memberof.c b/src/ldb_modules/memberof.c index 65b1fa6b9081aef2b518c741102ce59483c4209e..211b8ac09e13a8aaece0b306bf00c8d2fc666233 100644 --- a/src/ldb_modules/memberof.c +++ b/src/ldb_modules/memberof.c @@ -2388,11 +2388,12 @@ static int mbof_del_fill_muop(struct mbof_del_ctx *del_ctx, return LDB_SUCCESS; } -static int mbof_del_fill_ghop(struct mbof_del_ctx *del_ctx, - struct ldb_message *entry) +static int mbof_del_fill_ghop_ex(struct mbof_del_ctx *del_ctx, + struct ldb_message *entry, + struct ldb_val *ghvals, + unsigned int num_gh_vals) { struct ldb_message_element *mbof; - struct ldb_message_element *ghel; struct ldb_dn *valdn; int ret; int i, j; @@ -2403,12 +2404,6 @@ static int mbof_del_fill_ghop(struct mbof_del_ctx *del_ctx, return LDB_SUCCESS; } - ghel = ldb_msg_find_element(entry, DB_GHOST); - if (ghel == NULL || ghel->num_values == 0) { - /* No ghel attribute, just return success */ - return LDB_SUCCESS; - } - ret = entry_is_group_object(entry); switch (ret) { case LDB_SUCCESS: @@ -2427,7 +2422,7 @@ static int mbof_del_fill_ghop(struct mbof_del_ctx *del_ctx, ldb_debug(ldb_module_get_ctx(del_ctx->ctx->module), LDB_DEBUG_TRACE, "will delete %d ghost users from %d parents\n", - ghel->num_values, mbof->num_values); + num_gh_vals, mbof->num_values); for (i = 0; i < mbof->num_values; i++) { valdn = ldb_dn_from_ldb_val(del_ctx->ghops, @@ -2445,12 +2440,12 @@ static int mbof_del_fill_ghop(struct mbof_del_ctx *del_ctx, "processing ghosts in parent [%s]\n", (const char *) mbof->values[i].data); - for (j = 0; j < ghel->num_values; j++) { + for (j = 0; j < num_gh_vals; j++) { ret = mbof_append_muop(del_ctx, &del_ctx->ghops, &del_ctx->num_ghops, LDB_FLAG_MOD_DELETE, valdn, - (const char *) ghel->values[j].data, + (const char *) ghvals[j].data, DB_GHOST); if (ret != LDB_SUCCESS) { return ret; @@ -2461,6 +2456,21 @@ static int mbof_del_fill_ghop(struct mbof_del_ctx *del_ctx, return LDB_SUCCESS; } +static int mbof_del_fill_ghop(struct mbof_del_ctx *del_ctx, + struct ldb_message *entry) +{ + struct ldb_message_element *ghel; + + ghel = ldb_msg_find_element(entry, DB_GHOST); + if (ghel == NULL || ghel->num_values == 0) { + /* No ghel attribute, just return success */ + return LDB_SUCCESS; + } + + return mbof_del_fill_ghop_ex(del_ctx, entry, + ghel->values, ghel->num_values); +} + /* del memberuid attributes from parent groups */ static int mbof_del_muop(struct mbof_del_ctx *del_ctx) { -- 1.8.0