From: Razvan Cojocaru <[email protected]> tls_authentication_status() open-coded check_for_client_reason() for the plugin and script auth status. Call the helper instead. key_state_check_auth_failed_message_file() had no other caller, so fold it into the helper.
Change-Id: Ia48c1efc9a687383a1dc87edd49d8ba3eb5a87ad Signed-off-by: Razvan Cojocaru <[email protected]> Acked-by: Frank Lichtenheld <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2217 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2217 This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above): Frank Lichtenheld <[email protected]> diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_verify.c index 8641d15..f33a59c 100644 --- a/src/openvpn/ssl_verify.c +++ b/src/openvpn/ssl_verify.c @@ -1037,24 +1037,22 @@ } /** - * Checks if the auth failed reason file has any content and if yes it will - * be returned as string allocated in gc to the caller. - */ -static char * -key_state_check_auth_failed_message_file(const struct auth_deferred_status *ads, - struct gc_arena *gc) + * Check if the script/plugin left a message in the auth failed message + * file and relay it to the user */ +static void +check_for_client_reason(struct tls_multi *multi, const struct auth_deferred_status *ads) { - char *ret = NULL; if (ads->auth_failed_reason_file) { - struct buffer reason = buffer_read_from_file(ads->auth_failed_reason_file, gc); + struct gc_arena gc = gc_new(); + struct buffer reason = buffer_read_from_file(ads->auth_failed_reason_file, &gc); if (BLEN(&reason)) { - ret = BSTR(&reason); + auth_set_client_reason(multi, BSTR(&reason)); } + gc_free(&gc); } - return ret; } @@ -1221,21 +1219,9 @@ #endif if (failed_auth) { - struct gc_arena gc = gc_new(); const struct key_state *ks = get_primary_key(multi); - const char *plugin_message = - key_state_check_auth_failed_message_file(&ks->plugin_auth, &gc); - const char *script_message = - key_state_check_auth_failed_message_file(&ks->script_auth, &gc); - - if (plugin_message) - { - auth_set_client_reason(multi, plugin_message); - } - if (script_message) - { - auth_set_client_reason(multi, script_message); - } + check_for_client_reason(multi, &ks->plugin_auth); + check_for_client_reason(multi, &ks->script_auth); /* We have at least one session that failed authentication. There * might be still another session with valid keys. @@ -1243,7 +1229,6 @@ * with the other session (and we actually did that in earlier * version, this behaviour is really strange from a user (admin) * experience */ - gc_free(&gc); return TLS_AUTHENTICATION_FAILED; } else if (success) @@ -1305,20 +1290,6 @@ * this is the place to start. *************************************************************************** */ -/** - * Check if the script/plugin left a message in the auth failed message - * file and relay it to the user */ -static void -check_for_client_reason(struct tls_multi *multi, const struct auth_deferred_status *status) -{ - struct gc_arena gc = gc_new(); - const char *msg = key_state_check_auth_failed_message_file(status, &gc); - if (msg) - { - auth_set_client_reason(multi, msg); - } - gc_free(&gc); -} /* * Verify the user name and password using a script */ _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
