WSL: permission denied reading /mnt/c/Users//Cookies
On bash when i try to do the command ls i get the following message:
ls: cannot read symbolic link '<Folder Name>': Permission denied
Im on version 10.0.16299.125
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 49
- Comments: 29
@therealkenc I get the same issue as @ricardojrgpimentel . The only steps I take are:
cd /mnt/c/Users/<my username>lsThis gives me the following output:
I am running a fresh install of Windows 10, and Ubuntu is the Linux distro I am using.
The
EPERMon those legacy (if that is the word) Windows symlinks such as/User/<username>/Cookieshas been addressed in 18980. Works in both WSL1 and WSL2. Very awesome đŻ.I am using my windows home folder as my WSL home, I made this
lsfunction for~/.bashrcif anyone is interested:this makes this behavior more pleasant to deal with.
@therealkenc I actually find a way to do that, by alias ls=âls 2>/dev/nullâ. Iâm leaving it here in case someone searches for a workaround. Thank you anyway.
Itâs worth noting that this bug indirectly breaks Jupyter Notebook when run from a userâs home directory. Documented workarounds can found in the issue thread, but unlike this issue as it manifests with the
lscommand, it is causing a âhard failâ with Jupyter. Combined with @cwebster2âs comment, this issue is clearly a bug and if Microsoft is serious about WSL, it needs to be fixed.Provisionally because you do technically have Windows permissions to resolve the link. You get reasonable behavior in Cygwin for example. There is no particular reason why the link shouldnât resolve in WSL as well. No identity system is âbrokenâ by doing so. And, since this
Permission deniederror is the first thing people see incd /mnt/c/Users/<my username>, and that is where folks land by default in Windows Store WSL Ubuntu, the present situation is less than ideal. There are no cases (or common cases that I can think of) in Real Linux where a youâd get acannot read symbolic linkerror out ofls. At worst, if you donât have permission to the followed path, then the pathname is helpfully displayed in red withls -l --color. That WSL does not behave the same one could argue is a bug/diverge. I havenât looked at the source, but I suspect that error message comes from a defensive âhuh, howâd that happenâ error path inls.[The âprovisionallyâ caveat is because one can call anything as-designed by fiat. This issue isnât tagged one way or another.]
On
~/.bashrcyou can just make an alias for output:Firstly create the file:
touch /var/log/.ls-errorIn a second time make you privilege on this file :sudo chown $USER:$USER /var/log/.ls-errorIn
~/.bashrc:I was going to suggest that but I think I lost by train of thought at the time I wrote my post. Thanks for framing the behavioral change request in concrete terms. I think abstracting it further might run into separation of concerns problems. For now it would be enough if WSL didnât cause
lsto crap the bed. Someone will probably open a bug eventually asking why the perms onCookiesis âwrongâ, but thatâs a bridge that can be crossed another day.To add to the issue here is an excerpt from
straceoutput from runningls -l My\ Documents:the return value from
lstat()is 0, indicating success. ls then looks for selinux attributes and finally callsreadlink(), which should resolve the pathMy Documentsis pointing at but instead returns EACCESS indicating âsearch permission is denied for a component of the path prefixâ. The man page path_resolution(7) details how this works.I believe the behavior here to be incorrect. The
readlink()implementation by WSL should be able to resolve the path, then walk it to determine if EACCESS is warranted (e.g. the link truly resolves to somewhere you donât have access to read), but in the general case whereC:\Users\user\My Documentspoints toC:\Users\user\Documents, there is no access issues walking that path.The detail that the
My Documentsis not truly a symbolic link and has underlying dependency on registry keys for resolving its destination is something that should be abstracted away in the readlink call.Alternatively, the permissions for these files should be presented as 000,
l---------to indicate the user has no permission to the file.Interesting.
cygwin bash:
Powershell:
I am my normal user self in both cases.
Ever?
Just 'sayin.
Practical work-around for now remains redirect
2>/dev/null. Someone motivated might also consider an upstream patch to Ubuntuâs coreutils to makels(1)more tolerant of ~the bug~ WSLâs alternative filesystem semantics.You might want this too:
Itâs a bug. If its attached to my files system (in my case, a cryptomator mounted folder on the Windows side) and they are in all ways mine, I should be able to list it.