Attention is currently required from: Arne Schwabe.

Hello Arne Schwabe,

I'd like you to do a code review.
Please visit

    https://gerrit.openvpn.net/c/openvpn/+/2217?usp=email

to review the following change.


Change subject: ssl_verify: use check_for_client_reason() in 
tls_authentication_status()
......................................................................

ssl_verify: use check_for_client_reason() in tls_authentication_status()

tls_authentication_status() open-coded check_for_client_reason() for
the plugin and script auth status. Move the helper up and call it.

Change-Id: Ia48c1efc9a687383a1dc87edd49d8ba3eb5a87ad
Signed-off-by: Razvan Cojocaru <[email protected]>
---
M src/openvpn/ssl_verify.c
1 file changed, 17 insertions(+), 29 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/17/2217/1

diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_verify.c
index 8641d15..f121f0f 100644
--- a/src/openvpn/ssl_verify.c
+++ b/src/openvpn/ssl_verify.c
@@ -1159,6 +1159,21 @@
 static time_t cache_intervals[] = { 0, 0, 0, 0, 0, 1, 1, 2, 2, 4, 8 };

 /**
+ * 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);
+}
+
+/**
  * uses cache_intervals times to determine if we should update the
  * cache.
  */
@@ -1221,21 +1236,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 +1246,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 +1307,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
  */

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2217?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia48c1efc9a687383a1dc87edd49d8ba3eb5a87ad
Gerrit-Change-Number: 2217
Gerrit-PatchSet: 1
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to