-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
This question is related to one of the items in the tar pending feedback issue: #68230
In the initial Tar implementation PR, @tmds pointed out here and here that the code setting the mode when extracting files in Unix was incorrect because the umask is being ignored.
The proposed solution would be to call the SafeFileHandle.Open() static method that takes an Interop.Sys.Permissions argument. The problem is that this method is internal. The only places where we call it are in File, FileStream and FileSystem.Unix.cs, which all reside in System.Private.CoreLib.
I examined that Open method, and when it calls SafeFileHandle.Init here, that is when we interact with the umask, which we consume here.
I also noticed that the code in ZipFileExtensions.ZipArchiveEntry.Extract.Unix.cs has the same problem of ignoring the umask (cc @eerhardt).
So I have the following questions:
-
Why do we use the hardcoded Interop.Sys.Permissions.Mask in
SafeFileHandle, instead of the one desired by the user, which according to various documentation sources (like this one) is usually set in the.profilefile or in/etc/profile? -
If we all think it is the right thing to use that hardcoded mask, can I simply just do the following for both
TarEntryandZipFileExtensions?:
Interop.CheckIo(
Interop.Sys.FChMod(fs.SafeFileHandle, permissions & (int)Interop.Sys.Permissions.Mask),
fs.Name);