Content-Type: multipart/alternative; boundary=Apple-Mail-9D0E0245-5F2D-4BBB-8E35-22FA072A63AC Mime-Version: 1.0 (1.0) From: Marvin Adeff In-Reply-To: Date: Fri, 21 Aug 2020 19:37:27 -0700 Content-Transfer-Encoding: 7bit Message-Id: <5BBA3889-D486-40CA-A651-78F19FD1463B@...277...> References: <20200819070746.197-1-lstipakov@...277...> Subject: Re: [Openvpn-devel] [PATCH] tun.c: enable using wintun driver under SYSTEM List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Selva Nair Cc: Lev Stipakov , Lev Stipakov , openvpn-devel --Apple-Mail-9D0E0245-5F2D-4BBB-8E35-22FA072A63AC Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, When will this be available as an installable (beta) msi? Marvin=20 > On Aug 21, 2020, at 2:13 PM, Selva Nair wrote: >=20 > Hi, >=20 >> On Wed, Aug 19, 2020 at 3:08 AM Lev Stipakov wrote: >> From: Lev Stipakov >>=20 >> Commit 6d19775a468 has removed SYSTEM elevation hack, >> but introduced regression - inability to use wintun without interactive = service. >>=20 >> Proceed with ring buffers registration even if iservice is unavailable a= nd display >> relevant error message. >>=20 >> Trac #1318 >>=20 >> Signed-off-by: Lev Stipakov >> --- >> src/openvpn/tun.c | 30 +++++++++++++++++++++++++----- >> 1 file changed, 25 insertions(+), 5 deletions(-) >>=20 >> diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c >> index 30454454..62557364 100644 >> --- a/src/openvpn/tun.c >> +++ b/src/openvpn/tun.c >> @@ -6158,12 +6158,32 @@ wintun_register_ring_buffer(struct tuntap *tt, c= onst char *device_guid) >> } >> else >> { >> - msg(M_FATAL, "ERROR: Wintun requires SYSTEM privileges and the= refore " >> - "should be used with interactive service. If you w= ant to " >> - "use openvpn from command line, you need to do SYS= TEM " >> - "elevation yourself (for example with psexec)."); >> - } >> + if (!register_ring_buffers(tt->hand, >> + tt->wintun_send_ring, >> + tt->wintun_receive_ring, >> + tt->rw_handle.read, >> + tt->rw_handle.write)) >> + { >> + switch (GetLastError()) >> + { >> + case ERROR_ACCESS_DENIED: >> + msg(M_FATAL, "ERROR: Wintun requires SYSTEM privil= eges and therefore " >> + "should be used with interactive servi= ce. If you want to " >> + "use openvpn from command line, you ne= ed to do SYSTEM " >> + "elevation yourself (for example with = psexec)."); >> + break; >> + >> + case ERROR_ALREADY_INITIALIZED: >> + msg(M_NONFATAL, "Adapter %s is already in use", dev= ice_guid); >> + break; >>=20 >> + default: >> + msg(M_NONFATAL | M_ERRNO, "Failed to register ring = buffers"); >> + } >> + ret =3D false; >> + } >> + >> + } >> return ret; >> } >=20 > Looks good and running as SYSTEM works now as expected. Tested on 64 bit = Windows 10. >=20 > Acked-by: selva.nair@...277...=20 > _______________________________________________ > Openvpn-devel mailing list > Openvpn-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openvpn-devel --Apple-Mail-9D0E0245-5F2D-4BBB-8E35-22FA072A63AC Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit Hi,

When will this be available as an installable (beta) msi?

Marvin 

On Aug 21, 2020, at 2:13 PM, Selva Nair <selva.nair@...277...> wrote:

Hi,

On Wed, Aug 19, 2020 at 3:08 AM Lev Stipakov <lstipakov@...277...> wrote:
From: Lev Stipakov <lev@...515...>

Commit 6d19775a468 has removed SYSTEM elevation hack,
but introduced regression - inability to use wintun without interactive service.

Proceed with ring buffers registration even if iservice is unavailable and display
relevant error message.

Trac #1318

Signed-off-by: Lev Stipakov <lev@...515...>
---
 src/openvpn/tun.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index 30454454..62557364 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -6158,12 +6158,32 @@ wintun_register_ring_buffer(struct tuntap *tt, const char *device_guid)
     }
     else
     {
-        msg(M_FATAL, "ERROR:  Wintun requires SYSTEM privileges and therefore "
-                     "should be used with interactive service. If you want to "
-                     "use openvpn from command line, you need to do SYSTEM "
-                     "elevation yourself (for example with psexec).");
-    }
+        if (!register_ring_buffers(tt->hand,
+                                   tt->wintun_send_ring,
+                                   tt->wintun_receive_ring,
+                                   tt->rw_handle.read,
+                                   tt->rw_handle.write))
+        {
+            switch (GetLastError())
+            {
+                case ERROR_ACCESS_DENIED:
+                    msg(M_FATAL, "ERROR:  Wintun requires SYSTEM privileges and therefore "
+                                 "should be used with interactive service. If you want to "
+                                 "use openvpn from command line, you need to do SYSTEM "
+                                 "elevation yourself (for example with psexec).");
+                    break;
+
+                case ERROR_ALREADY_INITIALIZED:
+                    msg(M_NONFATAL, "Adapter %s is already in use", device_guid);
+                    break;

+                default:
+                    msg(M_NONFATAL | M_ERRNO, "Failed to register ring buffers");
+            }
+            ret = false;
+        }
+
+    }
     return ret;
 }

Looks good and running as SYSTEM works now as expected. Tested on 64 bit Windows 10.

_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
--Apple-Mail-9D0E0245-5F2D-4BBB-8E35-22FA072A63AC--