[Openvpn-devel,1/2] Fix sequence of events for async plugin v1 handler.

Message ID 20200727183436.6625-1-gert@greenie.muc.de
State Accepted
Headers show
Series [Openvpn-devel,1/2] Fix sequence of events for async plugin v1 handler. | expand

Commit Message

Gert Doering July 27, 2020, 8:34 a.m. UTC
If multi_client_connect_call_plugin_v1() goes to "deferred mode",
*and* there is no OPENVPN_CLIENT_CONNECT_DEFER handler, we
would read the "client specific options" file after every
(succeeded-because-not-present) call to plugin_call().

Move this to "after we have checked the deferred-cc file, and we
know for sure that we have CC_RET_SUCCEEDED".

Signed-off-by: Gert Doering <gert@greenie.muc.de>
---
 src/openvpn/multi.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Arne Schwabe July 27, 2020, 10:54 a.m. UTC | #1
Am 27.07.20 um 20:34 schrieb Gert Doering:
> If multi_client_connect_call_plugin_v1() goes to "deferred mode",
> *and* there is no OPENVPN_CLIENT_CONNECT_DEFER handler, we
> would read the "client specific options" file after every
> (succeeded-because-not-present) call to plugin_call().
> 
> Move this to "after we have checked the deferred-cc file, and we
> know for sure that we have CC_RET_SUCCEEDED".
> 

Not tested but the code change and explaination are sound.

Acked-By: Arne Schwabe <arne@rfc2549.org>
Gert Doering July 27, 2020, 9:46 p.m. UTC | #2
Patch has been applied to the master branch.

(I have tested this on the "t_server" test rig, of course :) )

commit 08f3c1cab7367fc8447001db34fd9627d60ba2b2
Author: Gert Doering
Date:   Mon Jul 27 20:34:35 2020 +0200

     Fix sequence of events for async plugin v1 handler.

     Signed-off-by: Gert Doering <gert@greenie.muc.de>
     Acked-by: Arne Schwabe <arne@rfc2549.org>
     Message-Id: <20200727183436.6625-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20613.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index 9bda38b0..cfb34720 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -2065,8 +2065,6 @@  multi_client_connect_call_plugin_v1(struct multi_context *m,
                                    &argv, NULL, mi->context.c2.es);
         if (plug_ret == OPENVPN_PLUGIN_FUNC_SUCCESS)
         {
-            multi_client_connect_post(m, mi, ccs->config_file,
-                                      option_types_found);
             ret = CC_RET_SUCCEEDED;
         }
         else if (plug_ret == OPENVPN_PLUGIN_FUNC_DEFERRED)
@@ -2100,6 +2098,13 @@  multi_client_connect_call_plugin_v1(struct multi_context *m,
         {
             ret = CC_RET_DEFERRED;
         }
+
+        /* if we still think we have succeeded, do postprocessing */
+        if (ret == CC_RET_SUCCEEDED)
+        {
+            multi_client_connect_post(m, mi, ccs->config_file,
+                                      option_types_found);
+        }
 cleanup:
         argv_free(&argv);