Blame SOURCES/0033-IPA-fix-capaths-output.patch

b2d430
From cf161fe0317fd37e1c5ad826cb783905aaf1f048 Mon Sep 17 00:00:00 2001
b2d430
From: Sumit Bose <sbose@redhat.com>
b2d430
Date: Mon, 18 Jul 2016 17:19:36 +0200
b2d430
Subject: [PATCH 33/44] IPA: fix [capaths] output
b2d430
b2d430
the capaths for a single domain should be collected in a single
b2d430
sub-section in the MIT Kerberos configuration not spread over multiple
b2d430
one. See the capaths section of the krb5.conf man page for details.
b2d430
b2d430
Resolves:
b2d430
https://fedorahosted.org/sssd/ticket/3103
b2d430
b2d430
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
b2d430
---
b2d430
 src/util/domain_info_utils.c | 29 ++++++++++++++++++++++++++---
b2d430
 1 file changed, 26 insertions(+), 3 deletions(-)
b2d430
b2d430
diff --git a/src/util/domain_info_utils.c b/src/util/domain_info_utils.c
b2d430
index 360f70376c472466168d93d45b6c547d51dd18c6..8cdd50d8d521d734e9ffd9b4e81cd6fbd7d158c7 100644
b2d430
--- a/src/util/domain_info_utils.c
b2d430
+++ b/src/util/domain_info_utils.c
b2d430
@@ -280,6 +280,7 @@ sss_write_domain_mappings(struct sss_domain_info *domain)
b2d430
     bool capaths_started = false;
b2d430
     char *uc_forest;
b2d430
     char *uc_parent;
b2d430
+    char *parent_capaths = NULL;
b2d430
 
b2d430
     if (domain == NULL || domain->name == NULL) {
b2d430
         DEBUG(SSSDBG_CRIT_FAILURE, "No domain name provided\n");
b2d430
@@ -399,9 +400,31 @@ sss_write_domain_mappings(struct sss_domain_info *domain)
b2d430
             capaths_started = true;
b2d430
         }
b2d430
 
b2d430
-        ret = fprintf(fstream, "%s = {\n  %s = %s\n}\n%s = {\n  %s = %s\n}\n",
b2d430
-                                dom->realm, uc_parent, uc_forest,
b2d430
-                                uc_parent, dom->realm, uc_forest);
b2d430
+        ret = fprintf(fstream, "%s = {\n  %s = %s\n}\n",
b2d430
+                                dom->realm, uc_parent, uc_forest);
b2d430
+        if (ret < 0) {
b2d430
+            DEBUG(SSSDBG_CRIT_FAILURE, "fprintf failed\n");
b2d430
+            goto done;
b2d430
+        }
b2d430
+
b2d430
+        if (parent_capaths == NULL) {
b2d430
+            parent_capaths = talloc_asprintf(tmp_ctx, "  %s = %s\n", dom->realm,
b2d430
+                                                                     uc_forest);
b2d430
+        } else {
b2d430
+            parent_capaths = talloc_asprintf_append(parent_capaths,
b2d430
+                                                    "  %s = %s\n", dom->realm,
b2d430
+                                                    uc_forest);
b2d430
+        }
b2d430
+        if (parent_capaths == NULL) {
b2d430
+            DEBUG(SSSDBG_OP_FAILURE,
b2d430
+                  "talloc_asprintf/talloc_asprintf_append failed.\n");
b2d430
+            ret = ENOMEM;
b2d430
+            goto done;
b2d430
+        }
b2d430
+    }
b2d430
+
b2d430
+    if (parent_capaths != NULL) {
b2d430
+        ret = fprintf(fstream, "%s = {\n%s}\n", uc_parent, parent_capaths);
b2d430
         if (ret < 0) {
b2d430
             DEBUG(SSSDBG_CRIT_FAILURE, "fprintf failed\n");
b2d430
             goto done;
b2d430
-- 
b2d430
2.4.11
b2d430