Blame SOURCES/0005-tools-remove-errx-from-setup_krb5_conf_directory.patch

ee8dc1
From b8f5d995d30c17eb8bec3ac5e0777ea94f5b76c3 Mon Sep 17 00:00:00 2001
ee8dc1
From: Sumit Bose <sbose@redhat.com>
ee8dc1
Date: Mon, 15 Apr 2019 18:00:52 +0200
ee8dc1
Subject: [PATCH 5/7] tools: remove errx from setup_krb5_conf_directory
ee8dc1
ee8dc1
Related to https://bugzilla.redhat.com/show_bug.cgi?id=1588596
ee8dc1
---
ee8dc1
 tools/tools.c | 38 ++++++++++++++++++++++++--------------
ee8dc1
 1 file changed, 24 insertions(+), 14 deletions(-)
ee8dc1
ee8dc1
diff --git a/tools/tools.c b/tools/tools.c
ee8dc1
index bdf6d38..fc9fa9a 100644
ee8dc1
--- a/tools/tools.c
ee8dc1
+++ b/tools/tools.c
ee8dc1
@@ -327,21 +327,31 @@ setup_krb5_conf_directory (adcli_conn *conn)
ee8dc1
 	}
ee8dc1
 
ee8dc1
 	if (asprintf (&directory, "%s%sadcli-krb5-XXXXXX", parent,
ee8dc1
-	              (parent[0] && parent[strlen(parent) - 1] == '/') ? "" : "/") < 0)
ee8dc1
-		errx (1, "unexpected: out of memory");
ee8dc1
-
ee8dc1
-	if (mkdtemp (directory) == NULL) {
ee8dc1
-		errn = errno;
ee8dc1
+	              (parent[0] && parent[strlen(parent) - 1] == '/') ? "" : "/") < 0) {
ee8dc1
+		warnx ("unexpected: out of memory");
ee8dc1
+		directory = NULL; /* content is undefined */
ee8dc1
 		failed = 1;
ee8dc1
-		warnx ("couldn't create temporary directory in: %s: %s",
ee8dc1
-		       parent, strerror (errn));
ee8dc1
-	} else {
ee8dc1
-		if (asprintf (&filename, "%s/krb5.conf", directory) < 0 ||
ee8dc1
-		    asprintf (&snippets, "%s/krb5.d", directory) < 0 ||
ee8dc1
-		    asprintf (&contents, "includedir %s\n%s%s\n", snippets,
ee8dc1
-		              krb5_conf ? "include " : "",
ee8dc1
-		              krb5_conf ? krb5_conf : "") < 0)
ee8dc1
-			errx (1, "unexpected: out of memory");
ee8dc1
+	}
ee8dc1
+
ee8dc1
+	if (!failed) {
ee8dc1
+		if (mkdtemp (directory) == NULL) {
ee8dc1
+			errn = errno;
ee8dc1
+			failed = 1;
ee8dc1
+			warnx ("couldn't create temporary directory in: %s: %s",
ee8dc1
+			       parent, strerror (errn));
ee8dc1
+		} else {
ee8dc1
+			if (asprintf (&filename, "%s/krb5.conf", directory) < 0 ||
ee8dc1
+			    asprintf (&snippets, "%s/krb5.d", directory) < 0 ||
ee8dc1
+			    asprintf (&contents, "includedir %s\n%s%s\n", snippets,
ee8dc1
+			              krb5_conf ? "include " : "",
ee8dc1
+			              krb5_conf ? krb5_conf : "") < 0) {
ee8dc1
+				warnx ("unexpected: out of memory");
ee8dc1
+				filename = NULL; /* content is undefined */
ee8dc1
+				snippets = NULL; /* content is undefined */
ee8dc1
+				contents = NULL; /* content is undefined */
ee8dc1
+				failed = 1;
ee8dc1
+			}
ee8dc1
+		}
ee8dc1
 	}
ee8dc1
 
ee8dc1
 	if (!failed) {
ee8dc1
-- 
ee8dc1
2.20.1
ee8dc1