Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better browser/interactive session detection inside of WSL #1148

Merged
merged 8 commits into from
Mar 15, 2023

Commits on Mar 14, 2023

  1. env: avoid virtual member call in ctor; all refresh

    We had a virtual member call in the constructor of the various
    IEnvironment implementations, which is a code smell.
    
    Instead, lazily populate the `_variables` cache dictionary, and add an
    explict `Refresh` method to refresh the cache. We call `Refresh` in the
    `SetEnvironmentVariable` method for convenience.
    
    For testing we simply pipe through the pre-computed variables in the
    `internal` constructor.
    mjcheetham committed Mar 14, 2023
    Configuration menu
    Copy the full SHA
    a130fec View commit details
    Browse the repository at this point in the history
  2. posix-session: check for Wayland display envars

    Also check for the WAYLAND_DISPLAY environment variable when determining
    if a graphical session/display exists for POSIX systems.
    mjcheetham committed Mar 14, 2023
    Configuration menu
    Copy the full SHA
    4462770 View commit details
    Browse the repository at this point in the history
  3. fs: add abstractions for reading all text and enum dir

    Add abstractions to the IFileSystem interface for enumerating
    directories and reading the entire contents of a file to a string.
    mjcheetham committed Mar 14, 2023
    Configuration menu
    Copy the full SHA
    d37c201 View commit details
    Browse the repository at this point in the history
  4. browser: split browser-check from desktop session check

    Split the web browser check from the desktop session checks. In future
    commits we will enhance the browser-check to take in to account the WSL
    special case.
    mjcheetham committed Mar 14, 2023
    Configuration menu
    Copy the full SHA
    f256672 View commit details
    Browse the repository at this point in the history
  5. wsl: add ability to detect WSL distro and version

    Add methods to the WslUtils class to enable detection of a WSL
    distribution, and also determine which WSL version is being used.
    
    Version 1 uses the Windows NT kernel and runs the distribution in the
    same user-mode space as Windows programs.
    
    Version 2 uses a light-weight VM to host a real Linux kernel, and runs
    the distribution also inside the VM; interop with Windows is achieved
    using other mechanisms.
    mjcheetham committed Mar 14, 2023
    1 Configuration menu
    Copy the full SHA
    afe938c View commit details
    Browse the repository at this point in the history
  6. ini: add basic INI file deserialiser

    Add a basic INI file deserialiser
    mjcheetham committed Mar 14, 2023
    Configuration menu
    Copy the full SHA
    6b887e1 View commit details
    Browse the repository at this point in the history
  7. wsl: add ability to run CMD/PowerShell scripts from WSL

    Add ability to launch cmd.exe or PowerShell.exe scripts from inside a
    WSL distribution.
    
    In order to discover the location of cmd.exe/powershell.exe we need
    search the Windows file system that's mounted by default /mnt/c.
    
    We inspect the /etc/wsl.conf file to respect users who have changed the
    default mount location for Windows drives.
    mjcheetham committed Mar 14, 2023
    Configuration menu
    Copy the full SHA
    a0e2b9c View commit details
    Browse the repository at this point in the history
  8. wsl: detect host Windows session 0 and disable browser

    In order to detect if we have an interactive Windows desktop session
    from inside WSL we need to 'punch out' from WSL to determine the session
    ID and window station.
    
    Strictly speaking, except for session 0 (from Vista onwards), any
    Windows session can have exactly one interactive window station (always
    called WinSta0). However, because we cannot easily determine the window
    station name from a simple cmd/powershell script, we take a simplified
    approach which isn't 100% accurate.
    
    Instead, we only permit browser auth methods if we are NOT in Windows
    session 0; any other Windows session we assume we are in WinSta0.
    
    The default OpenSSH Server configuration (Windows 10+) has `sshd`
    running as the built-in NT user NETWORK_SERVICE, which means it runs in
    session 0 (the services session). This is most common scenario, other
    than using WSL from a 'real', interactive Windows session that we're
    likely to face.
    mjcheetham committed Mar 14, 2023
    Configuration menu
    Copy the full SHA
    d0b767b View commit details
    Browse the repository at this point in the history