tun.c: enable using wintun driver under SYSTEM
PATCH 1/1 tun.c: enable using wintun driver under SYSTEM
From: Lev Stipakov <[email protected]...>
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
--- src/openvpn/tun.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-)
src/openvpn/tun.c +25 -5
@@ -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; }
Signature · 1 line
2.17.1
Hi,
Quoted 62 lines · Lev Stipakov
From: Lev Stipakov <[email protected]...>
Commit
6d19775a468has 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 <[email protected]...>--- src/openvpn/tun.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-)src/openvpn/tun.c +0
-1@@ -6158,12 +6158,32 @@ wintun_register_ring_buffer(struct tuntap *tt, const char *device_guid) }else { - msg(M_FATAL, "ERROR: Wintun requires SYSTEM privileges andtherefore "
- "should be used with interactive service. If you
want to "
- "use openvpn from command line, you need to do
SYSTEM "src/openvpn/tun.c +10
-2- "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 SYSTEMprivileges 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).");src/openvpn/tun.c +4
-0+break ; + +case ERROR_ALREADY_INITIALIZED : + msg(M_NONFATAL, "Adapter %s is already in use",
device_guid);src/openvpn/tun.c +3
-0+break ; +default : + msg(M_NONFATAL | M_ERRNO, "Failed to register ringbuffers");
src/openvpn/tun.c wintun_register_ring_buffer(struct tuntap *tt, const char *device_guid) · line 6188
Quoted 7 lines
src/openvpn/tun.c +5
-0+ } + ret = false; + } + + }return ret; }
Looks good and running as SYSTEM works now as expected. Tested on 64 bit Windows 10.
Hi,
When will this be available as an installable (beta) msi?
Marvin
Quoted 69 lines · Selva Nair
Hi,
Quoted 47 lines · Lev Stipakov
From: Lev Stipakov <[email protected]...>
Commit
6d19775a468has 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 <[email protected]...>--- src/openvpn/tun.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-)src/openvpn/tun.c +18
-5@@ -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 ;src/openvpn/tun.c wintun_register_ring_buffer(struct tuntap *tt, const char *device_guid) · line 6188
Quoted 10 lines
src/openvpn/tun.c +7
-0+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.
Acked-by [email protected]..._______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Hi,
Quoted 1 line · Marvin Adeff
When will this be available as an installable (beta) msi?
I'll merge the commit today or tomorrow (sorry for the lag on my side, was travelling and had only limited access to "Internet and focus").
My plan is to do a formal "beta2" tag on Wednesday, but of course Samuli/Lev could do a new installer ("beta1_1") earlier.
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...No need to rush. I’m happy to wait until Wednesday for beta2.
Cheers,
Marvin
Sent from my iPhone
Quoted 21 lines · Gert Doering
Hi,
Quoted 2 lines · Marvin Adeff
When will this be available as an installable (beta) msi?
I'll merge the commit today or tomorrow (sorry for the lag on my side, was travelling and had only limited access to "Internet and focus").
My plan is to do a formal "beta2" tag on Wednesday, but of course Samuli/Lev could do a new installer ("
beta1_1") earlier.gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you feed honest figures into a computer, honest figures come out. Never doubted it myself till I met a computer with a sense of humor." Robert A. Heinlein, The Moon is a Harsh Mistress Gert Doering - Munich, Germany [email protected]...
Your patch has been applied to the master and release/2.5 branch.
(I have not tested anything, but diffing tun.c to 6d19775a468~1 shows that's it is the same code that was removed, except for a more detailed error message)
commit ed47c097db63f8334f32bf9482da488928ff909b (master) commit f4761dd12ec5eb10a5897ecb7dc427f54a9b0769 (release/2.5)
Author: Lev Stipakov Date: Wed Aug 19 10:07:46 2020 +0300
tun.c: enable using wintun driver under SYSTEM
Signed-off-by: Lev Stipakov <[email protected]...>
Acked-by: Selva Nair <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg20780.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering