FileStatus.IsModeReadOnlyCore compares group with user where its comment says other: an extra getgroups per entry, and a wrong ReadOnly for some modes
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- csharp, macos
- Lĩnh vực
- operating-systems
Hướng nghiên cứu
Đọc src/libraries/System.Private.CoreLib/src/System/IO/FileStatus.Unix.cs ở phần quanh IsModeReadOnlyCore, đặc biệt là phép so sánh quyền và chú thích của nó. Kiểm tra các bài kiểm thử hiện có về xử lý quyền truy cập tệp Unix, sau đó bổ sung kiểm thử cho trường hợp quyền của nhóm và người dùng khác giống nhau, cũng như chế độ 0446 trên tệp thuộc sở hữu của người dùng khác. Hoàn thành khi phép so sánh tuân theo chú thích và khắc phục cả kết quả chỉ đọc không chính xác lẫn việc tra cứu nhóm không cần thiết.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
FileStatus.IsModeReadOnlyCore (Unix) skips the group check when group and user agree, where its comment speaks of group and other:
// System files often have the same permissions for group and other (umask 022).
if (isGroupReadOnly == isUserReadOnly)
{
return isGroupReadOnly;
}
This has two effects for a file or folder another user owns:
- Speed. For the common 0755 or 0644 owned by root, group and other agree (both read-only) but user and group don't, so the shortcut is missed and
IsMemberOfGroupruns. On macOS that callsgetgroups, which asks opendirectoryd and takes about a millisecond each time. ReadingFileSystemInfo.AttributesorFileSystemEntry.Attributesover a tree another user owns pays it for every entry. Walking the 1,163 folders of/usr/local/share/dotnet/packs(root-owned, as the macOS installer leaves it) and reading each one's attributes took 644 ms cold and 274 ms warm. Telling links apart there withLinkTargettook 34 ms. - Correctness. Where group and user agree but other differs, a caller who is neither the owner nor in the group gets the group's answer instead of other's. For example, mode 0446 owned by another user reports
ReadOnlyto someone outside the group, who may write it.
Reproduction Steps
On macOS, as a user other than root:
var watch = System.Diagnostics.Stopwatch.StartNew();
int count = 0;
foreach (string folder in Directory.EnumerateDirectories("/usr/local/share/dotnet/packs", "*", SearchOption.AllDirectories))
{
_ = new DirectoryInfo(folder).Attributes;
count++;
}
Console.WriteLine($"{count} folders, {watch.ElapsedMilliseconds} ms");
Expected behavior
The group check is skipped when group and other agree, as the comment says. Folders owned by root with mode 0755 then need no getgroups call.
Actual behavior
Every such folder calls IsMemberOfGroup. For mode 0446 owned by another user, a caller outside the group is told the file is read-only.
Regression?
Not known.
Known Workarounds
Avoid reading Attributes where only a link check is needed, for example with LinkTarget.
Configuration
.NET 11.0.0, macOS 27 on ARM64 (Apple M2 Max). The code is the same on main.
Other information
The likely fix is if (isGroupReadOnly == isOtherReadOnly).
- Ngôn ngữ chính
- C#
- Star
- 18.5k
- Fork
- 5.8k
- Merge trung bình
- 2 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 597
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dotnet/runtime
-
area-VM-meta-mono untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area-Debugger-mono untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
dotnet/runtime#138494 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area-AssemblyLoader-mono untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
dotnet/runtime#138493 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
JsonConsoleFormatter throws on NaN and infinite double and float values, failing the log callCó thể đã có người làm @Mohamedadel-prog đã nhận 1 ngày trước. Đang mởarea-Extensions-Logging untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
dotnet/runtime#138418 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area-Codegen-AOT-mono untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của dotnet/runtime
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
microsoft/sqltoolsservice#2851 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
elsa-workflows/elsa-foundation#6322 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
mohebifar/made-in-iran#273 ·
-
Test bug: Include_collection_with_cross_apply_with_filter relies on nondeterministic ORDER BY with TakeCó thể đã có người làm @Mohamedadel-prog đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
dotnet/efcore#39848 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày