Blame SOURCES/0006-tools-entry-remove-errx-from-parse_option.patch

ee8dc1
From d9912e19e48ec482351b9c384140ad71922ec5c0 Mon Sep 17 00:00:00 2001
ee8dc1
From: Sumit Bose <sbose@redhat.com>
ee8dc1
Date: Mon, 8 Apr 2019 17:22:00 +0200
ee8dc1
Subject: [PATCH 6/7] tools: entry - remove errx from parse_option
ee8dc1
ee8dc1
Related to https://bugzilla.redhat.com/show_bug.cgi?id=1588596
ee8dc1
---
ee8dc1
 tools/entry.c | 70 ++++++++++++++++++++++++++++++++++-----------------
ee8dc1
 1 file changed, 47 insertions(+), 23 deletions(-)
ee8dc1
ee8dc1
diff --git a/tools/entry.c b/tools/entry.c
ee8dc1
index 97ec6e7..f361845 100644
ee8dc1
--- a/tools/entry.c
ee8dc1
+++ b/tools/entry.c
ee8dc1
@@ -81,7 +81,7 @@ static adcli_tool_desc common_usages[] = {
ee8dc1
 	{ 0 },
ee8dc1
 };
ee8dc1
 
ee8dc1
-static void
ee8dc1
+static int
ee8dc1
 parse_option (Option opt,
ee8dc1
               const char *optarg,
ee8dc1
               adcli_conn *conn)
ee8dc1
@@ -93,54 +93,58 @@ parse_option (Option opt,
ee8dc1
 	switch (opt) {
ee8dc1
 	case opt_login_ccache:
ee8dc1
 		adcli_conn_set_login_ccache_name (conn, optarg);
ee8dc1
-		return;
ee8dc1
+		return ADCLI_SUCCESS;
ee8dc1
 	case opt_login_user:
ee8dc1
 		adcli_conn_set_login_user (conn, optarg);
ee8dc1
-		return;
ee8dc1
+		return ADCLI_SUCCESS;
ee8dc1
 	case opt_domain:
ee8dc1
 		adcli_conn_set_domain_name (conn, optarg);
ee8dc1
-		return;
ee8dc1
+		return ADCLI_SUCCESS;
ee8dc1
 	case opt_domain_realm:
ee8dc1
 		adcli_conn_set_domain_realm (conn, optarg);
ee8dc1
-		return;
ee8dc1
+		return ADCLI_SUCCESS;
ee8dc1
 	case opt_domain_controller:
ee8dc1
 		adcli_conn_set_domain_controller (conn, optarg);
ee8dc1
-		return;
ee8dc1
+		return ADCLI_SUCCESS;
ee8dc1
 	case opt_no_password:
ee8dc1
 		if (stdin_password || prompt_password) {
ee8dc1
-			errx (EUSAGE, "cannot use --no-password argument with %s",
ee8dc1
-			      stdin_password ? "--stdin-password" : "--prompt-password");
ee8dc1
+			warnx ("cannot use --no-password argument with %s",
ee8dc1
+			       stdin_password ? "--stdin-password" : "--prompt-password");
ee8dc1
+			return EUSAGE;
ee8dc1
 		} else {
ee8dc1
 			adcli_conn_set_password_func (conn, NULL, NULL, NULL);
ee8dc1
 			no_password = 1;
ee8dc1
 		}
ee8dc1
-		return;
ee8dc1
+		return ADCLI_SUCCESS;
ee8dc1
 	case opt_prompt_password:
ee8dc1
 		if (stdin_password || no_password) {
ee8dc1
-			errx (EUSAGE, "cannot use --prompt-password argument with %s",
ee8dc1
-			      stdin_password ? "--stdin-password" : "--no-password");
ee8dc1
+			warnx ("cannot use --prompt-password argument with %s",
ee8dc1
+			       stdin_password ? "--stdin-password" : "--no-password");
ee8dc1
+			return EUSAGE;
ee8dc1
 		} else {
ee8dc1
 			adcli_conn_set_password_func (conn, adcli_prompt_password_func, NULL, NULL);
ee8dc1
 			prompt_password = 1;
ee8dc1
 		}
ee8dc1
-		return;
ee8dc1
+		return ADCLI_SUCCESS;
ee8dc1
 	case opt_stdin_password:
ee8dc1
 		if (prompt_password || no_password) {
ee8dc1
-			errx (EUSAGE, "cannot use --stdin-password argument with %s",
ee8dc1
-			      prompt_password ? "--prompt-password" : "--no-password");
ee8dc1
+			warnx ("cannot use --stdin-password argument with %s",
ee8dc1
+			       prompt_password ? "--prompt-password" : "--no-password");
ee8dc1
+			return EUSAGE;
ee8dc1
 		} else {
ee8dc1
 			adcli_conn_set_password_func (conn, adcli_read_password_func, NULL, NULL);
ee8dc1
 			stdin_password = 1;
ee8dc1
 		}
ee8dc1
-		return;
ee8dc1
+		return ADCLI_SUCCESS;
ee8dc1
 	case opt_verbose:
ee8dc1
-		return;
ee8dc1
+		return ADCLI_SUCCESS;
ee8dc1
 	default:
ee8dc1
 		assert (0 && "not reached");
ee8dc1
 		break;
ee8dc1
 	}
ee8dc1
 
ee8dc1
-	errx (EUSAGE, "failure to parse option '%c'", opt);
ee8dc1
+	warnx ("failure to parse option '%c'", opt);
ee8dc1
+	return EUSAGE;
ee8dc1
 }
