Skip to content

<filesystem>: exists() fails with "Access denied" for certain type of symlinks #5095

@alexlipa91

Description

@alexlipa91

Describe the bug

We use std::filesystem::exists to check existence of paths on the system. Since few days we started to see an error where this function would fail with Access Denied. Unfortunately I could not get a fully reproducible example but I am gonna describe what I noticed.

This is the logged error

Exists D:\some_path\WebKit.framework = 0 with ec 5 and msg Access is denied.

This is the list of paths inside some_path

d-----        11/15/2024   4:51 AM                _SceneKit_SwiftUI.framework
d-----        11/15/2024   4:51 AM                _StoreKit_SwiftUI.framework
d-----        11/15/2024   4:51 AM                _SwiftData_SwiftUI.framework
d-----        11/15/2024   4:51 AM                _Translation_SwiftUI.framework
-a---l        11/15/2024   4:51 AM              0 AuthenticationServices.framework
-a---l        11/15/2024   4:51 AM              0 JavaScriptCore.framework
-a---l        11/15/2024   4:51 AM              0 SafariServices.framework
-a---l        11/15/2024   4:51 AM              0 WebKit.framework

The function fails on all the paths having the a and l bit on while it succeeds on the others.
Permissions should not be the problem: I tried with different users and with all of them I can read the files using powershell (with a simple ls).

Other things worth mentioning: these are symlinks that point to other symlinks

$ stat Modules
  File: Modules -> Versions/Current/Modules
  Size: 24              Blocks: 0          IO Block: 65536  symbolic link

$ stat Versions/Current/Modules
  File: Versions/Current/Modules
  Size: 0               Blocks: 0          IO Block: 65536  directory

$ stat Versions/Current
  File: Versions/Current -> A
  Size: 1               Blocks: 0          IO Block: 65536  symbolic link

$ stat Versions/A/
  File: Versions/A/
  Size: 0               Blocks: 0          IO Block: 65536  directory

again, I tried to repro by re-building a folder structure of this type but I couldn't reproduce the error

Any advice?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfilesystemC++17 filesystem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions