FileStatus.IsModeReadOnlyCore compares group with user where its comment says other: an extra getgroups per entry, and a wrong ReadOnly for some modes
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- csharp, macos
- Área
- operating-systems
Línea de trabajo
Lee src/libraries/System.Private.CoreLib/src/System/IO/FileStatus.Unix.cs en torno a IsModeReadOnlyCore, especialmente la comparación de permisos y su comentario. Revisa las pruebas existentes para el manejo de permisos de archivos Unix y añade cobertura para que los permisos de grupo y de otros usuarios coincidan, y para el modo 0446 en un archivo propiedad de otro usuario. El trabajo estará terminado cuando la comparación siga el comentario y se corrijan tanto el resultado incorrecto de solo lectura como la consulta innecesaria del grupo.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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).
- Lenguaje dominante
- C#
- Estrellas
- 18.5k
- Forks
- 5.8k
- Merge medio
- 2 d 8 h
- PR fusionados (30 d)
- 597
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de dotnet/runtime
-
area-VM-meta-mono untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
area-Debugger-mono untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
dotnet/runtime#138494 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
area-AssemblyLoader-mono untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
dotnet/runtime#138493 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
JsonConsoleFormatter throws on NaN and infinite double and float values, failing the log callPosiblemente ocupada @Mohamedadel-prog la tomó hace 1 día. Abiertoarea-Extensions-Logging untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
dotnet/runtime#138418 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
area-Codegen-AOT-mono untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
Los mantenedores suelen responder en 1 día
Todos los issues de dotnet/runtime
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
microsoft/sqltoolsservice#2851 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
elsa-workflows/elsa-foundation#6322 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
mohebifar/made-in-iran#273 ·
-
Test bug: Include_collection_with_cross_apply_with_filter relies on nondeterministic ORDER BY with TakePosiblemente ocupada @Mohamedadel-prog la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
dotnet/efcore#39848 · 1 comentario ·
Los mantenedores suelen responder en 2 días