|
|
905b4d |
From c74de0bbed7729b44567ca1cf364ddca94a2acbf Mon Sep 17 00:00:00 2001
|
|
|
905b4d |
From: Sumit Bose <sbose@redhat.com>
|
|
|
905b4d |
Date: Fri, 5 Dec 2014 11:11:49 +0100
|
|
|
905b4d |
Subject: [PATCH 164/167] IPA: process_members() optionally return missing
|
|
|
905b4d |
members list
|
|
|
905b4d |
|
|
|
905b4d |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
905b4d |
(cherry picked from commit 942ebb62c8df766a22271103abd518ddae02ea3a)
|
|
|
905b4d |
---
|
|
|
905b4d |
src/providers/ipa/ipa_s2n_exop.c | 85 +++++++++++++++++++++++++++++++---------
|
|
|
905b4d |
1 file changed, 67 insertions(+), 18 deletions(-)
|
|
|
905b4d |
|
|
|
905b4d |
diff --git a/src/providers/ipa/ipa_s2n_exop.c b/src/providers/ipa/ipa_s2n_exop.c
|
|
|
905b4d |
index 68f4cb7d8ff778342c5280652f0a62753c7c7b2c..bc476b469d02ea5f80d7e792693f5d25db889b74 100644
|
|
|
905b4d |
--- a/src/providers/ipa/ipa_s2n_exop.c
|
|
|
905b4d |
+++ b/src/providers/ipa/ipa_s2n_exop.c
|
|
|
905b4d |
@@ -1222,7 +1222,8 @@ fail:
|
|
|
905b4d |
|
|
|
905b4d |
static errno_t process_members(struct sss_domain_info *domain,
|
|
|
905b4d |
struct sysdb_attrs *group_attrs,
|
|
|
905b4d |
- char **members)
|
|
|
905b4d |
+ char **members,
|
|
|
905b4d |
+ TALLOC_CTX *mem_ctx, char ***_missing_members)
|
|
|
905b4d |
{
|
|
|
905b4d |
int ret;
|
|
|
905b4d |
size_t c;
|
|
|
905b4d |
@@ -1231,9 +1232,12 @@ static errno_t process_members(struct sss_domain_info *domain,
|
|
|
905b4d |
const char *dn_str;
|
|
|
905b4d |
struct sss_domain_info *obj_domain;
|
|
|
905b4d |
struct sss_domain_info *parent_domain;
|
|
|
905b4d |
+ char **missing_members = NULL;
|
|
|
905b4d |
+ size_t miss_count = 0;
|
|
|
905b4d |
|
|
|
905b4d |
if (members == NULL) {
|
|
|
905b4d |
DEBUG(SSSDBG_TRACE_INTERNAL, "No members\n");
|
|
|
905b4d |
+ *_missing_members = NULL;
|
|
|
905b4d |
return EOK;
|
|
|
905b4d |
}
|
|
|
905b4d |
|
|
|
905b4d |
@@ -1243,6 +1247,17 @@ static errno_t process_members(struct sss_domain_info *domain,
|
|
|
905b4d |
return ENOMEM;
|
|
|
905b4d |
}
|
|
|
905b4d |
|
|
|
905b4d |
+ if (_missing_members != NULL && mem_ctx != NULL) {
|
|
|
905b4d |
+ /* count members */
|
|
|
905b4d |
+ for (c = 0; members[c] != NULL; c++);
|
|
|
905b4d |
+ missing_members = talloc_zero_array(tmp_ctx, char *, c + 1);
|
|
|
905b4d |
+ if (missing_members == NULL) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "talloc_array_zero failed.\n");
|
|
|
905b4d |
+ ret = ENOMEM;
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
parent_domain = get_domains_head(domain);
|
|
|
905b4d |
|
|
|
905b4d |
for (c = 0; members[c] != NULL; c++) {
|
|
|
905b4d |
@@ -1256,27 +1271,46 @@ static errno_t process_members(struct sss_domain_info *domain,
|
|
|
905b4d |
ret = sysdb_search_user_by_name(tmp_ctx, obj_domain, members[c], NULL,
|
|
|
905b4d |
&msg;;
|
|
|
905b4d |
if (ret == EOK) {
|
|
|
905b4d |
- dn_str = ldb_dn_get_linearized(msg->dn);
|
|
|
905b4d |
- if (dn_str == NULL) {
|
|
|
905b4d |
- DEBUG(SSSDBG_OP_FAILURE, "ldb_dn_get_linearized failed.\n");
|
|
|
905b4d |
- goto done;
|
|
|
905b4d |
- }
|
|
|
905b4d |
+ if (group_attrs != NULL) {
|
|
|
905b4d |
+ dn_str = ldb_dn_get_linearized(msg->dn);
|
|
|
905b4d |
+ if (dn_str == NULL) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "ldb_dn_get_linearized failed.\n");
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
|
|
|
905b4d |
- DEBUG(SSSDBG_TRACE_ALL, "Adding member [%s][%s]\n",
|
|
|
905b4d |
- members[c], dn_str);
|
|
|
905b4d |
+ DEBUG(SSSDBG_TRACE_ALL, "Adding member [%s][%s]\n",
|
|
|
905b4d |
+ members[c], dn_str);
|
|
|
905b4d |
|
|
|
905b4d |
- ret = sysdb_attrs_add_string(group_attrs, SYSDB_MEMBER, dn_str);
|
|
|
905b4d |
- if (ret != EOK) {
|
|
|
905b4d |
- DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_add_string failed.\n");
|
|
|
905b4d |
- goto done;
|
|
|
905b4d |
+ ret = sysdb_attrs_add_string(group_attrs, SYSDB_MEMBER, dn_str);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
905b4d |
+ "sysdb_attrs_add_string failed.\n");
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
}
|
|
|
905b4d |
} else if (ret == ENOENT) {
|
|
|
905b4d |
- DEBUG(SSSDBG_TRACE_ALL, "Adding ghost member [%s]\n", members[c]);
|
|
|
905b4d |
+ if (group_attrs != NULL) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_TRACE_ALL, "Adding ghost member [%s]\n",
|
|
|
905b4d |
+ members[c]);
|
|
|
905b4d |
|
|
|
905b4d |
- ret = sysdb_attrs_add_string(group_attrs, SYSDB_GHOST, members[c]);
|
|
|
905b4d |
- if (ret != EOK) {
|
|
|
905b4d |
- DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_add_string failed.\n");
|
|
|
905b4d |
- goto done;
|
|
|
905b4d |
+ ret = sysdb_attrs_add_string(group_attrs, SYSDB_GHOST,
|
|
|
905b4d |
+ members[c]);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
905b4d |
+ "sysdb_attrs_add_string failed.\n");
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ if (missing_members != NULL) {
|
|
|
905b4d |
+ missing_members[miss_count] = talloc_strdup(missing_members,
|
|
|
905b4d |
+ members[c]);
|
|
|
905b4d |
+ if (missing_members[miss_count] == NULL) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "talloc_strdup failed.\n");
|
|
|
905b4d |
+ ret = ENOMEM;
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ miss_count++;
|
|
|
905b4d |
}
|
|
|
905b4d |
} else {
|
|
|
905b4d |
DEBUG(SSSDBG_OP_FAILURE, "sysdb_search_user_by_name failed.\n");
|
|
|
905b4d |
@@ -1284,6 +1318,21 @@ static errno_t process_members(struct sss_domain_info *domain,
|
|
|
905b4d |
}
|
|
|
905b4d |
}
|
|
|
905b4d |
|
|
|
905b4d |
+ if (_missing_members != NULL) {
|
|
|
905b4d |
+ if (miss_count == 0) {
|
|
|
905b4d |
+ *_missing_members = NULL;
|
|
|
905b4d |
+ } else {
|
|
|
905b4d |
+ if (mem_ctx != NULL) {
|
|
|
905b4d |
+ *_missing_members = talloc_steal(mem_ctx, missing_members);
|
|
|
905b4d |
+ } else {
|
|
|
905b4d |
+ DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
905b4d |
+ "Missing memory context for missing members list.\n");
|
|
|
905b4d |
+ ret = EINVAL;
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
ret = EOK;
|
|
|
905b4d |
done:
|
|
|
905b4d |
talloc_free(tmp_ctx);
|
|
|
905b4d |
@@ -1986,7 +2035,7 @@ static errno_t ipa_s2n_save_objects(struct sss_domain_info *dom,
|
|
|
905b4d |
}
|
|
|
905b4d |
|
|
|
905b4d |
ret = process_members(dom, attrs->sysdb_attrs,
|
|
|
905b4d |
- attrs->a.group.gr_mem);
|
|
|
905b4d |
+ attrs->a.group.gr_mem, NULL, NULL);
|
|
|
905b4d |
if (ret != EOK) {
|
|
|
905b4d |
DEBUG(SSSDBG_OP_FAILURE, "process_members failed.\n");
|
|
|
905b4d |
goto done;
|
|
|
905b4d |
--
|
|
|
905b4d |
2.1.0
|
|
|
905b4d |
|