Add tar tests to confirm entries owned by deleted users can still be read or written #83126
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
rootin 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