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

Feature request to configure /etc/wsl.conf #7

Closed
kai2nenobu opened this issue Apr 1, 2021 · 2 comments
Closed

Feature request to configure /etc/wsl.conf #7

kai2nenobu opened this issue Apr 1, 2021 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@kai2nenobu
Copy link

This is a feature request to configure /etc/wsl.conf for WSL distribution.

I want to mount DrvFs (Windows file systems under /mnt) by wsl-shell-user but WSL distribution mounts them by root user.

To change this behavior, it requires a manual step to change mount options in /etc/wsl.conf and restart the distribution after Vampire/setup-wsl step like below. (my workflow sample and workflow result)

      - uses: Vampire/setup-wsl@v1
        with:
          distribution: Ubuntu-20.04
          set-as-default: 'true'
          wsl-shell-user: wsl
      - name: Change mount options and restart
        shell: powershell
        run: |
          wsl -u root bash -c "printf '[automount]\nenabled = true\noptions = `"metadata,uid=1000,gid=1000,umask=22,fmask=11`"\n' | tee /etc/wsl.conf"
          wslconfig /terminate Ubuntu-20.04

If Vampire/setup-wsl has a feature to directly configure /etc/wsl.conf, it makes things simple and easy.

      - uses: Vampire/setup-wsl@v1
        with:
          distribution: Ubuntu-20.04
          set-as-default: 'true'
          wsl-shell-user: wsl
          # configure /etc/wsl.conf ("wsl-conf" is just an example)
          wsl-conf: |
            [automount]
            enabled = true
            options = "metadata,uid=1000,gid=1000,umask=22,fmask=11"

Please consider to add this feature if you like.

@Vampire Vampire added the enhancement New feature or request label Feb 7, 2022
@Vampire Vampire added this to the Next Version milestone Feb 7, 2022
@Vampire
Copy link
Owner

Vampire commented Feb 7, 2022

Thanks for the suggestion.
I like the idea, I just was not aware of /etc/wsl.conf or it might have been there right away.
I even like the wording you used.
This feature will be part of 1.2 which will be released in the next hours most probably.

@Vampire Vampire closed this as completed Feb 7, 2022
@ssbarnea
Copy link

ssbarnea commented Jul 4, 2022

In case someone else is looking about securing the file permissions on WSL, config below works with Ansible.

# /etc/wsl.conf
[automount]
enabled = true
root = /
options = "metadata,umask=077"
[interop]
enabled = false
appendWindowsPath = false

Be careful if you change other options as I seen setup-wsl stop working on some of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants