>From ac922c8bfa5c7702054c3566d57de14370175693 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Mon, 26 Nov 2012 18:22:12 +0100 Subject: [PATCH 3/6] 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 68b340cfd03714ad2f4192eccf6fb832486c644a..57336191084f878f2ee7384126828a7baddf299d 100644 --- a/src/ldb_modules/memberof.c +++ b/src/ldb_modules/memberof.c @@ -2403,11 +2403,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; @@ -2418,12 +2419,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: @@ -2442,7 +2437,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, @@ -2460,12 +2455,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; @@ -2476,6 +2471,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.1