Message ID | 1585963064-10311-1-git-send-email-selva.nair@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [Openvpn-devel,for-2.4,1/2] Move querying username/password from management interface to a function | expand |
Acked-by: Gert Doering <gert@greenie.muc.de> Thanks. Verified that it's indeed the same change with an extra #ifdef ENABLE_CLIENT_CR - "diffing the diffs" wasn't straightforward here. Your patch has been applied to the release/2.4 branch. commit 908eae5ce4b0b696fc335b6244b2e85c4d49c22a Author: Selva Nair Date: Fri Apr 3 21:17:43 2020 -0400 Move querying username/password from management interface to a function Signed-off-by: Selva Nair <selva.nair@gmail.com> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <1585963064-10311-1-git-send-email-selva.nair@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19697.html Signed-off-by: Gert Doering <gert@greenie.muc.de> -- kind regards, Gert Doering
Acked-by: Gert Doering <gert@greenie.muc.de> Thanks. Verified that it's indeed the same change with an extra #ifdef ENABLE_CLIENT_CR - "diffing the diffs" wasn't straightforward here. Your patch has been applied to the release/2.4 branch. commit 908eae5ce4b0b696fc335b6244b2e85c4d49c22a Author: Selva Nair Date: Fri Apr 3 21:17:43 2020 -0400 Move querying username/password from management interface to a function Signed-off-by: Selva Nair <selva.nair@gmail.com> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <1585963064-10311-1-git-send-email-selva.nair@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19697.html Signed-off-by: Gert Doering <gert@greenie.muc.de> -- kind regards, Gert Doering
diff --git a/src/openvpn/misc.c b/src/openvpn/misc.c index f44c65f..2b0d10c 100644 --- a/src/openvpn/misc.c +++ b/src/openvpn/misc.c @@ -880,6 +880,43 @@ absolute_pathname(const char *pathname) } } +#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"); + } + +#ifdef ENABLE_CLIENT_CR + if (auth_challenge && (flags & GET_USER_PASS_STATIC_CHALLENGE)) + { + sc = auth_challenge; + } +#endif + + 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 /* ifdef ENABLE_MANAGEMENT */ + /* * Get and store a username/password */ @@ -913,30 +950,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) - { - management_auth_failure(management, prefix, "previous auth credentials failed"); - } - -#ifdef ENABLE_CLIENT_CR - if (auth_challenge && (flags & GET_USER_PASS_STATIC_CHALLENGE)) + if (!auth_user_pass_mgmt(up, prefix, flags, auth_challenge)) { - sc = auth_challenge; - } -#endif - 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