Open brunolins16 opened 2 years ago
Tagging subscribers to this area: @dotnet/area-system-io See info in area-owners.md if you want to be subscribed.
Author: | brunolins16 |
---|---|
Assignees: | - |
Labels: | `area-System.IO`, `untriaged` |
Milestone: | - |
Hello. If I'm not mistaken, the issue also affects asp.net core.
For instance, when a web app is hosted in Kubernetes(k8s) and leverages from using k8s secrets, e.g. mounts a secret to a file path, it often leads to a set of symbolic links on a file system. If the web app serves the content of these secrets as static files, it leads to an issue that kestrel cannot determine files lends and uses an incorrect value in the HTTP Content-Length header. In the example below, please see the Content-Length HTTP header value.
/app/wwwroot/.well-known # tree -ah
.
├── [ 60] ..2022_05_06_15_52_59.3929185971
│ └── [5.6K] apple-developer-merchantid-domain-association.txt
├── [ 32] ..data -> ..2022_05_06_15_52_59.3929185971
└── [ 56] apple-developer-merchantid-domain-association.txt -> ..data/apple-developer-merchantid-domain-association.txt
2 directories, 2 files
/app/wwwroot/.well-known # ls -lah
total 4K
drwxrwsrwt 3 root 1337 100 May 6 15:52 .
drwxr-xr-x 1 root root 4.0K May 6 15:53 ..
drwxr-sr-x 2 root 1337 60 May 6 15:52 ..2022_05_06_15_52_59.3929185971
lrwxrwxrwx 1 root 1337 32 May 6 15:52 ..data -> ..2022_05_06_15_52_59.3929185971
lrwxrwxrwx 1 root 1337 56 May 6 15:52 apple-developer-merchantid-domain-association.txt -> ..data/apple-developer-merchantid-domain-association.txt
/app/wwwroot/.well-known # curl http://localhost:8080/.well-known/apple-developer-merchantid-domain-association.txt -I
HTTP/1.1 200 OK
Content-Length: 56
Content-Type: text/plain
Date: Fri, 06 May 2022 16:30:07 GMT
Server: Kestrel
Accept-Ranges: bytes
ETag: "1d861615bf5ffb8"
Last-Modified: Fri, 06 May 2022 15:52:59 GMT
/app/wwwroot/.well-known # curl http://localhost:8080/.well-known/..2022_05_06_15_52_59.3929185971/apple-developer-merchantid-domain-association.txt -I
HTTP/1.1 200 OK
Content-Length: 5758
Content-Type: text/plain
Date: Fri, 06 May 2022 16:30:12 GMT
Server: Kestrel
Accept-Ranges: bytes
ETag: "1d861615bf5e9fe"
Last-Modified: Fri, 06 May 2022 15:52:59 GMT
/app/wwwroot/.well-known
Thank you.
This is not only an issue on PhysicalFIleInfo, the problem comes from the underlying FileInfo. Changing any current behavior would be a breaking change, but this could be resolved with this API proposal https://github.com/dotnet/runtime/issues/52908.
Description
The ASP.NET core framework uses the PhysicalFileProvider to get physical files information PhysicalFileInfo in a lot places. However, the
Length
andLastModified
properties are not set to the correct value when the file is a symbolic link, as reported here https://github.com/dotnet/aspnetcore/issues/39170.The issue happens in both
Windows
andLinux
.Reproduction Steps
Expected behavior
Actual behavior
Windows
Linux
Regression?
No response
Known Workarounds
The following code, to the sample, give us the right information:
Configuration
OS: Ubuntu 20.04 and Windows 11 (22525.1000)
Other information
No response