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

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