summaryrefslogtreecommitdiffstats
path: root/src/util/domain_info_utils.c
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2015-01-22 17:03:00 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-01-23 13:16:53 +0100
commitdd5ebcde05442422f39084acb49b28cf47002d1e (patch)
tree6f9127ff3c2f5d2d4a5c5bb2d8b596acbaa60cc1 /src/util/domain_info_utils.c
parentba818cc39dfe94c2b8613f4badf7912811f0f737 (diff)
downloadsssd-dd5ebcde05442422f39084acb49b28cf47002d1e.tar.gz
sssd-dd5ebcde05442422f39084acb49b28cf47002d1e.tar.xz
sssd-dd5ebcde05442422f39084acb49b28cf47002d1e.zip
IPA: properly handle mixed-case trusted domains
In the SSSD cache domain names are handled case-sensitive. As a result fully-qualified names in RDN contain the domain part in the original spelling. When IPA client lookup up group-memberships on the IPA server via the extdom plugin the names returned are all lower case. To make sure new DNs are generated correctly the domain part must adjusted. Related to https://fedorahosted.org/sssd/ticket/2159 Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Diffstat (limited to 'src/util/domain_info_utils.c')
-rw-r--r--src/util/domain_info_utils.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/util/domain_info_utils.c b/src/util/domain_info_utils.c
index e04b90576..e0f1120e3 100644
--- a/src/util/domain_info_utils.c
+++ b/src/util/domain_info_utils.c
@@ -777,3 +777,75 @@ done:
return ret;
}
+
+errno_t fix_domain_in_name_list(TALLOC_CTX *mem_ctx,
+ struct sss_domain_info *dom,
+ char **in, char ***_out)
+{
+ int ret;
+ size_t c;
+ TALLOC_CTX *tmp_ctx;
+ char **out;
+ struct sss_domain_info *head;
+ struct sss_domain_info *out_domain;
+ char *in_name;
+ char *in_domain;
+
+ head = get_domains_head(dom);
+
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ DEBUG(SSSDBG_OP_FAILURE, "talloc_new failed.\n");
+ return ENOMEM;
+ }
+
+ /* count elements */
+ for (c = 0; in[c] != NULL; c++);
+
+ out = talloc_zero_array(tmp_ctx, char *, c + 1);
+ if (out == NULL) {
+ DEBUG(SSSDBG_OP_FAILURE, "talloc_array failed.\n");
+ ret = ENOMEM;
+ goto done;
+ }
+
+ for (c = 0; in[c] != NULL; c++) {
+ ret = sss_parse_name(tmp_ctx, head->names, in[c], &in_domain,
+ &in_name);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE, "sss_parse_name failed for [%s].\n",
+ in[c]);
+ goto done;
+ }
+
+ if (in_domain == NULL) {
+ out[c] = talloc_strdup(out, in_name);
+ } else {
+ out_domain = find_domain_by_name(head, in_domain, true);
+ if (out_domain == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "Cannot find domain with name [%s].\n", in_domain);
+ ret = EINVAL;
+ goto done;
+ }
+
+ out[c] = sss_tc_fqname(out, head->names, out_domain, in_name);
+ }
+
+ if (out[c] == NULL) {
+ DEBUG(SSSDBG_OP_FAILURE, "%s failed.\n",
+ in_domain == NULL ? "talloc_strdup" : "sss_tc_fqname");
+ ret = ENOMEM;
+ goto done;
+ }
+ }
+
+ *_out = talloc_steal(mem_ctx, out);
+
+ ret = EOK;
+
+done:
+ talloc_free(tmp_ctx);
+
+ return ret;
+}