[Openvpn-devel,v7,3/6] client-connect: Use inotify for the deferred client-connect status file

Message ID 20200716134315.17742-3-arne@rfc2549.org
State Superseded
Headers show
Series [Openvpn-devel,v7,1/6] client-connect: Add CC_RET_DEFERRED and cope with deferred client-connect | expand

Commit Message

Arne Schwabe July 16, 2020, 3:43 a.m. UTC
As we never do client-connect and authentication at the same time
it is safe to reuse the existing fields for client-connect return
status file

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
---
 src/openvpn/multi.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

Comments

Gert Doering July 16, 2020, 7:34 a.m. UTC | #1
Hi,

On Thu, Jul 16, 2020 at 03:43:12PM +0200, Arne Schwabe wrote:
> As we never do client-connect and authentication at the same time
> it is safe to reuse the existing fields for client-connect return
> status file

I don't have anything with inotify prepared right now, so I can't
really test this (it compiles *without* #define ENABLE_ASYNC_PUSH,
this I can already attest).

It would be good to have Lev test this very thoroughly...

gert

Patch

diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index e26daeea..60c2af09 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -2603,8 +2603,10 @@  multi_connection_established(struct multi_context *m, struct multi_instance *mi)
 
 #ifdef ENABLE_ASYNC_PUSH
 /*
- * Called when inotify event is fired, which happens when acf file is closed or deleted.
- * Continues authentication and sends push_reply.
+ * Called when inotify event is fired, which happens when acf
+ * or connect-status file is closed or deleted.
+ * Continues authentication and sends push_reply
+ * (or be deferred again by client-connect)
  */
 void
 multi_process_file_closed(struct multi_context *m, const unsigned int mpp_flags)
@@ -2890,7 +2892,15 @@  multi_process_post(struct multi_context *m, struct multi_instance *mi, const uns
             {
                 multi_connection_established(m, mi);
             }
-
+#if defined(ENABLE_ASYNC_PUSH) && defined(ENABLE_DEF_AUTH)
+            if (is_cas_pending(mi->context.c2.context_auth)
+                && mi->client_connect_defer_state.deferred_ret_file)
+            {
+                add_inotify_file_watch(m, mi, m->top.c2.inotify_fd,
+                                       mi->client_connect_defer_state.
+                                       deferred_ret_file);
+            }
+#endif
             /* tell scheduler to wake us up at some point in the future */
             multi_schedule_context_wakeup(m, mi);
         }