[Openvpn-devel] Separate handling of non-deferred return values for client-connect-scripts.

Message ID 20200720070802.18819-1-gert@greenie.muc.de
State Accepted
Headers show
Series
  • [Openvpn-devel] Separate handling of non-deferred return values for client-connect-scripts.
Related show

Commit Message

Gert Doering July 20, 2020, 7:08 a.m.
(Only) on "CC_RET_SUCCESS", run multi_client_connect_post().

On "CC_RET_FAILURE", add missing log line, do not call ..._post().

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

Comments

Arne Schwabe July 20, 2020, 9:21 a.m. | #1
Am 20.07.20 um 09:08 schrieb Gert Doering:
> (Only) on "CC_RET_SUCCESS", run multi_client_connect_post().
> 
> On "CC_RET_FAILURE", add missing log line, do not call ..._post().
> 
> Signed-off-by: Gert Doering <gert@greenie.muc.de>
> ---
>  src/openvpn/multi.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
> index 08112c98..e99de713 100644
> --- a/src/openvpn/multi.c
> +++ b/src/openvpn/multi.c
> @@ -2139,13 +2139,19 @@ multi_client_connect_script_deferred(struct multi_context *m,
>          ret = CC_RET_DEFERRED;
>      }
>  
> -    if (ret != CC_RET_DEFERRED)
> +    if (ret == CC_RET_SUCCEEDED)
>      {
>          ccs_delete_deferred_ret_file(mi);
>          multi_client_connect_post(m, mi, ccs->config_file,
>                                    option_types_found);
>          ccs_delete_config_file(mi);
>      }
> +    if (ret == CC_RET_FAILED)
> +    {
> +	msg(M_INFO, "MULTI: deferred --client-connect script returned CC_RET_FAILED");
> +        ccs_delete_deferred_ret_file(mi);
> +        ccs_delete_config_file(mi);
> +    }
>      return ret;
>  }

Looks good to me. Reading the config file on failed should not hurt but
is a very weird thing to do.

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

commit 3658e57797656e63e35be65397101a7191897272
Author: Gert Doering
Date:   Mon Jul 20 09:08:02 2020 +0200

     Separate handling of non-deferred return values for client-connect-scripts.

     Signed-off-by: Gert Doering <gert@greenie.muc.de>
     Acked-by: Arne Schwabe <arne@rfc2549.org>
     Message-Id: <20200720070802.18819-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20488.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 08112c98..e99de713 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -2139,13 +2139,19 @@  multi_client_connect_script_deferred(struct multi_context *m,
         ret = CC_RET_DEFERRED;
     }
 
-    if (ret != CC_RET_DEFERRED)
+    if (ret == CC_RET_SUCCEEDED)
     {
         ccs_delete_deferred_ret_file(mi);
         multi_client_connect_post(m, mi, ccs->config_file,
                                   option_types_found);
         ccs_delete_config_file(mi);
     }
+    if (ret == CC_RET_FAILED)
+    {
+	msg(M_INFO, "MULTI: deferred --client-connect script returned CC_RET_FAILED");
+        ccs_delete_deferred_ret_file(mi);
+        ccs_delete_config_file(mi);
+    }
     return ret;
 }