-
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
Add tar tests to confirm entries owned by deleted users can still be read or written #83126
Conversation
Since this is a test-only change, I'd like to backport it to 7.0 (tell-mode). |
/backport to release/7.0 |
Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/4386255953 |
@carlossanlop backporting to release/7.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Add tar tests to confirm entries owned by deleted users can still be read and written.
Using index info to reconstruct a base tree...
M src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.Unix.cs
M src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntryAsync.File.Tests.Unix.cs
Falling back to patching base and 3-way merge...
Auto-merging src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntryAsync.File.Tests.Unix.cs
Auto-merging src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.Unix.cs
CONFLICT (content): Merge conflict in src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.Unix.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Add tar tests to confirm entries owned by deleted users can still be read and written.
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! |
@carlossanlop an error occurred while backporting to release/7.0, please check the run log for details! Error: git am failed, most likely due to a merge conflict. |
I recently fixed a tar bug in Unix where attempting to write an entry into an archive where the groupName didn't exist, we would unexpectedly throw instead of silently continuing. #81070
I checked if we had the same issue with userName, and fortunately we don't, because when we do the syscall to try to obtain the userName of a non-existent user, the syscall returns empty string, and we can store that in the entry that we are going to write.
What we were missing were test to verify the userName behavior, so I added them in this PR. I also added tests in which neither the userName or the groupName exist in the system.
I manually ran these tests as
root
in my Ubuntu WSL instance, and they all passed. I did have to add a 250 ms sleep after deleting a user or a group. The tests would intermittently fail because the OS sometimes takes too long to delete the user or the group, causing us to successfully retrieve the values and setting them to the written entry, instead of writing empty string.I also fixed the logic we use with Process to prevent the deadlock described in the Process docs remarks whenm consuming the standard output: https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.standardoutput?view=net-7.0#remarks