-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Expect UnauthorizedAccessException in tvOS if extracting fifo from tar without elevation #71175
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
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsI saw a tvOS failure in one of my PRs. I had not seen it before, so I'm unsure if it's intermittent or consistent. The In other Unix platforms, extracting fifos does not throw, but apparently it does on tvOS. Here's the callstack:
|
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Instead of wondering whether it's consistent or not, I suggest to leave the code as it is but wrap in a try catch for UnauthorizedAccessException and in the catch simply Assert that you're on tvOS. |
|
The file got renamed in my last PR, so I'll force push a new commit. Also, I realized the problem might be that this test is executed always, regardless if the process is or is not elevated. I should explicitly check if the process is not elevated as a ConditionalFact. I was able to repro this problem when executing the tests in Unix, both with a normal user and with sudo. There were some weird failures when running as sudo.
Sounds good. I'll do that too (if needed). |
| [Fact] | ||
| public async Task SpecialFile_Unelevated_Throws_Async() | ||
| [ConditionalFact(nameof(IsUnixButNotSuperUser))] | ||
| public void SpecialFile_Unelevated_Throws() |
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 noticed this test, which was supposed to be the synchronous one, was written as the asynchronous one.
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
adamsitnik
left a comment
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 @carlossanlop
| { | ||
| [PlatformSpecific(TestPlatforms.AnyUnix & ~TestPlatforms.tvOS)] // https://github.com/dotnet/runtime/issues/68360 | ||
| [Fact] | ||
| [ConditionalFact(nameof(IsUnixButNotSuperUser))] |
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.
all the affected tests belong to *.Unix.cs files so we can assume that they are executed only on Unix and just use the existing IsSuperUser property:
| [ConditionalFact(nameof(IsUnixButNotSuperUser))] | |
| [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsSuperUser))] |
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.
Right, but I need them to not be executed as a super user, ever. That's why I created the extra property for the conditional fact. I don't know if you can negate a conditional fact condition, can you?
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.
The Unix can be removed, yes.
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.
@carlossanlop you are right, I am sorry I've missed the negation
|
The test failures are unrelated, which means the change worked. I can remove the |
I saw a tvOS failure in one of my PRs. I had not seen it before, so I'm unsure if it's intermittent or consistent.
The
ExtractToFile_SpecialFile_Unelevated_Throwsmethod threwUnauthorizedAccessExceptionwhen attempting to extract the fifo from the archive into disk:https://github.com/dotnet/runtime/blame/051b4828c7d3a0cad3289830ef9fd2120f45bb2b/src/libraries/System.Formats.Tar/tests/TarReader/TarReader.ExtractToFile.Tests.Unix.cs#L39
In other Unix platforms, extracting fifos does not throw, but apparently it does on tvOS.
Here's the callstack: