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