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

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