diff options
author | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2005-10-20 05:58:08 +0000 |
---|---|---|
committer | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2005-10-20 05:58:08 +0000 |
commit | 984cf0036c882c4fada83448aaa37bbd5ebb8130 (patch) | |
tree | d8a8d9f93c48326f2bb2295d95e19a4c830b3d62 /misc.c | |
parent | Make sure that install-win32/prebuild gets (diff) | |
download | openvpn-984cf0036c882c4fada83448aaa37bbd5ebb8130.tar.xz |
Merged with Alon's r688.
git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@689 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 41 |
1 files changed, 26 insertions, 15 deletions
@@ -1155,7 +1155,6 @@ get_console_input (const char *prompt, const bool echo, char *input, const int c void get_user_pass (struct user_pass *up, const char *auth_file, - const bool password_only, const char *prefix, const unsigned int flags) { @@ -1173,32 +1172,44 @@ get_user_pass (struct user_pass *up, && ((auth_file && streq (auth_file, "management")) || (from_stdin && (flags & GET_USER_PASS_MANAGEMENT))) && management_query_user_pass_enabled (management)) { - if (!management_query_user_pass (management, up, prefix, password_only)) - msg (M_FATAL, "ERROR: could not read %s username/password from management interface", prefix); + if (!management_query_user_pass (management, up, prefix, flags)) + msg (M_FATAL, "ERROR: could not read %s username/password/ok from management interface", prefix); } else #endif /* * Get username/password from standard input? */ - if (from_stdin) + if (from_stdin || (flags & GET_USER_PASS_NEED_OK)) { struct buffer user_prompt = alloc_buf_gc (128, &gc); struct buffer pass_prompt = alloc_buf_gc (128, &gc); - buf_printf (&user_prompt, "Enter %s Username:", prefix); - buf_printf (&pass_prompt, "Enter %s Password:", prefix); - - if (!password_only) + if (flags & GET_USER_PASS_NEED_OK) { - 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); + 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)) + { + 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 password from stdin", prefix); + 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"); } else { @@ -1222,7 +1233,7 @@ get_user_pass (struct user_pass *up, if (!fp) msg (M_ERR, "Error opening '%s' auth file: %s", prefix, auth_file); - if (password_only) + if (flags & GET_USER_PASS_PASSWORD_ONLY) { if (fgets (up->password, USER_PASS_LEN, fp) == NULL) msg (M_FATAL, "Error reading password from %s authfile: %s", @@ -1243,7 +1254,7 @@ get_user_pass (struct user_pass *up, chomp (up->username); chomp (up->password); - if (!password_only && strlen (up->username) == 0) + if (!(flags & GET_USER_PASS_PASSWORD_ONLY) && strlen (up->username) == 0) msg (M_FATAL, "ERROR: username from %s authfile '%s' is empty", prefix, auth_file); } |