Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1328996

Summary: ncat does not auto-disconnect upon server termination
Product: Red Hat Enterprise Linux 7 Reporter: Christopher Gurley <ccgurley>
Component: nmapAssignee: Pavel Zhukov <pzhukov>
Status: CLOSED DUPLICATE QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: low Docs Contact:
Priority: unspecified    
Version: 7.2CC: 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:
Embargoed:

Description Christopher Gurley 2016-04-20 20:28:21 UTC
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

Comment 2 Daniel Miller 2017-03-18 04:00:55 UTC
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.

Comment 4 Pavel Zhukov 2017-10-23 15:25:18 UTC

*** This bug has been marked as a duplicate of bug 1078244 ***