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

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