FileStatus.IsModeReadOnlyCore compares group with user where its comment says other: an extra getgroups per entry, and a wrong ReadOnly for some modes
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- csharp, macos
調査の方向性
src/libraries/System.Private.CoreLib/src/System/IO/FileStatus.Unix.cs の IsModeReadOnlyCore 付近を読み、特に権限の比較とそのコメントを確認してください。Unix ファイル権限の処理に関する既存のテストを確認し、グループとその他のユーザーの権限が一致するケース、および別のユーザーが所有するファイルのモード 0446 を対象とするテストを追加してください。比較がコメントに従い、読み取り専用という誤った結果と不要なグループ検索の両方が解消されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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).
- 主要言語
- C#
- スター
- 18.5k
- フォーク
- 5.8k
- 平均マージ
- 2日 8時間
- マージ済み PR(30日)
- 597
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/runtime のほかの issue
-
area-VM-meta-mono untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
area-Debugger-mono untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
dotnet/runtime#138494 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area-AssemblyLoader-mono untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dotnet/runtime#138493 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
JsonConsoleFormatter throws on NaN and infinite double and float values, failing the log call対応中かも @Mohamedadel-prog が 1 日前に担当しました。 オープンarea-Extensions-Logging untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
dotnet/runtime#138418 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
area-Codegen-AOT-mono untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
microsoft/sqltoolsservice#2851 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
elsa-workflows/elsa-foundation#6322 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 74/100
mohebifar/made-in-iran#273 ·
-
Test bug: Include_collection_with_cross_apply_with_filter relies on nondeterministic ORDER BY with Take対応中かも @Mohamedadel-prog が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
dotnet/efcore#39848 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信