Change in openvpn[release/2.6]: win: replace wmic invocation with powershell
A message that is not in the archive (sent off-list or not yet received): gerrit.1757504119000.Ie135e070b481b88033c43b76f872060fb237243c@...2715...
Attention is currently required from: flichtenheld, plaisthos.
Hello plaisthos, flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1175?usp=email
to review the following change.
Change subject: win: replace wmic invocation with powershell
......................................................................
win: replace wmic invocation with powershell
Since wmic has been recently deprecated and is absent on new systems, replace setting DNS domain "old-style" with powershell.
GitHub: https://github.com/OpenVPN/openvpn/issues/642
---
M src/openvpn/tun.c
M src/openvpn/win32.h
2 files changed, 14 insertions(+), 9 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/75/1175/1
src/openvpn/tun.c +13 -8
@@ -383,7 +383,7 @@ }static void -do_dns_domain_wmic (bool add,const struct tuntap *tt) +do_dns_domain_pwsh (bool add,const struct tuntap *tt) {if (!tt->options.domain) {
@@ -391,9 +391,14 @@ }struct argv argv =argv_new (); -argv_printf (&argv,"%s%s nicconfig where (InterfaceIndex=%ld) call SetDNSDomain '%s'" , -get_win_sys_path (),WMIC_PATH_SUFFIX , tt->adapter_index, add ? tt->options.domain :"" ); -exec_command ("WMIC" , &argv,1 ,M_WARN ); +argv_printf (&argv, +"%s%s -NoProfile -NonInteractive -Command Set-DnsClient -InterfaceIndex %ld -ConnectionSpecificSuffix '%s'" , +get_win_sys_path (), +POWERSHELL_PATH_SUFFIX , + tt->adapter_index, + add ? tt->options.domain :"" + ); +exec_command ("PowerShell" , &argv,1 ,M_WARN );argv_free (&argv); }
@@ -1269,7 +1274,7 @@if (!tt->did_ifconfig_setup) { -do_dns_domain_wmic (true, tt); +do_dns_domain_pwsh (true, tt); } }#else /* platforms we have no IPv6 code for */
@@ -1625,7 +1630,7 @@ tt->adapter_netmask, NI_IP_NETMASK | NI_OPTIONS); } -do_dns_domain_wmic (true, tt); +do_dns_domain_pwsh (true, tt); }
@@ -7024,7 +7029,7 @@ {if (!tt->did_ifconfig_setup) { -do_dns_domain_wmic (false, tt); +do_dns_domain_pwsh (false, tt); }netsh_delete_address_dns (tt, true, &gc);
@@ -7050,7 +7055,7 @@ }else { -do_dns_domain_wmic (false, tt); +do_dns_domain_pwsh (false, tt);if (tt->options.ip_win32_type ==IPW32_SET_NETSH ) {
src/openvpn/win32.h +1 -1
@@ -38,7 +38,7 @@#define WIN_ROUTE_PATH_SUFFIX "\\system32\\route.exe"#define WIN_IPCONFIG_PATH_SUFFIX "\\system32\\ipconfig.exe"#define WIN_NET_PATH_SUFFIX "\\system32\\net.exe" -#define WMIC_PATH_SUFFIX "\\system32\\wbem\\wmic.exe" +#define POWERSHELL_PATH_SUFFIX "\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"/* * Win32-specific OpenVPN code, targeted at the mingw
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1175?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: Ie135e070b481b88033c43b76f872060fb237243c
Gerrit-Change-Number: 1175
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld, plaisthos, stipa.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1175?usp=email )
Change subject: win: replace wmic invocation with powershell
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
What about the wmic invocation in the (2.6) service?
``` Your branch is up to date with 'stable/release/2.6'. [email protected]...:/home/gert/src/openvpn-maint/openvpn$ git grep wmic.exe src/openvpn/win32.h:#define WMIC_PATH_SUFFIX "\\system32\\wbem\\wmic.exe" src/openvpnserv/interactive.c: openvpn_swprintf(argv0, _countof(argv0), L"%ls\\%ls", get_win_sys_path(), L"wbem\\wmic.exe"); ```
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1175?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: Ie135e070b481b88033c43b76f872060fb237243c
Gerrit-Change-Number: 1175
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Wed, 10 Sep 2025 20:43:01 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: plaisthos, stipa.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1175?usp=email )
Change subject: win: replace wmic invocation with powershell
......................................................................
Patch Set 1: Code-Review-1
(1 comment)
Patchset:
PS1:
Since Gert did not mark this as needing work, doing so now.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1175?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: Ie135e070b481b88033c43b76f872060fb237243c
Gerrit-Change-Number: 1175
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Fri, 12 Sep 2025 13:24:12 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
stipa has abandoned this change. ( http://gerrit.openvpn.net/c/openvpn/+/1175?usp=email )
Change subject: win: replace wmic invocation with powershell
......................................................................
Abandoned
Superseded by 1183
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1175?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: Ie135e070b481b88033c43b76f872060fb237243c
Gerrit-Change-Number: 1175
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: abandon