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

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