Skip to content

permission denied reading /mnt/c/Users/<user>/Cookies #2779

Closed

Description

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

Activity

  1. therealkenc commented on Dec 23, 2017

    @therealkenc

    Please post your reproduction steps.

  2. danarth commented on Jan 15, 2018

    @danarth

    therealkenc I get the same issue as Ricardo Pimentel (@ricardojrgpimentel) . The only steps I take are:

    • cd /mnt/c/Users/<my username>
    • ls

    This gives me the following output:

    ls: cannot read symbolic link 'Application Data': Permission denied
    ls: cannot read symbolic link 'Cookies': Permission denied
    ls: cannot read symbolic link 'Local Settings': Permission denied
    ls: cannot read symbolic link 'My Documents': Permission denied
    ls: cannot read symbolic link 'NetHood': Permission denied
    ls: cannot read symbolic link 'PrintHood': Permission denied
    ls: cannot read symbolic link 'Recent': Permission denied
    ls: cannot read symbolic link 'SendTo': Permission denied
    ls: cannot read symbolic link 'Start Menu': Permission denied
    ls: cannot read symbolic link 'Templates': Permission denied
    

    I am running a fresh install of Windows 10, and Ubuntu is the Linux distro I am using.

  3. therealkenc commented on Jan 16, 2018

    @therealkenc

    You don't have access to those on Windows either. Go to Windows Explorer, paste C:\Users\you\Cookies.

    Interestingly enough though, ntfs-3g appears to get this right under an analogous scenario on Real Linux. So yeah.

  4. WSLUser commented on Jan 16, 2018

    @WSLUser

    Is this UserVoice worthy as it might considered a new feature. I know I would love to see this capability. Learning NTFS-3G can do it sounds to me like it's a simple reach out to that team to get the repro steps for implementing it and making any possible tailoring to make it more specific to Windows 10. I'm actually now curious to see about running NTFS-3G inside Ubuntu on WSL to test this scenario out. Maybe when I have more time for it.

  5. therealkenc commented on Jan 16, 2018

    @therealkenc

    Is this UserVoice worthy as it might considered a new feature.

    Whether something is UserVoice worthy is in the eyes of the upvotes over there.

    curious to see about running NTFS-3G inside Ubuntu on WSL

    No that won't work per an oft-requested but currently unavailable feature, which I won't mention out loud because it doesn't have to do with the ask in the OP. But it starts with an F.

  6. WSLUser commented on Jan 16, 2018

    @WSLUser

    Well thanks for the enlightenment. Thanks for your hint about the unavailable feature. I had upvoted that already due to other things awhile ago. Hopefully it's addressed by fall this year but I won't be holding my breath either.

  7. changed the title [-]ls command doesnt have permission[/-] [+]permission denied reading /mnt/c/Users/<user>/Cookies[/+] on Apr 3, 2018
  8. shoffmeister commented on Jun 15, 2018

    @shoffmeister

    Why is this issue not resolved as "working as designed" / "not a bug"?

    If a user gets permission denied on the Windows side, why is there an expectation that the same user ("Windows identity") does not get the same permission denied from LInux?

    One of the key differences between a real-life Linux and WSL here is that a real-life Linux simply does not offer any security on reading NTFS, while WSL has a fully integrated identity system. If someone wants to break the identity / security system, using Linux in a virtual machine and then mapping the raw disk into that virtual machine would appear to be the right thing?

  9. therealkenc commented on Jun 15, 2018

    @therealkenc

    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 denied error is the first thing people see in cd /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 a cannot read symbolic link error out of ls. At worst, if you don't have permission to the followed path, then the pathname is helpfully displayed in red with ls -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 in ls.

    [The "provisionally" caveat is because one can call anything as-designed by fiat. This issue isn't tagged one way or another.]

    image

  10. shoffmeister commented on Jun 15, 2018

    @shoffmeister

    Interesting.

    cygwin bash:

    $ pwd
    /cygdrive/c
    
    $ ls -la Documents\ and\ Settings
    lrwxrwxrwx 1 SYSTEM SYSTEM 17 Jul 10  2015 'Documents and Settings' -> /cygdrive/c/Users
    

    Powershell:

    PS C:\> pwd
    
    Path
    ----
    C:\
    
    
    PS C:\> Get-ChildItem  -Attributes Hidden '.\Documents and Settings\' | Format-List
    Get-ChildItem : Access to the path 'C:\Documents and Settings' is denied.
    At line:1 char:1
    + Get-ChildItem  -Attributes Hidden '.\Documents and Settings\' | Forma ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : PermissionDenied: (C:\Documents and Settings\:String) [Get-ChildItem], UnauthorizedAcces
       sException
        + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
    

    I am my normal user self in both cases.

  11. shoffmeister commented on Jun 15, 2018

    @shoffmeister

    And, again, powershell, this time on Ubuntu:

    pwsh-preview
    
    PowerShell v6.1.0-preview.3
    Copyright (c) Microsoft Corporation. All rights reserved.
    
    https://aka.ms/pscore6-docs
    Type 'help' to get help.
    
    cd /mnt/c
    PS /mnt/c>  Get-ChildItem -Attributes hidden './Documents and Settings' | Format-List
    
        Directory: /mnt/c
    
    Name           : Documents and Settings
    Length         : 0
    CreationTime   : 7/10/15 2:21:38 PM
    LastWriteTime  : 7/10/15 2:21:38 PM
    LastAccessTime : 7/10/15 2:21:38 PM
    Mode           : -----l
    LinkType       : SymbolicLink
    Target         :
    VersionInfo    :
    
  12. 8 remaining items

  13. JustAShoeMaker commented on Apr 11, 2019

    @JustAShoeMaker

    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.

  14. rkitover commented on May 7, 2019

    @rkitover

    I am using my windows home folder as my WSL home, I made this ls function for ~/.bashrc if anyone is interested:

    ls() {
        ls_opts="-h --color=auto"
    
        if [ $# -eq 0 ]; then
            if [ "$PWD" = "$HOME" ]; then
                ls_opts="$ls_opts --hide='ntuser.*' --hide='NTUSER.*'"
            fi
    
            eval command ls "$ls_opts" '"$@"' 2>/dev/null
            return 0
        fi
    
        eval command ls "$ls_opts" '"$@"'
    }

    this makes this behavior more pleasant to deal with.

  15. YantCaccia commented on May 7, 2019

    @YantCaccia

    I am using my windows home folder as my WSL home, I made this ls function for ~/.bashrc if anyone is interested:
    ls() {
    ls_opts="-h --color=auto"

    if [ $# -eq 0 ]; then
        if [ "$PWD" = "$HOME" ]; then
            ls_opts="$ls_opts --hide='ntuser.*' --hide='NTUSER.*'"
        fi
    
        eval command ls "$ls_opts" '"$@"' 2>/dev/null
        return 0
    fi
    
    eval command ls "$ls_opts" '"$@"'
    

    }
    this makes this behavior more pleasant to deal with.

    how to use that?

  16. rkitover commented on May 7, 2019

    @rkitover

    Just paste the function into your ~/.bashrc

  17. rkitover commented on May 7, 2019

    @rkitover

    You might want this too:

    # remove background colors from dircolors
    eval "$(dircolors -p | \
        sed 's/ 4[0-9];/ 01;/; s/;4[0-9];/;01;/g; s/;4[0-9] /;01 /' | \
        dircolors /dev/stdin)"
  18. Maissacrement commented on Jun 16, 2019

    @Maissacrement

    On ~/.bashrc you can just make an alias for output:

    Firstly create the file: touch /var/log/.ls-error
    In a second time make you privilege on this file : sudo chown $USER:$USER /var/log/.ls-error

    In ~/.bashrc:

    # ls alias redirect output to /var/log/.ls-error
    alias ls='ls $@ 2> /var/log/.ls-error --color=auto'
    
  19. therealkenc commented on Jun 16, 2019

    @therealkenc

    Thanks for pinging this one. I was hoping this would resolve itself in WSL 2 with the new 9p /mnt/c. Alas no joy.

    But now that we have Linux CIFS for reals, it did make me wonder how the Windows SMB server deals with those symlinks. Rather than present the files as "l---------" as suggested last summer, the entries just don't appear... because SMB never serves them up, and on the Linux side, getdents(2) never returns them. Which is along the lines of my earlier comment here.

    So I guess a reasonable new ask is: "make 9p behave like SMB."

    image

  20. therealkenc commented on Jun 22, 2019

    @therealkenc

    Ever?

    image

    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 make ls(1) more tolerant of the bug WSL's alternative filesystem semantics.

  21. therealkenc commented on Aug 6, 2019

    @therealkenc

    From #4104 (message)

    Something similar started happening to me, but it is only when ls --colors=auto

    That's actually a half-interesting data point. It isn't colors. It happens any time the readlink(2) + stat(2) combo is evoked. Which doesn't happen in a bare ls(1), which only needs the name out of getdents(2). You'll get the same EPERM with:

    $ "ls" -l     # <--- EPERM fail, with or without the ls colors alias
    
  22. therealkenc commented on Sep 20, 2019

    @therealkenc

    The EPERM on those legacy (if that is the word) Windows symlinks such as /User/<username>/Cookies has been addressed in 18980. Works in both WSL1 and WSL2. Very awesome 💯.

    image

  23. onuryurdupak commented on Feb 20, 2020

    @onuryurdupak

    I am using my windows home folder as my WSL home, I made this ls function for ~/.bashrc if anyone is interested:

    ls() {
        ls_opts="-h --color=auto"
    
        if [ $# -eq 0 ]; then
            if [ "$PWD" = "$HOME" ]; then
                ls_opts="$ls_opts --hide='ntuser.*' --hide='NTUSER.*'"
            fi
    
            eval command ls "$ls_opts" '"$@"' 2>/dev/null
            return 0
        fi
    
        eval command ls "$ls_opts" '"$@"'
    }

    this makes this behavior more pleasant to deal with.

    I know this is old but...
    This is a nice workaround.
    I had this problem with WSL when using Terminator via X Service.
    But naming the function "ls" caused a syntax error so I worked around it by giving the function another name and defining an alias for it like this:

    ls_override () {
        ls_opts="-h --color=auto"
    
        if [ $# -eq 0 ]; then
            if [ "$PWD" = "$HOME" ]; then
                ls_opts="$ls_opts --hide='ntuser.*' --hide='NTUSER.*'"
            fi
    
            eval command ls "$ls_opts" '"$@"' 2>/dev/null
            return 0
        fi
    
        eval command ls "$ls_opts" '"$@"'
    }
    alias ls=ls_override
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions