Fix sequence of events for async plugin v1 handler.
PATCH 1/2 Fix sequence of events for async plugin v1 handler.
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".
--- src/openvpn/multi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
src/openvpn/multi.c +7 -2
@@ -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);
Signature · 1 line
2.26.2
PATCH 2/2 Abort client-connect handler loop after first handler sets 'disable'.
The old code would run all (succeeding) handlers, then discover "one of them set the 'disable' flag for this client", and then unroll all the handlers.
Moving the 'disable' check into the loop makes it stop after the first handler that fails or (succeeds and sets 'disable'). This is a bit more logical in the log files, and has less potential side effects due to running "later" client-connect handlers when we already know they will have to be unrolled.
--- src/openvpn/multi.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
src/openvpn/multi.c +11 -11
@@ -2617,18 +2617,18 @@ multi_connection_established(struct multi_context *m, struct multi_instance *mi)ASSERT (0 ); } - (*cur_handler_index)++; - } +/* +* Check for "disable" directive in client-config-dir file +* or config file generated by --client-connect script. +*/ +if (mi->context.options.disable) + { +msg (D_MULTI_ERRORS ,"MULTI: client has been rejected due to " +"'disable' directive" ); + cc_succeeded = false; + } -/* -* Check for "disable" directive in client-config-dir file -* or config file generated by --client-connect script. -*/ -if (mi->context.options.disable) - { -msg (D_MULTI_ERRORS ,"MULTI: client has been rejected due to " -"'disable' directive" ); - cc_succeeded = false; + (*cur_handler_index)++; }if (cc_succeeded)
Signature · 1 line
2.26.2
Am 27.07.20 um 20:34 schrieb Gert Doering:
Quoted 8 lines
If
multi_client_connect_call_plugin_v1()goes to "deferred mode", *and* there is noOPENVPN_CLIENT_CONNECT_DEFERhandler, we would read the "client specific options" file after every (succeeded-because-not-present) call toplugin_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.
Re: [Openvpn-devel] [PATCH 2/2] Abort client-connect handler loop after first handler sets 'disable'.
In reply to Gert DoeringAm 27.07.20 um 20:34 schrieb Gert Doering:
Quoted 11 lines
The old code would run all (succeeding) handlers, then discover "one of them set the 'disable' flag for this client", and then unroll all the handlers.
Moving the 'disable' check into the loop makes it stop after the first handler that fails or (succeeds and sets 'disable'). This is a bit more logical in the log files, and has less potential side effects due to running "later" client-connect handlers when we already know they will have to be unrolled.
Signed-off-by Gert Doering <[email protected]...>
This another of the 'review is easy if you ignore white space' patches. This slightly changes the behaviour but I don't see a problem with the behaviour change to abort early.
[Openvpn-devel] [PATCH applied] Re: Abort client-connect handler loop after first handler sets 'disable'.
In reply to Gert DoeringPatch has been applied to the master branch.
commit 20b394746a7a351d892bb8c21beb66dd138631d9
Author: Gert Doering Date: Mon Jul 27 20:34:36 2020 +0200
Abort client-connect handler loop after first handler sets 'disable'.
Signed-off-by: Gert Doering <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg20612.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
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 <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg20613.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering