Skip to contentSkip to conversation

Require AEAD support in the crypto library

PATCH In review Arne Schwabe 3 participants 5 messages Jul 20, 2020 – Aug 4, 2020 1 message not in the archive

lore
Share & tools
lore
#1 lore raw

PATCH v3 1/1 Require AEAD support in the crypto library

In reply to a message not in the archive

All supported crypto libraries have AEAD support and with our ncp/de facto default cipher AES-256-GCM we do not want to support the obscure corner case of a library with disabled AEAD.

Patch V2: Remove three instances of (harmless) #ifdef Steffan spotted
that can be removed now too.

---
 config-msvc.h                |  1 -
 configure.ac                 |  7 ++-----
 src/openvpn/crypto.c         | 11 -----------
 src/openvpn/crypto_mbedtls.c | 14 --------------
 src/openvpn/crypto_openssl.c | 26 ++------------------------
 src/openvpn/crypto_openssl.h |  4 ----
 src/openvpn/options.c        |  6 ------
 7 files changed, 4 insertions(+), 65 deletions(-)
config-msvc.h +0 -1
index 875da4a6..8ef48979 100644
@@ -5,7 +5,6 @@
 #define ENABLE_DEF_AUTH 1
 #define ENABLE_PF 1
 #define ENABLE_CRYPTO_OPENSSL 1
-#define HAVE_AEAD_CIPHER_MODES 1
 #define ENABLE_DEBUG 1
 #define ENABLE_EUREPHIA 1
 #define ENABLE_FRAGMENT 1
configure.ac +2 -5
index d1db0a21..43f78fb7 100644
@@ -907,11 +907,10 @@ if test "${with_crypto_library}" = "openssl"; then
 		AC_DEFINE([HAVE_OPENSSL_ENGINE], [1], [OpenSSL engine support available])
 	fi
 
-	have_crypto_aead_modes="yes"
 	AC_CHECK_FUNC(
 		[EVP_aes_256_gcm],
 		,
-		[have_crypto_aead_modes="no"]
+		[AC_MSG_ERROR([OpenSSL check for AES-256-GCM support failed])]
 	)
 
     # All supported OpenSSL version (>= 1.0.2)
@@ -1005,14 +1004,13 @@ elif test "${with_crypto_library}" = "mbedtls"; then
 		[AC_MSG_ERROR([mbed TLS 2.y.z required])]
 	)
 
-	have_crypto_aead_modes="yes"
 	AC_CHECK_FUNCS(
 		[ \
 			mbedtls_cipher_write_tag \
 			mbedtls_cipher_check_tag \
 		],
 		,
-		[have_crypto_aead_modes="no"; break]
+		[AC_MSG_ERROR([mbed TLS check for AEAD support failed])]
 	)
 
 	have_export_keying_material="yes"
@@ -1227,7 +1225,6 @@ test "${enable_pf}" = "yes" && AC_DEFINE([ENABLE_PF], [1], [Enable internal pack
 test "${enable_strict_options}" = "yes" && AC_DEFINE([ENABLE_STRICT_OPTIONS_CHECK], [1], [Enable strict options check between peers])
 
 test "${enable_crypto_ofb_cfb}" = "yes" && AC_DEFINE([ENABLE_OFB_CFB_MODE], [1], [Enable OFB and CFB cipher modes])
-test "${have_crypto_aead_modes}" = "yes" && AC_DEFINE([HAVE_AEAD_CIPHER_MODES], [1], [Use crypto library])
 if test "${have_export_keying_material}" = "yes"; then
 	AC_DEFINE(
 		[HAVE_EXPORT_KEYING_MATERIAL], [1],
src/openvpn/crypto.c +0 -11
index bbf47ef7..e92a0dc1 100644
@@ -64,7 +64,6 @@ static void
 openvpn_encrypt_aead(struct buffer *buf, struct buffer work,
                      struct crypto_options *opt)
 {
-#ifdef HAVE_AEAD_CIPHER_MODES
     struct gc_arena gc;
     int outlen = 0;
     const struct key_ctx *ctx = &opt->key_ctx_bi.encrypt;
@@ -152,9 +151,6 @@ err:
     buf->len = 0;
     gc_free(&gc);
     return;
-#else /* HAVE_AEAD_CIPHER_MODES */
-    ASSERT(0);
-#endif /* ifdef HAVE_AEAD_CIPHER_MODES */
 }
 
 static void
@@ -361,7 +357,6 @@ openvpn_decrypt_aead(struct buffer *buf, struct buffer work,
                      struct crypto_options *opt, const struct frame *frame,
                      const uint8_t *ad_start)
 {
-#ifdef HAVE_AEAD_CIPHER_MODES
     static const char error_prefix[] = "AEAD Decrypt error";
     struct packet_id_net pin = { 0 };
     const struct key_ctx *ctx = &opt->key_ctx_bi.decrypt;
@@ -482,10 +477,6 @@ error_exit:
     buf->len = 0;
     gc_free(&gc);
     return false;
-#else /* HAVE_AEAD_CIPHER_MODES */
-    ASSERT(0);
-    return false;
-#endif /* ifdef HAVE_AEAD_CIPHER_MODES */
 }
 
 /*
@@ -1104,7 +1095,6 @@ test_crypto(struct crypto_options *co, struct frame *frame)
     /* init work */
     ASSERT(buf_init(&work, FRAME_HEADROOM(frame)));
 
-#ifdef HAVE_AEAD_CIPHER_MODES
     /* init implicit IV */
     {
         const cipher_kt_t *cipher =
@@ -1126,7 +1116,6 @@ test_crypto(struct crypto_options *co, struct frame *frame)
             co->key_ctx_bi.decrypt.implicit_iv_len = impl_iv_len;
         }
     }
-#endif /* ifdef HAVE_AEAD_CIPHER_MODES */
 
     msg(M_INFO, "Entering " PACKAGE_NAME " crypto self-test mode.");
     for (i = 1; i <= TUN_MTU_SIZE(frame); ++i)
src/openvpn/crypto_mbedtls.c +0 -14
index bb752557..19a87eb4 100644
@@ -530,12 +530,10 @@ cipher_kt_block_size(const mbedtls_cipher_info_t *cipher_kt)
 int
 cipher_kt_tag_size(const mbedtls_cipher_info_t *cipher_kt)
 {
-#ifdef HAVE_AEAD_CIPHER_MODES
     if (cipher_kt && cipher_kt_mode_aead(cipher_kt))
     {
         return OPENVPN_AEAD_TAG_LENGTH;
     }
-#endif
     return 0;
 }
 
@@ -632,7 +630,6 @@ cipher_ctx_iv_length(const mbedtls_cipher_context_t *ctx)
 int
 cipher_ctx_get_tag(cipher_ctx_t *ctx, uint8_t *tag, int tag_len)
 {
-#ifdef HAVE_AEAD_CIPHER_MODES
     if (tag_len > SIZE_MAX)
     {
         return 0;
@@ -644,9 +641,6 @@ cipher_ctx_get_tag(cipher_ctx_t *ctx, uint8_t *tag, int tag_len)
     }
 
     return 1;
-#else  /* ifdef HAVE_AEAD_CIPHER_MODES */
-    ASSERT(0);
-#endif /* HAVE_AEAD_CIPHER_MODES */
 }
 
 int
@@ -688,7 +682,6 @@ cipher_ctx_reset(mbedtls_cipher_context_t *ctx, const uint8_t *iv_buf)
 int
 cipher_ctx_update_ad(cipher_ctx_t *ctx, const uint8_t *src, int src_len)
 {
-#ifdef HAVE_AEAD_CIPHER_MODES
     if (src_len > SIZE_MAX)
     {
         return 0;
@@ -700,9 +693,6 @@ cipher_ctx_update_ad(cipher_ctx_t *ctx, const uint8_t *src, int src_len)
     }
 
     return 1;
-#else  /* ifdef HAVE_AEAD_CIPHER_MODES */
-    ASSERT(0);
-#endif /* HAVE_AEAD_CIPHER_MODES */
 }
 
 int
@@ -741,7 +731,6 @@ int
 cipher_ctx_final_check_tag(mbedtls_cipher_context_t *ctx, uint8_t *dst,
                            int *dst_len, uint8_t *tag, size_t tag_len)
 {
-#ifdef HAVE_AEAD_CIPHER_MODES
     size_t olen = 0;
 
     if (MBEDTLS_DECRYPT != ctx->operation)
@@ -773,9 +762,6 @@ cipher_ctx_final_check_tag(mbedtls_cipher_context_t *ctx, uint8_t *dst,
     }
 
     return 1;
-#else  /* ifdef HAVE_AEAD_CIPHER_MODES */
-    ASSERT(0);
-#endif /* HAVE_AEAD_CIPHER_MODES */
 }
 
 void
src/openvpn/crypto_openssl.c +2 -24
index 161a189e..c47c2f3c 100644
@@ -301,9 +301,7 @@ show_available_ciphers(void)
 #ifdef ENABLE_OFB_CFB_MODE
                        || cipher_kt_mode_ofb_cfb(cipher)
 #endif
-#ifdef HAVE_AEAD_CIPHER_MODES
                        || cipher_kt_mode_aead(cipher)
-#endif
                        ))
         {
             cipher_list[num_ciphers++] = cipher;
@@ -710,11 +708,8 @@ bool
 cipher_kt_mode_cbc(const cipher_kt_t *cipher)
 {
     return cipher && cipher_kt_mode(cipher) == OPENVPN_MODE_CBC
-#ifdef EVP_CIPH_FLAG_AEAD_CIPHER
            /* Exclude AEAD cipher modes, they require a different API */
-           && !(EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER)
-#endif
-    ;
+           && !(EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER);
 }
 
 bool
@@ -722,17 +717,13 @@ cipher_kt_mode_ofb_cfb(const cipher_kt_t *cipher)
 {
     return cipher && (cipher_kt_mode(cipher) == OPENVPN_MODE_OFB
                       || cipher_kt_mode(cipher) == OPENVPN_MODE_CFB)
-#ifdef EVP_CIPH_FLAG_AEAD_CIPHER
            /* Exclude AEAD cipher modes, they require a different API */
-           && !(EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER)
-#endif
-    ;
+           && !(EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER);
 }
 
 bool
 cipher_kt_mode_aead(const cipher_kt_t *cipher)
 {
-#ifdef HAVE_AEAD_CIPHER_MODES
     if (cipher)
     {
         switch (EVP_CIPHER_nid(cipher))
@@ -746,7 +737,6 @@ cipher_kt_mode_aead(const cipher_kt_t *cipher)
                 return true;
         }
     }
-#endif
 
     return false;
 }
@@ -806,11 +796,7 @@ cipher_ctx_iv_length(const EVP_CIPHER_CTX *ctx)
 int
 cipher_ctx_get_tag(EVP_CIPHER_CTX *ctx, uint8_t *tag_buf, int tag_size)
 {
-#ifdef HAVE_AEAD_CIPHER_MODES
     return EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, tag_size, tag_buf);
-#else
-    ASSERT(0);
-#endif
 }
 
 int
@@ -841,16 +827,12 @@ cipher_ctx_reset(EVP_CIPHER_CTX *ctx, const uint8_t *iv_buf)
 int
 cipher_ctx_update_ad(EVP_CIPHER_CTX *ctx, const uint8_t *src, int src_len)
 {
-#ifdef HAVE_AEAD_CIPHER_MODES
     int len;
     if (!EVP_CipherUpdate(ctx, NULL, &len, src, src_len))
     {
         crypto_msg(M_FATAL, "%s: EVP_CipherUpdate() failed", __func__);
     }
     return 1;
-#else  /* ifdef HAVE_AEAD_CIPHER_MODES */
-    ASSERT(0);
-#endif
 }
 
 int
@@ -874,7 +856,6 @@ int
 cipher_ctx_final_check_tag(EVP_CIPHER_CTX *ctx, uint8_t *dst, int *dst_len,
                            uint8_t *tag, size_t tag_len)
 {
-#ifdef HAVE_AEAD_CIPHER_MODES
     ASSERT(tag_len < SIZE_MAX);
     if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, tag_len, tag))
     {
@@ -882,9 +863,6 @@ cipher_ctx_final_check_tag(EVP_CIPHER_CTX *ctx, uint8_t *dst, int *dst_len,
     }
 
     return cipher_ctx_final(ctx, dst, dst_len);
-#else  /* ifdef HAVE_AEAD_CIPHER_MODES */
-    ASSERT(0);
-#endif
 }
 
 void
src/openvpn/crypto_openssl.h +0 -4
index 4694ee08..e6f8f537 100644
@@ -61,13 +61,9 @@ typedef HMAC_CTX hmac_ctx_t;
 /** Cipher is in CFB mode */
 #define OPENVPN_MODE_CFB        EVP_CIPH_CFB_MODE
 
-#ifdef HAVE_AEAD_CIPHER_MODES
-
 /** Cipher is in GCM mode */
 #define OPENVPN_MODE_GCM        EVP_CIPH_GCM_MODE
 
-#endif /* HAVE_AEAD_CIPHER_MODES */
-
 /** Cipher should encrypt */
 #define OPENVPN_OP_ENCRYPT      1
 
src/openvpn/options.c +0 -6
index 04518bf5..94308a8e 100644
@@ -104,9 +104,7 @@ const char title_string[] =
     " [MH/RECVDA]"
 #endif
 #endif
-#ifdef HAVE_AEAD_CIPHER_MODES
     " [AEAD]"
-#endif
     " built on " __DATE__
 ;
 
@@ -871,11 +869,7 @@ init_options(struct options *o, const bool init_gc)
     o->scheduled_exit_interval = 5;
 #endif
     o->ciphername = "BF-CBC";
-#ifdef HAVE_AEAD_CIPHER_MODES /* IV_NCP=2 requires GCM support */
     o->ncp_enabled = true;
-#else
-    o->ncp_enabled = false;
-#endif
     o->ncp_ciphers = "AES-256-GCM:AES-128-GCM";
     o->authname = "SHA1";
     o->prng_hash = "SHA1";
Signature · 1 line
2.26.2
#3 lore raw

PATCH v7 1/1 client-connect: Add documentation for the deferred client connect feature

In reply to a message not in the archive

Patch V5: Fix typos, clarify man page section about deferred client-connect
script. Add section to Changes.rst

Patch V6: Convert manpage to rst

It also incoroporates suggested changes from Richard Bonhomme
<[email protected]...> [0]

[0] Message-ID: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg20331.html

Patch V7: Reinclude the changes of Changes.rst and openvpn-plugin.h
Clarify some parts of the documentation.

---
 Changes.rst                          |  5 +++++
 doc/man-sections/generic-options.rst | 11 ++++++----
 doc/man-sections/script-options.rst  | 33 ++++++++++++++++++++++++++++
 include/openvpn-plugin.h.in          | 21 +++++++++++++-----
 4 files changed, 60 insertions(+), 10 deletions(-)
Changes.rst +5 -0
index 34abcd97..78a66650 100644
@@ -25,6 +25,11 @@ Improved Data channel cipher negotiation
 Asynchronous (deferred) authentication support for auth-pam plugin.
     See src/plugins/auth-pam/README.auth-pam for details.
 
+Deferred client-connect
+    The ``--client-connect`` option and the connect plugin API allow
+    asynchronous/deferred return of the configuration file in the same way
+    as the auth-plugin.
+
 Deprecated features
 -------------------
 For an up-to-date list of all deprecated options, see this wiki page:
doc/man-sections/generic-options.rst +7 -4
index d44dc05f..a07fe7e7 100644
@@ -394,11 +394,14 @@ which mode OpenVPN is configured as.
 
   This directory will be used by in the following cases:
 
-  * ``--client-connect`` scripts to dynamically generate client-specific
-    configuration files.
+  * ``--client-connect`` scripts and :code:`OPENVPN_PLUGIN_CLIENT_CONNECT`
+    plug-in hook to dynamically generate client-specific configuration
+    :code:`client_connect_config_file` and return success/failure via
+    :code:`client_connect_deferred_file` when using deferred client connect
+    method
 
