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 1890475

Summary: [RFE] ncat: change default behavior and close immediately when the server is done sending
Product: Red Hat Enterprise Linux 8 Reporter: Phil Jasbutis <pjasbuti>
Component: nmapAssignee: Martin Osvald 🛹 <mosvald>
Status: CLOSED WONTFIX QA Contact: František Hrdina <fhrdina>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.2CC: fhrdina, mschwabe
Target Milestone: rcKeywords: FutureFeature, TestCaseNeeded, Triaged
Target Release: 8.0Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 16:40:38 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 Phil Jasbutis 2020-10-22 10:48:10 UTC
3. What is the nature and description of the request?

- Customer is using ncat to transfer files between two hosts by using rsync
- when copy operation is finished server closed socket for writing by calling shutdown(sd, SHUT_WR).
- client sees this and continues, because it can still send data (if you do not use --recv-only option)
- client socket keeps open (CLOSE_WAIT) even server has send shutdown
- when server socket is closed, ncat can't distinguish whether it's closed or half closed, until it tries to send something.


4. Why does the customer need this? (List the business requirements here)

- cp files/data between two sockets and terminate also client when server is done


5. How would the customer like to achieve this? (List the functional requirements here)

a) change the default behavior, so that client also performs shutdown after receiving server shutdown
b) Allowing the -k option to bring back the (current) keep alive behavior in client mode


6. For each functional requirement listed, specify how Red Hat and the customer can test to confirm the requirement is successfully implemented.

Example:

a)

root@server# useradd user1
root@server# su - user1
user1@server# ncat -4 --allow <client IP> -l -e /bin/bash

root@client# ncat <server IP>
exit

root@client# lsof -p <ncat pid> | grep CLOSE_WAIT
root@client#


b)

root@server# useradd user1
root@server# su - user1
root@server# ncat -4 --allow <client IP> -k -l -e /bin/bash

root@client# ncat <server IP>
exit

root@client# lsof -p <ncat pid> | grep CLOSE_WAIT
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF      NODE NAME
ncat    <pid> root    3u  IPv4 468854      0t0       TCP <client>:50546-><server>:31337 (CLOSE_WAIT)


7. Is there already an existing RFE upstream or in Red Hat Bugzilla?

- found RHBZ#1078244 -> it is confirmed that the actual behavior is not a bug and BZ is closed with WONTFIX
- found upstream mailing list [https://seclists.org/nmap-dev/2017/q2/134] where upstream maintainer suggest to change default behavior and implement parameter -k
- found [https://github.com/nmap/nmap/issues/1779] where an extra argument --exit-on-close is requested to change the current behavior


8. Does the customer have any specific timeline dependencies and which release would they like to target (i.e. RHEL5, RHEL6)?

- no, asap


9. Is the sales team involved in this request and do they have any additional input?

- no


10. List any affected packages or components.

- nmap-ncat


11. Would the customer be able to assist in testing this functionality if implemented?

- yes

Comment 4 Phil Jasbutis 2021-04-14 09:21:21 UTC
a) testcase to verify the default behavior on exit is changed

  1. setup ncat listener:

  terminalA # ncat -4 -l -e /bin/bash


  2. open a new terminal and connect: 

  terminalB # nc localhost


  3. type "exit" on the client side (terminalB)

  terminalB # exit


  4. on terminalA listener exists, on terminalB client exits

  5. verify that there is no connection on CLOSE_WAIT on terminalA

  terminalA # lsof | grep "^nc" | grep CLOSE_WAIT 
  terminalA #



b) testcase to verify "--no-terminate" behaves like Ncat's previous behavior

  1. setup ncat listener:

  terminalA # ncat --no-terminate -4 -l -e /bin/bash


  2. open a new terminal and connect: 

  terminalB # nc localhost


  3. type "exit" on the client side (terminalB)

  terminalB # exit


  4. on terminalA listener exists, on terminalB client does _not_ return to prompt


  5. verify that there is a nc connection with status CLOSE_WAIT on terminalA

  terminalA # lsof | grep "^nc" | grep CLOSE_WAIT
  nc 319261 user 3u IPv4 5147699 0t0 TCP host:47682->host:31337 (CLOSE_WAIT)

Comment 7 Martin Osvald 🛹 2022-05-10 16:40:38 UTC
I tried to get this into Fedora and received very negative feedback that this change would break so many existing scripts that cannot be easily fixed to accommodate the proposed change.

Therefore closing this as WONTFIX as don't want to disrupt behavior seen for ages which would definitely lead to an extreme amount of customer cases.