| Summary: | ncat does not auto-disconnect upon server termination | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Christopher Gurley <ccgurley> |
| Component: | nmap | Assignee: | Pavel Zhukov <pzhukov> |
| Status: | CLOSED DUPLICATE | QA Contact: | BaseOS QE Security Team <qe-baseos-security> |
| Severity: | low | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 7.2 | CC: | dmiller, gsgatlin |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2017-10-23 15:25:18 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
For the moment, there's not a good workaround for this. Ncat previously would quit as soon as it received EOF from the server, but this was unsatisfactory in cases where the server was willing to continue receiving data after EOF. So what happens is this: First, the server closes the connection with a FIN, putting itself into FIN_WAIT_1. The client (Ncat) acknowledges this with ACK, and its socket goes into CLOSE_WAIT. In this state, it can continue to send data. The server's OS is waiting for the FIN from the client. When you enter the first line in the client, it goes out in a PSH packet, and the server, having no listening process, sends a RST. This closes down the socket on the local end, but Ncat has no way of knowing this until it tries to do some sort of operation on the socket again. It does this with the second line, and encounters the EPIPE. To see a case where this is behavior is expected, run the server side as `echo "hello" | ncat -l 2222`. When Ncat connects to this server, it immediately receives the "hello" as well as EOF from the server. But it also has a chance to send whatever it wants back to the server, and that will be received. So the trick is distinguishing between a server that is done sending but able to receive, and one that is completely done and not able to receive. At least one send operation is really necessary in this case. I am looking into it to see if there is some way to detect the socket state after the first line is sent (which results in the RST being received, which ought to affect the socket in some detectable way). It looks like the epoll Nsock engine might get some sort of notification of this, thought the default select engine does not. After I gather some notes and ask the Nmap development mailing list for thoughts, I'll post the URL to the message archive here. *** This bug has been marked as a duplicate of bug 1078244 *** |
Description of problem: When connection is broken between either a local or remote ncat server the client does not automatically disconnect as it did in rhel 6 Version-Release number of selected component (if applicable): nmap-ncat-6.40-7.el7.x86_64 How reproducible: Can be done on a minimal install of RHEL 7.2 with the nmap-ncat package Steps to Reproduce: 1. run ncat -l 2222 (or some port not in use) 2. run ncat localhost 2222 3. see that connection was successful 4. close the ncat process that is listening (ctrl+c) 5. client ncat will let you enter a line or two before reporting broken pipe Actual results: client continues to run until the user enters a line or two Expected results: client disconnects as soon as connection with server is broken. This can be seen by doing the same thing on a RHEL 6.9 box. Additional info: Please disregard if this was intentional. Thanks, Chris