Giter Club home page Giter Club logo

Comments (11)

Biswa96 avatar Biswa96 commented on May 29, 2024 2

Any great tip like the 0x08 for this one or should I just make my commands more strict?

I'm not the right one to comment on that. But if this was not for Ubuntu or any stable software I have some dangerous tricks in my sleeve 🤐

from wsl-distrolauncher.

Biswa96 avatar Biswa96 commented on May 29, 2024

Just curious where it is used.

from wsl-distrolauncher.

CarlosNihelton avatar CarlosNihelton commented on May 29, 2024

Hi! We have a custom routine for both distro installation and later reconfiguration. Currently, the preparation for that routine requires detection of subsystem version (1 or 2) and of graphical capabilities. But that might be require us to look into other aspects, like the default environment variables.

For now you can see the usage below:

https://github.com/ubuntu/WSL/blob/9cc33befc0f8af1b837212aa5190d111cbfef273/DistroLauncher/WSLInfo.cpp#L49

from wsl-distrolauncher.

Biswa96 avatar Biswa96 commented on May 29, 2024

I am kind of thinking that mistake (probably). I may be wrong. As far as I can remember, the distributionVersion parameter does not reflect whether the distribution is in WSL1 or WSL2 environment. It reflects lxfs vs. wslfs, old topic.

This is undocumented but works. The wslDistributionFlags provides WSL1 vs WSL2. For WSL2, wslDistributionFlags has 0x08 flag or-ed.

from wsl-distrolauncher.

Biswa96 avatar Biswa96 commented on May 29, 2024

There should be an official way to detect whether wslg is enabled or not without executing any ELF binary or poking a file.

from wsl-distrolauncher.

CarlosNihelton avatar CarlosNihelton commented on May 29, 2024

I am kind of thinking that mistake (probably). I may be wrong. As far as I can remember, the distributionVersion parameter does not reflect whether the distribution is in WSL1 or WSL2 environment. It reflects lxfs vs. wslfs, old topic.

This is undocumented but works. The wslDistributionFlags provides WSL1 vs WSL2. For WSL2, wslDistributionFlags has 0x08 flag or-ed.

You are indeed right. Thanks for spotting my bug. Really appreciate it. Yet, just by the WSL_DISTRIBUTION_FLAGS_DEFAULT constant I wouldn't be able to detect WSL2.

It would be nice if the API itself provided a function for that specific piece of information. Would the 0x08 trick be documented anytime or you guys consider it an internal detail?

from wsl-distrolauncher.

CarlosNihelton avatar CarlosNihelton commented on May 29, 2024

There should be an official way to detect whether wslg is enabled or not without executing any ELF binary or poking a file.

While I totally agree with you, I didn't find any better way other than inspecting sockets.

from wsl-distrolauncher.

Biswa96 avatar Biswa96 commented on May 29, 2024

I didn't find any better way other than inspecting sockets.

Wondering what that will be.

from wsl-distrolauncher.

CarlosNihelton avatar CarlosNihelton commented on May 29, 2024

I didn't find any better way other than inspecting sockets.

Wondering what that will be.

You can have a look if you want 😅
https://github.com/ubuntu/WSL/blob/9cc33befc0f8af1b837212aa5190d111cbfef273/DistroLauncher/WSLInfo.cpp#L79-L97

from wsl-distrolauncher.

Biswa96 avatar Biswa96 commented on May 29, 2024

O, I thought AF_VSOCK vs. AF_INET.

In my opinion, the /tmp/.X11-unix path is not only for wslg. A program may use AF_UNIX socket even in WSL1 or in WSL2 for X servers only (like vcxsrv). AF_UNIX was added in 17063 build of Windows 10 whereas WSL2 was added 18362 build.

from wsl-distrolauncher.

CarlosNihelton avatar CarlosNihelton commented on May 29, 2024

O, I thought AF_VSOCK vs. AF_INET.

In my opinion, the /tmp/.X11-unix path is not only for wslg. A program may use AF_UNIX socket even in WSL1 or in WSL2 for X servers only (like vcxsrv).

That sounds as interesting as challenging. AFAIK, AF_VSOCK would help to be sure I'm under WSL 2, but would it tell anything about WSLg? While I can ls -l /tmp/.X11-unix | grep wslg , doesn't tell the whole story either, since it also appears mounted on WSL 1 instances. Besides the fact that it still feels a bit hacky to my taste.

Any great tip like the 0x08 for this one or should I just make my commands more strict?

from wsl-distrolauncher.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.