-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trim file type bits from mode header #77151
Trim file type bits from mode header #77151
Conversation
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsFixes #77107. Depends on dotnet/runtime-assets#279.
|
src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs
Outdated
Show resolved
Hide resolved
Yes, fixed. Too many tabs and PRs are opened. 😅 |
Merged ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you very much for your help @am11 !
@danmoseley, can we backport to 7.0? (bugfix in new library) |
@am11 I moved to the ASPNET team so it's not my call. Generally test coverage doesn't need any special approvals to back port though. 7.0 branch might be closed for a bit for GA. |
Oh this is a product change. It would need all the regular process. The bar is roughly the servicing bar right now. It would be up to the folks in this repo though. |
@danmoseley this is the fix for the issue #77096 in which you were coordinating with the author. Seeing other fixes being backported to 7.0, so there may still be some time. |
Yup, but this is @adamsitnik / @jeffhandley area now. The test failure is another hit on #77087 00 (Inline) -------- coreclr!WKS::gc_heap::mark_array_marked+0x1a [D:\a_work\1\s\src\coreclr\gc\gc.cpp @ 8471] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
set | ||
{ | ||
if ((int)value is < 0 or > 4095) // 4095 in decimal is 7777 in octal | ||
if ((value & ~TarHelpers.ValidUnixFileModes) != 0) // throw on invalid UnixFileModes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: There's another reference to 4095
on the tests which we could change to a const UnixFileMode ValidUnixFileModes
.
runtime/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.File.Base.Unix.cs
Line 38 in ccd9d16
UnixFileMode expectedMode = (UnixFileMode)(status.Mode & 4095); // First 12 bits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently we don't have access to the helpers in the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was suggesting copying the const
to the tests, not making the one on src accessible to tests. Is just a nit, so you can disregard it.
// Some paths do not use the setter, and we want to return valid UnixFileMode. | ||
// This mask only keeps the least significant 12 bits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if not using the setter everywhere is correct. it seems somewhat inconsistent and we could've thrown earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I am not sure if this is intentional. I didn't wanted to go for larger refactoring at this point. There is also an existing helper:
runtime/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHelpers.Unix.cs
Line 55 in 88aea31
internal static void CreateDirectory(string fullPath, UnixFileMode? mode, SortedDictionary<string, UnixFileMode>? pendingModes) |
@@ -97,6 +97,19 @@ await using (TarWriter writer = new TarWriter(archive, TarEntryFormat.Ustar, lea | |||
} | |||
} | |||
|
|||
[Fact] | |||
public async Task ExtractEntry_DockerImageTarWithFileTypeInDirectoriesInMode_SuccessfullyExtracts_Async() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also include a version of this test using a compressed archive since that's what the customer reported. Also, add the sync test. But this is up to you, not a big deal tbh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That will require setting up token to fetch gzipped tar archive from docker api and posting a PR like dotnet/runtime-assets#279. I don't have access to those tokens (and don't think it is super important for 7.0 minimal fix).
Thanks. |
@jozkee, thanks. Can you please backport it to 7.0? This is matching the behavior of other tar reader implementations ( |
@am11 I'm going to initiate the backport. This will put the fix into consideration for a servicing release--most of the other backports you've observed have also been for the first servicing release. Thanks for this fix! |
/backport to release/7.0 |
Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/3347871693 |
@jeffhandley backporting to release/7.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Trim file type bits from mode header
Applying: Define and use ValidUnixFileModes
Applying: Rev System.Formats.Tar.TestData version
Using index info to reconstruct a base tree...
M eng/Version.Details.xml
M eng/Versions.props
Falling back to patching base and 3-way merge...
Auto-merging eng/Versions.props
CONFLICT (content): Merge conflict in eng/Versions.props
Auto-merging eng/Version.Details.xml
CONFLICT (content): Merge conflict in eng/Version.Details.xml
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0003 Rev System.Formats.Tar.TestData version
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
* Trim file type bits from mode header * Define and use ValidUnixFileModes * Rev System.Formats.Tar.TestData version * Move ValidUnixFileModes to shared helpers
* Trim file type bits from mode header (#77151) * Trim file type bits from mode header * Define and use ValidUnixFileModes * Rev System.Formats.Tar.TestData version * Move ValidUnixFileModes to shared helpers * Bump package version for TAR test assets Co-authored-by: Adeel Mujahid <[email protected]> Co-authored-by: Carlos Sanchez <[email protected]>
Fixes #77096.
Depends on dotnet/runtime-assets#279.