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

Permission Denied when writing to \\wsl$\... path even from elevated shell [wsl2] #4638

Closed
ejohb opened this issue Nov 2, 2019 · 6 comments

Comments

@ejohb
Copy link

ejohb commented Nov 2, 2019

PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\test> [System.Environment]::OSVersion.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      18990  0


PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\test> wsl --list --verbose
  NAME            STATE           VERSION
* test            Running         2

PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\test> cp C:\wsl.conf etc/wsl.conf
cp : Access to the path '\\wsl$\test\etc\wsl.conf' is denied.
At line:1 char:1
+ cp C:\wsl.conf etc/wsl.conf
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\wsl.conf:FileInfo) [Copy-Item], UnauthorizedAccessException
    + FullyQualifiedErrorId : CopyFileInfoItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.CopyItemCommand

There doesn't seem to be a way to modify the files from the Windows side. Is this a bug?

@karuboniru
Copy link

Maybe a feature: accessing \\wsl$ seems to obey permissions from the Linux side.

@ejohb
Copy link
Author

ejohb commented Nov 3, 2019

Maybe a feature: accessing \wsl$ seems to obey permissions from the Linux side.

Ah! Yeah now I understand what it's doing (using the default Linux user permissions), thanks. Changing the default user to root indeed works.

PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\test> set_default_user test root
PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\test> wslconfig.exe /t test
PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\test> set_default_user testroot
PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\test> cp C:\wsl.conf .\etc\wsl.conf

Even so, that's a bit inconvenient. It means I need to kill the WSL instance entirely (cos changing the default user doesn't work otherwise) if I want to do anything that needs root. I would say that an elevated Windows environment should implicitly have root via P9.

@stevebovy
Copy link

We need a configuration option where "wsl$" ignores ownership and permissions; but preserves those
attributes when a file is changed.

I tried running notepad pluss "as admin" and then try to update an /etc file; BUT I could not get it to work

@stevebovy
Copy link

"wsl$" is an excellent and wonderful new feature, but as always with everything LINUX, esoteric concerns for necessary compatibility gets in the way of practical functionality and usefulness.

OF COURSE we must absolutely preserve ownership and permissions for the sake of compatibility and for the sake of proper usage and proper testing.

BUT when a windows machine is a private dev working machine ; I hope we can try to avoid tripping over our own shoelaces.

Practical usefulness predicates that we must try to find a way to work around this short sighted built-in limitation.

After-all ON Linux 20-30% of most file-management activity is ADMINISTRATIVE and not work related productivity ( so this limitation that we are disusing ) puts a huge damper on the
effective usefulness of this new feature.

Thanks again for the great work. But Please do not put UN-needed and unnecessary HAND-CUFFS
ON THIS NEW FEATURE. !!

@edsyl
Copy link

edsyl commented Apr 19, 2020

This file permission issue manifests itself in many ways. For embedded Linux development, the ability to run and configure Yocto and Buildroot is mandatory. Unfortunately neither build tool completes due to inexplicable file permission errors. Doing exactly the same on Mint19.3 completes with no issues.
I have tried the metadata options to no avail. I'm afraid that wsl2 is anon-starter for Embedded Linux devs on Win10.
Too bad because wsl2 is great in other ways.

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants