From: Selva Nair <selva.n...@gmail.com> This helps the next patch. No functionality changes, only refactoring.
Signed-off-by: Selva Nair <selva.n...@gmail.com> --- No changes from v1 src/openvpn/misc.c | 54 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/src/openvpn/misc.c b/src/openvpn/misc.c index 1931149..0d5ac30 100644 --- a/src/openvpn/misc.c +++ b/src/openvpn/misc.c @@ -116,6 +116,38 @@ hostname_randomize(const char *hostname, struct gc_arena *gc) #undef n_rnd_bytes } +#ifdef ENABLE_MANAGEMENT +/* Get username/password from the management interface */ +static bool +auth_user_pass_mgmt(struct user_pass *up, const char *prefix, const unsigned int flags, + const char *auth_challenge) +{ + const char *sc = NULL; + + if (flags & GET_USER_PASS_PREVIOUS_CREDS_FAILED) + { + management_auth_failure(management, prefix, "previous auth credentials failed"); + } + + if (auth_challenge && (flags & GET_USER_PASS_STATIC_CHALLENGE)) + { + sc = auth_challenge; + } + if (!management_query_user_pass(management, up, prefix, flags, sc)) + { + if ((flags & GET_USER_PASS_NOFATAL) != 0) + { + return false; + } + else + { + msg(M_FATAL, "ERROR: could not read %s username/password/ok/string from management interface", prefix); + } + } + return true; +} +#endif + /* * Get and store a username/password */ @@ -149,28 +181,10 @@ get_user_pass_cr(struct user_pass *up, && (!from_authfile && (flags & GET_USER_PASS_MANAGEMENT)) && management_query_user_pass_enabled(management)) { - const char *sc = NULL; response_from_stdin = false; - - if (flags & GET_USER_PASS_PREVIOUS_CREDS_FAILED) + if (!auth_user_pass_mgmt(up, prefix, flags, auth_challenge)) { - management_auth_failure(management, prefix, "previous auth credentials failed"); - } - - if (auth_challenge && (flags & GET_USER_PASS_STATIC_CHALLENGE)) - { - sc = auth_challenge; - } - if (!management_query_user_pass(management, up, prefix, flags, sc)) - { - if ((flags & GET_USER_PASS_NOFATAL) != 0) - { - return false; - } - else - { - msg(M_FATAL, "ERROR: could not read %s username/password/ok/string from management interface", prefix); - } + return false; } } else -- 2.1.4 _______________________________________________ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel