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