mirror of
https://github.com/microsoft/WSL.git
synced 2025-12-11 03:40:23 -06:00
Add superuser detection in networking logs script (#12520)
* Add super user detection; a powershell approach is used * use the 'id' command * avoid stderr warning & wsl alias
This commit is contained in:
parent
ae780d11a1
commit
8c61f09e4d
@ -127,6 +127,10 @@ mkdir -p $folder
|
||||
$logProfile = "$folder/wsl_networking.wprp"
|
||||
$networkingBashScript = "$folder/networking.sh"
|
||||
|
||||
# Detect the super user first.
|
||||
# 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.
|
||||
$superUser = & wsl.exe -- id -nu 0 # user name of the super user.
|
||||
|
||||
# Copy/Download supporting files
|
||||
if (Test-Path "$PSScriptRoot/wsl_networking.wprp")
|
||||
{
|
||||
@ -158,7 +162,7 @@ if (Test-Path $wslconfig)
|
||||
}
|
||||
|
||||
# Collect Linux & Windows network state before the repro
|
||||
& wsl.exe -u root -e $networkingBashScript 2>&1 > $folder/linux_network_configuration_before.log
|
||||
& wsl.exe -u $superUser -e $networkingBashScript 2>&1 > $folder/linux_network_configuration_before.log
|
||||
|
||||
Collect-WindowsNetworkState "before_repro"
|
||||
|
||||
@ -202,7 +206,7 @@ netsh wfp capture start file="$folder/wfpdiag.cab"
|
||||
$tcpdumpProcess = $null
|
||||
try
|
||||
{
|
||||
$tcpdumpProcess = Start-Process wsl.exe -ArgumentList "-u root tcpdump -n -i any -e -vvv > $folder/tcpdump.log" -PassThru
|
||||
$tcpdumpProcess = Start-Process wsl.exe -ArgumentList "-u $superUser tcpdump -n -i any -e -vvv > $folder/tcpdump.log" -PassThru
|
||||
}
|
||||
catch {}
|
||||
|
||||
@ -258,7 +262,7 @@ finally
|
||||
{
|
||||
try
|
||||
{
|
||||
wsl.exe -u root killall tcpdump
|
||||
wsl.exe -u $superUser killall tcpdump
|
||||
if ($tcpdumpProcess -ne $null)
|
||||
{
|
||||
Wait-Process -InputObject $tcpdumpProcess -Timeout 10
|
||||
@ -272,7 +276,7 @@ finally
|
||||
}
|
||||
|
||||
# Collect Linux & Windows network state after the repro
|
||||
& wsl.exe -u root -e $networkingBashScript 2>&1 > $folder/linux_network_configuration_after.log
|
||||
& wsl.exe -u $superUser -e $networkingBashScript 2>&1 > $folder/linux_network_configuration_after.log
|
||||
|
||||
Collect-WindowsNetworkState "after_repro"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user