]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Introduce management client state for AUTH_PENDING notifications
authorArne Schwabe <arne@rfc2549.org>
Mon, 25 Jan 2021 12:56:21 +0000 (13:56 +0100)
committerGert Doering <gert@greenie.muc.de>
Sun, 14 Feb 2021 15:53:21 +0000 (16:53 +0100)
This allows a UI client to display the correct state. Technically the
client is still waiting for PUSH_REPLY but for every practical concern
this is a different state as we are waiting for the pending
authentication to finish.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20210125125628.30364-5-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21498.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/manage.c
src/openvpn/manage.h
src/openvpn/push.c

index ed9dde1ecd945537059f1816b420ab1f2e5cf51c..169e645fb3004b9c26814aa1141e02b46c3e8742 100644 (file)
@@ -169,6 +169,9 @@ man_state_name(const int state)
         case OPENVPN_STATE_TCP_CONNECT:
             return "TCP_CONNECT";
 
+        case OPENVPN_STATE_AUTH_PENDING:
+            return "AUTH_PENDING";
+
         default:
             return "?";
     }
index a3364644e336dc809756fcbbed048626c424a393..9797842b8001ffe9b471ff8b6922502d3aa454ec 100644 (file)
@@ -492,6 +492,8 @@ management_enable_def_auth(const struct management *man)
 #define OPENVPN_STATE_GET_CONFIG    9  /* Downloading configuration from server */
 #define OPENVPN_STATE_RESOLVE       10 /* DNS lookup */
 #define OPENVPN_STATE_TCP_CONNECT   11 /* Connecting to TCP server */
+#define OPENVPN_STATE_AUTH_PENDING  12 /* Waiting in auth-pending mode
+                                        * technically variant of GET_CONFIG */
 
 #define OPENVPN_STATE_CLIENT_BASE   7  /* Base index of client-only states */
 
index 2ceee2c448d1189757b6bc39d0c922775c5d6dfc..9a67e03620384789ac5087f720f7afcf280685c7 100644 (file)
@@ -248,12 +248,30 @@ parse_auth_pending_keywords(const struct buffer *buffer,
     if (!buf_advance(&buf, strlen("AUTH_PENDING"))
         || !(buf_read_u8(&buf) == ',') || !BLEN(&buf))
     {
+#ifdef ENABLE_MANAGEMENT
+        if (management)
+        {
+            management_set_state(management, OPENVPN_STATE_AUTH_PENDING,
+                                 "", NULL, NULL, NULL, NULL);
+        }
+#endif
+
         return;
     }
 
     /* parse the keywords in the same way that push options are parsed */
     char line[OPTION_LINE_SIZE];
 
+#ifdef ENABLE_MANAGEMENT
+    /* Need to do the management notification with the keywords before
+     * buf_parse is called, as it will insert \0 bytes into the buffer */
+    if (management)
+    {
+        management_set_state(management, OPENVPN_STATE_AUTH_PENDING,
+                             BSTR(&buf), NULL, NULL, NULL, NULL);
+    }
+#endif
+
     while (buf_parse(&buf, ',', line, sizeof(line)))
     {
         if (sscanf(line, "timeout %u", server_timeout) != 1)