From: "cron2 (Code Review)"
Date: Mon, 15 Sep 2025 20:28:06 +0000
In-Reply-To:
References:
Reply-To: gert@...1296..., arne-openvpn@...1227...,
openvpn-devel@lists.sourceforge.net, frank@...2641...,
lstipakov@...277...
Message-ID:
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="shODO1h7Ks8="; charset=UTF-8
Subject: [Openvpn-devel] [S] Change in openvpn[master]: win: replace wmic
invocation with powershell
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
To: stipa , plaisthos , flichtenheld
Cc: openvpn-devel
--shODO1h7Ks8=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
cron2 has uploaded a new patch set (#2) to the change originally created by=
stipa. ( http://gerrit.openvpn.net/c/openvpn/+/1187?usp=3Demail )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
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.
This is based on 2.6 patch which replaces wmic with powershell
d383d6e "win: replace wmic invocation with powershell"
except that here we only touch openvpn process code. There is no
wmic calls in 2.7 service.
Github: fixes OpenVPN/openvpn#642
Change-Id: Ibb126e9ca4548aeb8b60df226e37c9b414698247
Signed-off-by: Lev Stipakov
Acked-by: Gert Doering
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1187
Message-Id: <20250915130344.2906-1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32=
951.html
Signed-off-by: Gert Doering
---
M src/openvpn/tun.c
M src/openvpn/win32.h
2 files changed, 12 insertions(+), 9 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/87/1187/2
diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index 29f74a2..ee0733a 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -405,7 +405,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)
{
@@ -413,10 +413,13 @@
}
struct argv argv =3D argv_new();
- argv_printf(&argv, "%s%s nicconfig where (InterfaceIndex=3D%ld) call S=
etDNSDomain '%s'",
- get_win_sys_path(), WMIC_PATH_SUFFIX, tt->adapter_index,
+ argv_printf(&argv,
+ "%s%s -NoProfile -NonInteractive -Command Set-DnsClient -I=
nterfaceIndex %lu -ConnectionSpecificSuffix '%s'",
+ get_win_sys_path(),
+ POWERSHELL_PATH_SUFFIX,
+ tt->adapter_index,
add ? tt->options.domain : "");
- exec_command("WMIC", &argv, 1, M_WARN);
+ exec_command("PowerShell", &argv, 1, M_WARN);
argv_free(&argv);
}
@@ -1208,7 +1211,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 */
@@ -1527,7 +1530,7 @@
NI_IP_NETMASK | NI_OPTIONS);
}
- do_dns_domain_wmic(true, tt);
+ do_dns_domain_pwsh(true, tt);
}
@@ -6547,7 +6550,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);
@@ -6574,7 +6577,7 @@
}
else
{
- do_dns_domain_wmic(false, tt);
+ do_dns_domain_pwsh(false, tt);
if (tt->options.ip_win32_type =3D=3D IPW32_SET_NETSH)
{
diff --git a/src/openvpn/win32.h b/src/openvpn/win32.h
index dbfa5bc..ff3145a 100644
--- a/src/openvpn/win32.h
+++ b/src/openvpn/win32.h
@@ -40,7 +40,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\\pow=
ershell.exe"
/*
* Win32-specific OpenVPN code, targeted at the mingw
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1187?usp=3Demail
To unsubscribe, or for help writing mail filters, visit http://gerrit.openv=
pn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ibb126e9ca4548aeb8b60df226e37c9b414698247
Gerrit-Change-Number: 1187
Gerrit-PatchSet: 2
Gerrit-Owner: stipa
Gerrit-Reviewer: cron2
Gerrit-Reviewer: flichtenheld
Gerrit-Reviewer: plaisthos
Gerrit-CC: openvpn-devel
Gerrit-MessageType: newpatchset
--shODO1h7Ks8=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
cron2 uploaded patch set #2 to the change originally cr=
eated by stipa.
View Change
The following approvals got outdated an=
d were removed:
Code-Review+2 by cron2
win: replace wmic invocation with powershell
=
Since wmic has been recently deprecated and is absent on new
systems, re=
place setting DNS domain "old-style" with powershell.
This=
is based on 2.6 patch which replaces wmic with powershell
d383d=
6e "win: replace wmic invocation with powershell"
except t=
hat here we only touch openvpn process code. There is no
wmic calls in 2=
.7 service.
Github: fixes OpenVPN/openvpn#642
Change-Id: Ibb1=
26e9ca4548aeb8b60df226e37c9b414698247
Signed-off-by: Lev Stipakov <le=
v@...515...>
Acked-by: Gert Doering <gert@...1296...>
Gerrit=
URL: https://gerrit.openvpn.net/c/openvpn/+/1187
Message-Id: <202509=
15130344.2906-1-gert@...1296...>
URL: https://www.mail-archive.com/op=
envpn-devel@lists.sourceforge.net/msg32951.html
Signed-off-by: Gert Doer=
ing <gert@...1296...>
---
M src/openvpn/tun.c
M src/openvpn/=
win32.h
2 files changed, 12 insertions(+), 9 deletions(-)
<=
pre style=3D"font-family: monospace,monospace; white-space: pre-wrap;">git =
pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/87/1187/2=
diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index 29=
f74a2..ee0733a 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -405,7 +405,7 @@
}
static void
-do_dns_domain_wmic(bool add, const struct t=
untap *tt)
+do_dns_do=
main_pwsh(bool add, const struct tuntap *tt)
{
<=
span> if (!tt->options.domain)
{
@@ -413,10 +413,13 @@
}
=
struct argv argv =3D argv_new();
- argv_printf(&argv, "%s%s nicconfig where=
(InterfaceIndex=3D%ld) call SetDNSDomain '%s'",
- get_win_sys_path(),=
WMIC_PATH_SUFFIX, tt->adapter_index,
+ argv_printf(&argv,
+ "%s%s -NoProfile -NonInter=
active -Command Set-DnsClient -InterfaceIndex %lu -ConnectionSpecificSuffix=
'%s'",
=
+ get_win_sys_path(),
+ POWERSHELL_PATH_SUFFIX,
+ tt->adapter_index,<=
/span>
add ? tt->options.domain : ""=
);
- exec_command(&q=
uot;WMIC", &argv, 1, M_WARN);
+ exec_command("PowerShell", &argv, 1, M=
_WARN);
argv_free(&argv);=
}
@@ -1208,7 +1211,7 @@
=
if (!tt->did_ifconfig_setup)
=
{
- do_dns_=
domain_wmic(true, tt);
+ do_dns_domain_pwsh(true, tt);
}
}
#else /* platforms we have no IPv6 co=
de for */
@@ -1527,7 +1530,7 @@
=
NI_IP_NETMASK | NI_OPTIONS);
}
- =
do_dns_domain_wmic(true, tt);
+ do_dns_domain_pwsh(true, tt);
}
@@ -6547,7 +6550,7 @@
{
if (!tt->did_ifconf=
ig_setup)
{
- do_dns_domain_wmic(false, tt);
+ do_dns_domain=
_pwsh(false, tt);
}
netsh_delete_address_dns(tt, true, &gc);
@@ -6574,7 +6577,7 @@
}
=
else
{
- do_dns_domain_wmic(false, tt);
+ do_dns_domain_pwsh(false=
, tt);
if (tt->options.ip=
_win32_type =3D=3D IPW32_SET_NETSH)
{diff --git a/src/openvpn/win32.h b/src/openvpn/win32.h
index dbfa5bc..ff3145a 100644
--- a/src/openvpn/win32.h=
+++ b/src/openvpn/win32.h
@@ -40,7 +40,7 @=
@
#define WIN_ROUTE_PATH_SUFFIX "\\system32\\route=
.exe"
#define WIN_IPCONFIG_PATH_SUFFIX "\\system=
32\\ipconfig.exe"
#define WIN_NET_PATH_SUFFIX &q=
uot;\\system32\\net.exe"
-#define WMIC_PATH_SUFFIX "\\system32\\wbem\\wmic.exe&q=
uot;
+#define POWERSH=
ELL_PATH_SUFFIX "\\system32\\WindowsPowerShell\\v1.0\\powershell.exe=
"
/*
* Win32-spec=
ific OpenVPN code, targeted at the mingw
<=
p>To view, visit change 1187. To unsubscribe, or for help writing mail filters=
, visit settings.
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ibb126e9ca4548aeb8b60df226e3=
7c9b414698247
Gerrit-Change-Number: 1187
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <lstipakov@...277...>=
;
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...=
1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...=
.1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...=
ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--shODO1h7Ks8=--