-  * :code:`OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY` plugin hook to return
-    success/failure via ``auth_control_file`` when using deferred auth
+  * :code:`OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY` plug-in hooks returns
+    success/failure via :code:`auth_control_file` when using deferred auth
     method
 
   * :code:`OPENVPN_PLUGIN_ENABLE_PF` plugin hook to pass filtering rules
doc/man-sections/script-options.rst +33 -0
index ddc1363c..a1d489b8 100644
@@ -137,6 +137,13 @@ SCRIPT HOOKS
   returns a non-zero error status, it will cause the client to be
   disconnected.
 
+  If a ``--client-connect`` wants to defer the generating of the
+  configuration then the script should use the
+  :code:`client_connect_deferred_file` and
+  :code:`client_connect_config_file` environment variables. And write
+  status accordingly into these files.  See the `Environmental Variables`_
+  section for more details.
+
 --client-disconnect cmd
   Like ``--client-connect`` but called on client instance shutdown. Will
   not be called unless the ``--client-connect`` script and plugins (if
@@ -512,6 +519,32 @@ instances.
     Total number of bytes sent to client during VPN session. Set prior to
     execution of the ``--client-disconnect`` script.
 
+:code:`client_connect_config_file`
+    The path to the configuration file that should be written by the
+    ``--client-connect`` script.  The content of this environment variable
+    is identical to the file as an argument of the called
+    ``--client-connect`` script.
+
+:code:`client_connect_deferred_file`
+    This file can be optionally written to to communicate a status code of
+    the ``--client-connect`` script.  The first character in the file must
+    be either :code:`1` to indicate normal script execution, :code:`0`
+    indicates an error (in the same way that a non zero exit status does)
+    or :code:`2` to indicate that the script deferred returning the config
+    file. When the script defers returning the configuration, it must also
+    write :code:`2` to the file to indicate the deferral.
+
+    A background process or similar must then take care of writing the
+    configuration to the file indicated by the
+    :code:`client_connect_config_file` environment variable and when
+    finished, write the a :code:`1` to this file (or :code:`0` in case of
+    an error).
+
+    The absence of any character in the file when the script finishes
+    executing is interpreted the same as :code:`1`. This allows scripts
+    that are not written to support the defer mechanism to be used
+    unmodified.
+
 :code:`common_name`
     The X509 common name of an authenticated client. Set prior to execution
     of ``--client-connect``, ``--client-disconnect`` and
include/openvpn-plugin.h.in +15 -6
index 38fbe097..64b20886 100644
@@ -557,12 +557,21 @@ OPENVPN_PLUGIN_DEF openvpn_plugin_handle_t OPENVPN_PLUGIN_FUNC(openvpn_plugin_op
  * OPENVPN_PLUGIN_FUNC_SUCCESS on success, OPENVPN_PLUGIN_FUNC_ERROR on failure
  *
  * In addition, OPENVPN_PLUGIN_FUNC_DEFERRED may be returned by
- * OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY.  This enables asynchronous
- * authentication where the plugin (or one of its agents) may indicate
- * authentication success/failure some number of seconds after the return
- * of the OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY handler by writing a single
- * char to the file named by auth_control_file in the environmental variable
- * list (envp).
+ * OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY, OPENVPN_PLUGIN_CLIENT_CONNECT and
+ * OPENVPN_PLUGIN_CLIENT_CONNECT_V2. This enables asynchronous
+ * authentication or client connect  where the plugin (or one of its agents)
+ * may indicate authentication success/failure or client configuration some
+ * number of seconds after the return of the function handler.
+ * For OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY and OPENVPN_PLUGIN_CLIENT_CONNECT
+ * this is done by writing a single char to the file named by
+ * auth_control_file/client_connect_deferred_file
+ * in the environmental variable list (envp).
+ *
+ * In addition the OPENVPN_PLUGIN_CLIENT_CONNECT_DEFER and
+ * OPENVPN_PLUGIN_CLIENT_CONNECT_DEFER_V2 are called when OpenVPN tries to
+ * get the deferred result. For a V2 call implementing this function is
+ * required as information is not passed by files. For the normal version
+ * the call is optional.
  *
  * first char of auth_control_file:
  * '0' -- indicates auth failure
Signature · 1 line
2.26.2
#4 lore raw

Re: [Openvpn-devel] [PATCH v7] client-connect: Add documentation for the deferred client connect feature

1x typo, 3x suggestions

Quoted 9 lines · Arne Schwabe

Patch V5: Fix typos, clarify man page section about deferred client-connect
script. Add section to Changes.rst

Patch V6: Convert manpage to rst

It also incoroporates suggested changes from Richard Bonhomme

incoroporates -> incorporates

Quoted 6 lines

<[email protected]...> [0]

[0] Message-ID: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg20331.html

Patch V7: Reinclude the changes of Changes.rst and openvpn-plugin.h

Reinclude -> Re-include (or maybe "Restore the lost changes of..")

Quoted 66 lines

Clarify some parts of the documentation.

---
  Changes.rst                          |  5 +++++
  doc/man-sections/generic-options.rst | 11 ++++++----
  doc/man-sections/script-options.rst  | 33 ++++++++++++++++++++++++++++
  include/openvpn-plugin.h.in          | 21 +++++++++++++-----
  4 files changed, 60 insertions(+), 10 deletions(-)
Changes.rst +5 -0
index 34abcd97..78a66650 100644
@@ -25,6 +25,11 @@ Improved Data channel cipher negotiation
  Asynchronous (deferred) authentication support for auth-pam plugin.
      See src/plugins/auth-pam/README.auth-pam for details.
 
+Deferred client-connect
+    The ``--client-connect`` option and the connect plugin API allow
+    asynchronous/deferred return of the configuration file in the same way
+    as the auth-plugin.
+
  Deprecated features
  -------------------
  For an up-to-date list of all deprecated options, see this wiki page:
doc/man-sections/generic-options.rst +7 -4
index d44dc05f..a07fe7e7 100644
@@ -394,11 +394,14 @@ which mode OpenVPN is configured as.
 
    This directory will be used by in the following cases:
 
-  * ``--client-connect`` scripts to dynamically generate client-specific
-    configuration files.
+  * ``--client-connect`` scripts and :code:`OPENVPN_PLUGIN_CLIENT_CONNECT`
+    plug-in hook to dynamically generate client-specific configuration
+    :code:`client_connect_config_file` and return success/failure via
+    :code:`client_connect_deferred_file` when using deferred client connect
+    method
 
-  * :code:`OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY` plugin hook to return
-    success/failure via ``auth_control_file`` when using deferred auth
+  * :code:`OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY` plug-in hooks returns
+    success/failure via :code:`auth_control_file` when using deferred auth
      method
 
    * :code:`OPENVPN_PLUGIN_ENABLE_PF` plugin hook to pass filtering rules
doc/man-sections/script-options.rst +7 -0
index ddc1363c..a1d489b8 100644
@@ -137,6 +137,13 @@ SCRIPT HOOKS
    returns a non-zero error status, it will cause the client to be
    disconnected.
 
+  If a ``--client-connect`` wants to defer the generating of the
+  configuration then the script should use the
+  :code:`client_connect_deferred_file` and
+  :code:`client_connect_config_file` environment variables. And write
+  status accordingly into these files.  See the `Environmental Variables`_
+  section for more details.
+
  --client-disconnect cmd
    Like ``--client-connect`` but called on client instance shutdown. Will
    not be called unless the ``--client-connect`` script and plugins (if

doc/man-sections/script-options.rst instances. · line 523

Quoted 5 lines
doc/man-sections/script-options.rst +2 -0
@@ -512,6 +519,32 @@ instances.
      Total number of bytes sent to client during VPN session. Set prior to
      execution of the ``--client-disconnect`` script.
 
+:code:`client_connect_config_file`
+    The path to the configuration file that should be written by the

suggest:
should be written by the ->
should be written to by the

doc/man-sections/script-options.rst instances. · line 529

Quoted 6 lines
doc/man-sections/script-options.rst +6 -0
+    ``--client-connect`` script.  The content of this environment variable
+    is identical to the file as an argument of the called
+    ``--client-connect`` script.
+
+:code:`client_connect_deferred_file`
+    This file can be optionally written to to communicate a status code of

suggest:
written to to communicate
written to in order to communicate

Quoted 54 lines
doc/man-sections/script-options.rst +18 -0
+    the ``--client-connect`` script.  The first character in the file must
+    be either :code:`1` to indicate normal script execution, :code:`0`
+    indicates an error (in the same way that a non zero exit status does)
+    or :code:`2` to indicate that the script deferred returning the config
+    file. When the script defers returning the configuration, it must also
+    write :code:`2` to the file to indicate the deferral.
+
+    A background process or similar must then take care of writing the
+    configuration to the file indicated by the
+    :code:`client_connect_config_file` environment variable and when
+    finished, write the a :code:`1` to this file (or :code:`0` in case of
+    an error).
+
+    The absence of any character in the file when the script finishes
+    executing is interpreted the same as :code:`1`. This allows scripts
+    that are not written to support the defer mechanism to be used
+    unmodified.
+
  :code:`common_name`
      The X509 common name of an authenticated client. Set prior to execution
      of ``--client-connect``, ``--client-disconnect`` and
include/openvpn-plugin.h.in +15 -6
index 38fbe097..64b20886 100644
@@ -557,12 +557,21 @@ OPENVPN_PLUGIN_DEF openvpn_plugin_handle_t OPENVPN_PLUGIN_FUNC(openvpn_plugin_op
   * OPENVPN_PLUGIN_FUNC_SUCCESS on success, OPENVPN_PLUGIN_FUNC_ERROR on failure
   *
   * In addition, OPENVPN_PLUGIN_FUNC_DEFERRED may be returned by
- * OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY.  This enables asynchronous
- * authentication where the plugin (or one of its agents) may indicate
- * authentication success/failure some number of seconds after the return
- * of the OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY handler by writing a single
- * char to the file named by auth_control_file in the environmental variable
- * list (envp).
+ * OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY, OPENVPN_PLUGIN_CLIENT_CONNECT and
+ * OPENVPN_PLUGIN_CLIENT_CONNECT_V2. This enables asynchronous
+ * authentication or client connect  where the plugin (or one of its agents)
+ * may indicate authentication success/failure or client configuration some
+ * number of seconds after the return of the function handler.
+ * For OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY and OPENVPN_PLUGIN_CLIENT_CONNECT
+ * this is done by writing a single char to the file named by
+ * auth_control_file/client_connect_deferred_file
+ * in the environmental variable list (envp).
+ *
+ * In addition the OPENVPN_PLUGIN_CLIENT_CONNECT_DEFER and
+ * OPENVPN_PLUGIN_CLIENT_CONNECT_DEFER_V2 are called when OpenVPN tries to
+ * get the deferred result. For a V2 call implementing this function is
+ * required as information is not passed by files. For the normal version
+ * the call is optional.
   *
   * first char of auth_control_file:
   * '0' -- indicates auth failure
#2 lore raw
In reply to Arne Schwabe

Quick sanity check on FreeBSD/1.0.2s, Linux/1.1.1g, Linux/mbedTLS (client side only). All good.

Your patch has been applied to the master branch.

commit 94edc7c5dd3cf8988df15fe4d7bd6cba9486b2a6

Author: Arne Schwabe
Date:   Mon Jul 20 14:17:04 2020 +0200
     Require AEAD support in the crypto library

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Steffan Karger <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg20506.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

Acked-by on v7 1/1
#5 lore raw

[Openvpn-devel] [PATCH applied] Re: client-connect: Add documentation for the deferred client connect feature

In reply to Arne Schwabe

The code is long in. I thought I'd see some review by "not me" on the docs, but since the 2.5_beta1 cutoff date is coming soon, I just did this now. Included all the latest suggestions from Richard as well.

I have reworded the "script-options.rst" section somewhat, because I found it a bit unclear in regards to "what does a script/plugin have to do, when?" - since I struggled with this, I now know :-)

Your patch has been applied to the master branch.

commit 71d56aea895cc13aad06048066251979162db3f3

Author: Arne Schwabe
Date:   Mon Jul 20 16:27:03 2020 +0200
     client-connect: Add documentation for the deferred client connect feature

     Signed-off-by: David Sommerseth <[email protected]...>
     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg20511.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering