Skip to contentSkip to conversation

operations that still require elevation on windows

Openvpn-devel Selva Nair 2 participants 5 messages Mar 6, 2016 – Mar 7, 2016

lore
Share & tools
lore

Selva Nair

author
#0 lore raw

Hi,

There at least two more things on windows that the interactive service has to support:

(i) register-dns
(ii) ipv6 address and route setup

Is there anything else? For (ii) can't it be done using the IP Helper API on vista+ -- is the use of net command required? If not, it should be easy to delegate it to the service.

Thanks,

Selva

#1 lore raw

Hi,

Quoted 4 lines · Selva Nair

There at least two more things on windows that the interactive service has to support:

(i) register-dns

Indeed, this seems to be missing today.

Quoted 5 lines

(ii) ipv6 address and route setup

Is there anything else? For (ii) can't it be done using the IP Helper API on vista+ -- is the use of net command required? If not, it should be easy to delegate it to the service.

... but this should all be nicely done...?

tun.c, around line 1390:

        if (tt->options.msg_channel)
          {
            do_address_service (true, AF_INET6, tt);
          }
        else
          {
            /* example: netsh interface ipv6 set address interface=42 2001:608:8

003::d store=active */

and route.c, add_route_ipv6()

...
#elif defined (WIN32)

if (tt->options.msg_channel)

    status = add_route_ipv6_service (r6, tt);

else
...

Looking at interactive.c, "HandleAddressMessage()" uses CreateUnicastIpAddressEntry(), which according to my reading of MSDN supports IPv4 and IPv6. It's filled using "sockaddr_inet()", which actually does IPv4 and IPv6 even if the name doesn't suggest so:

static SOCKADDR_INET
sockaddr_inet (short family, inet_address_t *addr) {
SOCKADDR_INET sa_inet;
ZeroMemory (&sa_inet, sizeof (sa_inet)); sa_inet.si_family = family;
if (family == AF_INET)

    sa_inet.Ipv4.sin_addr = addr->ipv4;
  else if (family == AF_INET6)
    sa_inet.Ipv6.sin6_addr = addr->ipv6;

return sa_inet;
}

So, we should be fine - and I'm fairly sure it actually works as one of my test cases was "unprivileged user, iservice, VPN tunnel has IPv6".

Now, I have no clue whether this might be a deprecated API, and something in the IP Helper API suite is "better" - just pointing out that we seem to be actually fine regarding IPv6 address and route.

(HandleRouteMessage() uses CreateIpForwardEntry2(), so that's also IPv4+IPv6)

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
author
#2 lore raw
Quoted 11 lines · Gert Doering
Quoted 1 line · Selva Nair

There at least two more things on windows that the interactive service

has

Quoted 3 lines

to support:

(i) register-dns

Indeed, this seems to be missing today.

Quoted 2 lines

(ii) ipv6 address and route setup

Quoted 7 lines
Quoted 1 line

Is there anything else? For (ii) can't it be done using the IP Helper

API

Quoted 1 line

on vista+ -- is the use of net command required? If not, it should be

easy

Quoted 1 line

to delegate it to the service.

... but this should all be nicely done...?

Oh, I missed that. Based on the Trac ticket (#71) discussion on fatal error after sleep-resume, which was apparently caused by netsh failures treated as FATAL, and seeing some comments that ipv6 setup needs to use netsh command, I just assumed this is not done. Sorry for jumping into that conclusion.

Then its only register-dns that remains...

Selva

#3 lore raw

Hi,

Quoted 5 lines · Selva Nair

Oh, I missed that. Based on the Trac ticket (#71) discussion on fatal error after sleep-resume, which was apparently caused by netsh failures treated as FATAL, and seeing some comments that ipv6 setup needs to use netsh command, I just assumed this is not done. Sorry for jumping into that conclusion.

Trac#71 is way before iservice was even on the horizon :-) - and yes, OpenVPN itself only uses netsh.exe today, "because this is all I had, back then on Windows XP".

When discussing iservice and IPv6, we decided "back then" that iservice should not care about WinXP - because we do not have the permission issues on XP anyway (it wasn't clear back then whether OpenVPN 2.4 would support XP or not, but we decided that we do not need XP support in the iservice).

Quoted 1 line

Then its only register-dns that remains...

Yep. Its semantics are not totally clear to me (the code does more, like turn off dns cache off/on) and I have no idea whether there's a real API for that...

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
author
#4 lore raw

Hi,

Quoted 5 lines · Gert Doering
Quoted 1 line

Then its only register-dns that remains...

Yep. Its semantics are not totally clear to me (the code does more, like turn off dns cache off/on) and I have no idea whether there's a real API for that...

Yes, it does much more than "ipconfig /registerdns": it restarts dns service, flushes the dns cache, and then does registerdns. Looks like someone decided to throw everything at it. In my own very limited tests I've never seen anything more than registerdns needed to get the DNS server registered. In fact, a manual "dhcp /renew" after the connection comes up also appears to do the job: this is not the same as the --dhcp-renew option, though.

But I haven't tested any of this beyond a single windows 7 machine, so cant say for use that ipconfig /registerdns or dhcp renew is enough. Considering that many folks appear to be dependent on this option, we have to keep it as is, I guess.

AFAIK, there is no API for either of these. There are some undocumented calls like DnsFlushReseolverCache in dnsapi.dll but there are no official docs on them. The service can be started and restarted using API but its no less pain than using "net stop" and "net start"

I suppose we need to just queue this request to the service and let it do it asynchronously in a separate thread. Which is not very unlike the current fork_to_self approach. It shouldn't be hard to add that to interactive.c

Selva