Skip to content

Commit 078ed71

Browse files
committed
linuxsessionmgr: make browser detection more robust
Now that we know how to launch a browser via $BROWSER (if set), we should adjust our `IsWebBrowserAvailable` check for Linux. In both WSL and non-WSL (native Linux) environments we immediately return true when $BROWSER is set. VSCode remote tunnels set the $BROWSER variable to a script that redirects requests back to the client's browser, for example. In non-WSL environments we also make our checks for a browser more robust by checking for a 'shell execute' handler (like xdg-open). Previously we just relied on a desktop session ($DISPLAY or $WAYLAND_DISPLAY), which isn't accurate since in BrowserUtils::OpenDefaultBrowser we require a shell execute handler (or $BROWSER). The check and implementation are now aligned! Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
1 parent 3701a50 commit 078ed71

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

src/shared/Core/Interop/Linux/LinuxSessionManager.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,22 @@ public override bool IsWebBrowserAvailable
2121

2222
private bool GetWebBrowserAvailable()
2323
{
24+
// Check if the $BROWSER environment variable is set - we've been told explicitly we have one!
25+
if (BrowserUtils.TryGetBrowserEnvironment(Environment, out _))
26+
{
27+
return true;
28+
}
29+
30+
// We need a shell execute handler to be able to launch to browser
31+
if (!BrowserUtils.TryGetLinuxShellExecuteHandler(Environment, out _))
32+
{
33+
return false;
34+
}
35+
2436
// If this is a Windows Subsystem for Linux distribution we may
2537
// be able to launch the web browser of the host Windows OS.
2638
if (WslUtils.IsWslDistribution(Environment, FileSystem, out _))
2739
{
28-
// We need a shell execute handler to be able to launch to browser
29-
if (!BrowserUtils.TryGetLinuxShellExecuteHandler(Environment, out _))
30-
{
31-
return false;
32-
}
33-
3440
//
3541
// If we are in Windows logon session 0 then the user can never interact,
3642
// even in the WinSta0 window station. This is typical when SSH-ing into a
@@ -55,10 +61,9 @@ private bool GetWebBrowserAvailable()
5561

5662
// If we are not in session 0, or we cannot get the Windows session ID,
5763
// assume that we *CAN* launch the browser so that users are never blocked.
58-
return true;
64+
// Fall through to return true.
5965
}
6066

61-
// We require an interactive desktop session to be able to launch a browser
62-
return IsDesktopSession;
67+
return true;
6368
}
6469
}

0 commit comments

Comments
 (0)