-
Notifications
You must be signed in to change notification settings - Fork 4.9k
NamedPipe: CurrentUserOnly, quick fixes for Unix #27463
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,20 @@ public static void CreateServer_ConnectClient() | |
} | ||
} | ||
|
||
[Fact] | ||
[PlatformSpecific(TestPlatforms.AnyUnix)] // On Unix domain socket should have different location in this case. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. I admit I didn't yet review the CurrentUserOnly code that went in and so haven't thought deeply about it. But it's a little worrying that CurrentUserOnly when applied on just the server or client means that the current user can't connect to it. Do we have other approaches we could take that would enable it? Could we get away with only checking user ID or we believe the extra security provided by the directory is critical? Could we try one path and then the other if we fail to connect on the first? Etc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could get away with removing the extra directory to avoid this behavior, the downside seems that we need throw on the server side, see #26395 (comment) There is also a small incorrect thing that I just noticed about the current code: we chmod the directory but don't check actual ownership so for instance root can chmode but owner is still old user (the code ignores that for now). |
||
public static void CreateServerNotCurrentUserOnly_ClientCurrentUserOnly_ThrowsTimeout_OnUnix() | ||
{ | ||
var name = GetUniquePipeName(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: var => string |
||
using (var server = new NamedPipeServerStream(name, PipeDirection.InOut, 1, PipeTransmissionMode.Byte)) | ||
{ | ||
using (var client = new NamedPipeClientStream(".", name, PipeDirection.InOut, PipeOptions.CurrentUserOnly)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the same issue apply if the server is CurrentUserOnly and the client is not? We should test that direction as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently due to the extra folder yes. The test basically ensures that they have a different location when current user only is set. Before I add the reverse test, let's consider if we don't want to instead get rid of the extra directory. |
||
{ | ||
Assert.Throws<TimeoutException>(() => client.Connect(1)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently the client is not going to find it so that is the "natural" exception, the alternative is to go with |
||
} | ||
} | ||
} | ||
|
||
[Fact] | ||
public static void CreateMultipleServers_ConnectMultipleClients() | ||
{ | ||
|
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.
?"Was refused"