ee8dc1
 
ee8dc1
 int
ee8dc1
@@ -224,7 +228,11 @@ adcli_tool_user_create (adcli_conn *conn,
ee8dc1
 			adcli_attrs_free (attrs);
ee8dc1
 			return opt == 'h' ? 0 : 2;
ee8dc1
 		default:
ee8dc1
-			parse_option ((Option)opt, optarg, conn);
ee8dc1
+			res = parse_option ((Option)opt, optarg, conn);
ee8dc1
+			if (res != ADCLI_SUCCESS) {
ee8dc1
+				adcli_attrs_free (attrs);
ee8dc1
+				return res;
ee8dc1
+			}
ee8dc1
 			break;
ee8dc1
 		}
ee8dc1
 	}
ee8dc1
@@ -322,7 +330,10 @@ adcli_tool_user_delete (adcli_conn *conn,
ee8dc1
 			adcli_tool_usage (options, common_usages);
ee8dc1
 			return opt == 'h' ? 0 : 2;
ee8dc1
 		default:
ee8dc1
-			parse_option ((Option)opt, optarg, conn);
ee8dc1
+			res = parse_option ((Option)opt, optarg, conn);
ee8dc1
+			if (res != ADCLI_SUCCESS) {
ee8dc1
+				return res;
ee8dc1
+			}
ee8dc1
 			break;
ee8dc1
 		}
ee8dc1
 	}
ee8dc1
@@ -417,7 +428,11 @@ adcli_tool_group_create (adcli_conn *conn,
ee8dc1
 			adcli_attrs_free (attrs);
ee8dc1
 			return opt == 'h' ? 0 : 2;
ee8dc1
 		default:
ee8dc1
-			parse_option ((Option)opt, optarg, conn);
ee8dc1
+			res = parse_option ((Option)opt, optarg, conn);
ee8dc1
+			if (res != ADCLI_SUCCESS) {
ee8dc1
+				adcli_attrs_free (attrs);
ee8dc1
+				return res;
ee8dc1
+			}
ee8dc1
 			break;
ee8dc1
 		}
ee8dc1
 	}
ee8dc1
@@ -505,7 +520,10 @@ adcli_tool_group_delete (adcli_conn *conn,
ee8dc1
 			adcli_tool_usage (options, common_usages);
ee8dc1
 			return opt == 'h' ? 0 : 2;
ee8dc1
 		default:
ee8dc1
-			parse_option ((Option)opt, optarg, conn);
ee8dc1
+			res = parse_option ((Option)opt, optarg, conn);
ee8dc1
+			if (res != ADCLI_SUCCESS) {
ee8dc1
+				return res;
ee8dc1
+			}
ee8dc1
 			break;
ee8dc1
 		}
ee8dc1
 	}
ee8dc1
@@ -628,7 +646,10 @@ adcli_tool_member_add (adcli_conn *conn,
ee8dc1
 			adcli_tool_usage (options, common_usages);
ee8dc1
 			return opt == 'h' ? 0 : 2;
ee8dc1
 		default:
ee8dc1
-			parse_option ((Option)opt, optarg, conn);
ee8dc1
+			res = parse_option ((Option)opt, optarg, conn);
ee8dc1
+			if (res != ADCLI_SUCCESS) {
ee8dc1
+				return res;
ee8dc1
+			}
ee8dc1
 			break;
ee8dc1
 		}
ee8dc1
 	}
ee8dc1
@@ -725,7 +746,10 @@ adcli_tool_member_remove (adcli_conn *conn,
ee8dc1
 			adcli_tool_usage (options, common_usages);
ee8dc1
 			return opt == 'h' ? 0 : 2;
ee8dc1
 		default:
ee8dc1
-			parse_option ((Option)opt, optarg, conn);
ee8dc1
+			res = parse_option ((Option)opt, optarg, conn);
ee8dc1
+			if (res != ADCLI_SUCCESS) {
ee8dc1
+				return res;
ee8dc1
+			}
ee8dc1
 			break;
ee8dc1
 		}
ee8dc1
 	}
ee8dc1
-- 
ee8dc1
2.20.1
ee8dc1