[Openvpn-devel,v1] options: let the interactive service add routes again

Message ID 20261118181613.2865-1-gert@greenie.muc.de
State New
Headers
Series [Openvpn-devel,v1] options: let the interactive service add routes again |

Commit Message

Gert Doering Nov. 18, 2026, 6:16 p.m. UTC
  From: Heiko Hund <heiko@ist.eigentlich.net>

Since c139e82d the service puts --msg-channel in front of the user
options, a --route-method from the config overrides the service
route method implicitly set by --msg-channel, and adding routes
in turn fails without admin rights.

Force the service route method in postprocessing when --msg-channel is
used, independent of the option order.

Github: OpenVPN/openvpn#1151
Change-Id: I4571033af79092d85657b176044497245faf5e39
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Razvan Cojocaru <razvanc@mailbox.org>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2219
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2219
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Razvan Cojocaru <razvanc@mailbox.org>
  

Patch

diff --git a/doc/man-sections/windows-options.rst b/doc/man-sections/windows-options.rst
index 8d7dcbb..87c7008 100644
--- a/doc/man-sections/windows-options.rst
+++ b/doc/man-sections/windows-options.rst
@@ -179,6 +179,10 @@ 
   :code:`exe`
         Call the route.exe shell command.
 
+  When OpenVPN is started by the interactive service, the service adds
+  the routes and a ``--route-method`` given in the configuration is
+  ignored.
+
 --service args
   Should be used when OpenVPN is being automatically executed by another
   program in such a context that no interaction with the user via display
diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index 947439d..09a9d522 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -2494,6 +2494,14 @@ 
         options->ifconfig_noexec = false;
     }
 
+    /* the service adds the routes, --route-method must not override it */
+    if (options->msg_channel && options->route_method != ROUTE_METHOD_SERVICE)
+    {
+        msg(M_WARN, "WARNING: ignoring --route-method, routes are added by the interactive service");
+        options->route_method = ROUTE_METHOD_SERVICE;
+    }
+
+    /* this depends on options->route_method, which is set above */
     remap_redirect_gateway_flags(options);
 
     /*