-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Ping.Send buffer is not really sent on linux running as non-root #62458
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsDescriptionWhen creating a new instance of the Ping class and calling the Send method providing a buffer, the buffer is not put into the ICMP message that's sent over the network unless the program is run as root. Instead the runtime simply forwards the call to the Reproduction StepsCreate a new console application with
Build the executable with Expected behaviorThe supplied buffer is sent along with the ICMP echo message. Actual behaviorThe wrong payload is sent along with the ICMP echo message. Regression?No response Known WorkaroundsRunning any "Client" program as root sends along the correct buffer. ConfigurationOutput of
Other informationNo response
|
While some improvements may be possible I don't think it is fixable as the |
Another option is to give the process I think exception in this case might be more helpful and improve the user experience; with message calling out "run program with privileged user or grant |
Triage: If we can't send the payload, we should throw PNSE instead of no-op (today). The exception should have reasonable message as mentioned above. |
Thanks for chiming in. First I'd like to ask what a PSNE and a PNSP exception is. I can't figure it out 😅 Documentation is obviously a very good start. I first developed my application on windows, on which everything was fine. To then move to my Debian laptop where things all of a sudden where not so fine. A remark about the difference in behavior on the MSDN page would've been of great help. I think an exception thrown is a fine solution in the case of a buffer being passed along. If I just wanted to check if something is up I don't care (as a developer) that the native ping utility transparently is invoked for me. That solution also works just fine (for a different scenario than mine). @am11: that seems like a "correct" workaround. For now running as sudo is possible in my case, so that's what I'll probably continue doing, but I'll definitely try out your trick. Haven't used capabilities on executables on Linux before - it's all a learning experience! |
PNSE (PNSP) -> PlatformNotSupportedException |
Description
When creating a new instance of the Ping class and calling the Send method providing a buffer, the buffer is not put into the ICMP message that's sent over the network unless the program is run as root.
Instead the runtime simply forwards the call to the
ping
binary on the system, applying the-s
parameter that tellsping
how large a payload should be sent. From here it's the systemsping
command actually generating the payload and not the payload defined in the C# code.Reproduction Steps
Create a new console application with
dotnet new console -n fancy-project-name
and cd into the directory. Use the following code in Program.csBuild the executable with
dotnet build
and cd into the build output folder. Open a second terminal in the same folder.In terminal window A run the server-part as root
sudo ./fancy-project-name /Server
.In terminal window B run the client-part as non-root
./fancy-project-name /Client
. Notice how the output is not the hex-code for 'A'.Rerun the server as root in terminal window A and now rerun the client as root in terminal window B. This time the server prints the expected bytes.
Expected behavior
The supplied buffer is sent along with the ICMP echo message.
Actual behavior
The wrong payload is sent along with the ICMP echo message.
Regression?
No response
Known Workarounds
Running any "Client" program as root sends along the correct buffer.
Configuration
Output of
dotnet --info
Other information
No response
The text was updated successfully, but these errors were encountered: