summaryrefslogtreecommitdiff
path: root/src/ldb_modules
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2012-11-26 18:22:12 +0100
committerJakub Hrozek <jhrozek@redhat.com>2012-12-05 23:32:18 +0100
commit08500fd7b7d64c26289a62772d433ea5bf578482 (patch)
tree4d1dd8ec386aab0b13bd791b20d1b9ef3da33bec /src/ldb_modules
parenta8fb39ac2e029d32f6937f8bb683284dcb648a9d (diff)
downloadsssd-08500fd7b7d64c26289a62772d433ea5bf578482.tar.gz
sssd-08500fd7b7d64c26289a62772d433ea5bf578482.tar.bz2
sssd-08500fd7b7d64c26289a62772d433ea5bf578482.zip
MEMBEROF: Split the del ghost attribute op into a reusable function
This new function is going to be reused by the modify operation
Diffstat (limited to 'src/ldb_modules')
-rw-r--r--src/ldb_modules/memberof.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/ldb_modules/memberof.c b/src/ldb_modules/memberof.c
index 68b340cf..57336191 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)
{