@@ -53,45 +53,42 @@ protected override void OpenBrowserInternal(string url)
5353
5454 private bool GetWebBrowserAvailable ( )
5555 {
56- // If this is a Windows Subsystem for Linux distribution we may
57- // be able to launch the web browser of the host Windows OS.
58- if ( WslUtils . IsWslDistribution ( Environment , FileSystem , out _ ) )
56+ // We need a shell execute handler to be able to launch to browser
57+ if ( ! TryGetShellExecuteHandler ( Environment , out _ ) )
5958 {
60- // We need a shell execute handler to be able to launch to browser
61- if ( ! TryGetShellExecuteHandler ( Environment , out _ ) )
62- {
63- return false ;
64- }
65-
66- //
67- // If we are in Windows logon session 0 then the user can never interact,
68- // even in the WinSta0 window station. This is typical when SSH-ing into a
69- // Windows 10+ machine using the default OpenSSH Server configuration,
70- // which runs in the 'services' session 0.
71- //
72- // If we're in any other session, and in the WinSta0 window station then
73- // the user can possibly interact. However, since it's hard to determine
74- // the window station from PowerShell cmdlets (we'd need to write P/Invoke
75- // code and that's just messy and too many levels of indirection quite
76- // frankly!) we just assume any non session 0 is interactive.
77- //
78- // This assumption doesn't hold true if the user has changed the user that
79- // the OpenSSH Server service runs as (not a built-in NT service) *AND*
80- // they've SSH-ed into the Windows host (and then started a WSL shell).
81- // This feels like a very small subset of users...
82- //
83- if ( WslUtils . GetWindowsSessionId ( FileSystem ) == 0 )
84- {
85- return false ;
86- }
59+ return false ;
60+ }
8761
88- // If we are not in session 0, or we cannot get the Windows session ID,
89- // assume that we *CAN* launch the browser so that users are never blocked.
90- return true ;
62+ // If this is a Windows Subsystem for Linux distribution we may
63+ // be able to launch the web browser of the host Windows OS, but
64+ // there are further checks to do on the Windows host's session.
65+ //
66+ // If we are in Windows logon session 0 then the user can never interact,
67+ // even in the WinSta0 window station. This is typical when SSH-ing into a
68+ // Windows 10+ machine using the default OpenSSH Server configuration,
69+ // which runs in the 'services' session 0.
70+ //
71+ // If we're in any other session, and in the WinSta0 window station then
72+ // the user can possibly interact. However, since it's hard to determine
73+ // the window station from PowerShell cmdlets (we'd need to write P/Invoke
74+ // code and that's just messy and too many levels of indirection quite
75+ // frankly!) we just assume any non session 0 is interactive.
76+ //
77+ // This assumption doesn't hold true if the user has changed the user that
78+ // the OpenSSH Server service runs as (not a built-in NT service) *AND*
79+ // they've SSH-ed into the Windows host (and then started a WSL shell).
80+ // This feels like a very small subset of users...
81+ //
82+ if ( WslUtils . IsWslDistribution ( Environment , FileSystem , out _ ) &&
83+ WslUtils . GetWindowsSessionId ( FileSystem ) == 0 )
84+ {
85+ return false ;
9186 }
9287
93- // We require an interactive desktop session to be able to launch a browser
94- return IsDesktopSession ;
88+ // If we are not in WSL, or we are but are not in session 0 (or we cannot get
89+ // the Windows session ID), assume that we *CAN* launch the browser so that
90+ // users are never blocked.
91+ return true ;
9592 }
9693
9794 private static bool TryGetShellExecuteHandler ( IEnvironment env , out string shellExecPath )
0 commit comments