@@ -127,6 +127,10 @@ mkdir -p $folder
127127$logProfile = " $folder /wsl_networking.wprp"
128128$networkingBashScript = " $folder /networking.sh"
129129
130+ # Detect the super user first.
131+ # Actually it's not definite that the super user is named "root". Instead, a user with uid=0 is what we are looking for. See #11693.
132+ $superUser = & wsl.exe -- id - nu 0 # user name of the super user.
133+
130134# Copy/Download supporting files
131135if (Test-Path " $PSScriptRoot /wsl_networking.wprp" )
132136{
@@ -158,7 +162,7 @@ if (Test-Path $wslconfig)
158162}
159163
160164# Collect Linux & Windows network state before the repro
161- & wsl.exe - u root - e $networkingBashScript 2>&1 > $folder / linux_network_configuration_before.log
165+ & wsl.exe - u $superUser - e $networkingBashScript 2>&1 > $folder / linux_network_configuration_before.log
162166
163167Collect- WindowsNetworkState " before_repro"
164168
@@ -202,7 +206,7 @@ netsh wfp capture start file="$folder/wfpdiag.cab"
202206$tcpdumpProcess = $null
203207try
204208{
205- $tcpdumpProcess = Start-Process wsl.exe - ArgumentList " -u root tcpdump -n -i any -e -vvv > $folder /tcpdump.log" - PassThru
209+ $tcpdumpProcess = Start-Process wsl.exe - ArgumentList " -u $superUser tcpdump -n -i any -e -vvv > $folder /tcpdump.log" - PassThru
206210}
207211catch {}
208212
@@ -258,7 +262,7 @@ finally
258262{
259263 try
260264 {
261- wsl.exe - u root killall tcpdump
265+ wsl.exe - u $superUser killall tcpdump
262266 if ($tcpdumpProcess -ne $null )
263267 {
264268 Wait-Process - InputObject $tcpdumpProcess - Timeout 10
@@ -272,7 +276,7 @@ finally
272276}
273277
274278# Collect Linux & Windows network state after the repro
275- & wsl.exe - u root - e $networkingBashScript 2>&1 > $folder / linux_network_configuration_after.log
279+ & wsl.exe - u $superUser - e $networkingBashScript 2>&1 > $folder / linux_network_configuration_after.log
276280
277281Collect- WindowsNetworkState " after_repro"
278282
0 commit comments