aboutsummaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2005-10-20 10:16:41 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2005-10-20 10:16:41 +0000
commitdd1047f52119bbe78bd0f2c9452c9965c4bdf0dc (patch)
tree1675b676ff3f477d365940dd8a39578fed97ef62 /misc.c
parentChangeLog edit (diff)
downloadopenvpn-dd1047f52119bbe78bd0f2c9452c9965c4bdf0dc.tar.xz
Some changes to GET_USER_PASS_NEED_OK flag to
get_user_pass. (1) Allow an additional longer prompt string to be passed to the management interface client, in addition to the request type string. (2) Allow the management interface client to return a string, usually "ok" or "cancel" as the third argument to "needok" command. (3) Renamed "ok" command in management interface to "needok". (4) Edited management-notes.txt to reflect new needok feature. (5) See init.c:125 for new code example. git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@694 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/misc.c b/misc.c
index 4a79ee5..df40ace 100644
--- a/misc.c
+++ b/misc.c
@@ -1178,38 +1178,42 @@ get_user_pass (struct user_pass *up,
else
#endif
/*
+ * Get NEED_OK confirmation from the console
+ */
+ if (flags & GET_USER_PASS_NEED_OK)
+ {
+ struct buffer user_prompt = alloc_buf_gc (128, &gc);
+
+ buf_printf (&user_prompt, "NEED-OK|%s|%s:", prefix, up->username);
+
+ if (!get_console_input (BSTR (&user_prompt), true, up->password, USER_PASS_LEN))
+ msg (M_FATAL, "ERROR: could not read %s ok-confirmation from stdin", prefix);
+
+ if (!strlen (up->password))
+ strcpy (up->password, "ok");
+ }
+
+ /*
* Get username/password from standard input?
*/
- if (from_stdin || (flags & GET_USER_PASS_NEED_OK))
+ else if (from_stdin)
{
struct buffer user_prompt = alloc_buf_gc (128, &gc);
struct buffer pass_prompt = alloc_buf_gc (128, &gc);
- if (flags & GET_USER_PASS_NEED_OK)
- {
- buf_printf (&pass_prompt, "NEED-OK:%s:", prefix);
- }
- else
+ buf_printf (&user_prompt, "Enter %s Username:", prefix);
+ buf_printf (&pass_prompt, "Enter %s Password:", prefix);
+
+ if (!(flags & GET_USER_PASS_PASSWORD_ONLY))
{
- buf_printf (&user_prompt, "Enter %s Username:", prefix);
- buf_printf (&pass_prompt, "Enter %s Password:", prefix);
-
- if (!(flags & GET_USER_PASS_PASSWORD_ONLY))
- {
- if (!get_console_input (BSTR (&user_prompt), true, up->username, USER_PASS_LEN))
- msg (M_FATAL, "ERROR: could not read %s username from stdin", prefix);
- if (strlen (up->username) == 0)
- msg (M_FATAL, "ERROR: %s username is empty", prefix);
- }
+ if (!get_console_input (BSTR (&user_prompt), true, up->username, USER_PASS_LEN))
+ msg (M_FATAL, "ERROR: could not read %s username from stdin", prefix);
+ if (strlen (up->username) == 0)
+ msg (M_FATAL, "ERROR: %s username is empty", prefix);
}
if (!get_console_input (BSTR (&pass_prompt), false, up->password, USER_PASS_LEN))
- msg (M_FATAL, "ERROR: could not not read %s %s from stdin",
- prefix,
- (flags & GET_USER_PASS_NEED_OK) ? "ok-confirmation" : "password");
-
- if (flags & GET_USER_PASS_NEED_OK)
- strcpy (up->password, "ok");
+ msg (M_FATAL, "ERROR: could not not read %s password from stdin", prefix);
}
else
{