Bug 1944131

Summary: netcat does not properly terminate on EOF (nmap-ncat works well)
Product: [Fedora] Fedora Reporter: Jakub Jelen <jjelen>
Component: netcatAssignee: Robert Scheck <redhat-bugzilla>
Status: CLOSED EOL QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 34CC: redhat-bugzilla
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-06-08 06:28:16 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 Jakub Jelen 2021-03-29 11:20:47 UTC
Description of problem:
A week ago, this new package landed in Fedora, introducing alternatives to the /bin/nc.

The new netcat provides the following

  /usr/bin/nc
  /usr/bin/netcat

While the old one:

  /usr/bin/nc
  /usr/bin/ncat

The nc binary symlins either of these based on the non-copletely transparent update-alternatives.

While the ncat alternative properly detected the EOF and closes connection:

(first terminal)
# ncat -l 8080
XXX
# 

(second terminal)
# echo XXX | ncat localhost 8080
# 

the new netcat does not and keeps hanging both client and server after reading the EOF:

(first terminal)
# netcat -l 8080
XXX

(second terminal)
# echo XXX | netcat localhost 8080


Version-Release number of selected component (if applicable):
netcat-1.217-3.fc34.x86_64
nmap-ncat-7.80-11.fc34.x86_64


How reproducible:
always

Steps to Reproduce:
1. Send EOF to netcat

Actual results:
EOF is not propagated to the other side of socket

Expected results:
the EOF is sent to listener, socket is closed, command terminates.

Additional info:
This is a regression if the netcat gets installed instead of nmap-ncat.

Comment 1 Jakub Jelen 2021-03-29 11:22:49 UTC
This particular use case is even described in the manual page of netcat:

> The connection may be terminated using an EOF (ā€˜^D’).

(assuming the echo/bash sends the EOF correctly to the netcat)

Comment 2 Robert Scheck 2021-03-29 12:02:27 UTC
I am not sure whether I can address this, because like /usr/sbin/sendmail is not a 100% alternative when using Postfix, Exim etc. rather Sendmail itself, it's similar for /usr/bin/nc. Same situation also applies e.g. for /usr/bin/ksh regarding ksh93 or mksh. In case a software relies on a specific behaviour it IMHO should use the specific implementation directly (e.g. ncat) rather via the alternatives symlink (nc).

Your report however brings me to the question whether you installed netcat yourself explicitly or whether it happened by accident (sloppy package dependency or packaging mistake etc.). The intention was to provide the original OpenBSD netcat additionally for those who want it, not to break everybody's scripts, behaviour etc. by default (like the hard and mostly by Red-Hat-driven switch from the original "nc" RPM package to "nmap-ncat" like 5+ years ago did).

Comment 3 Jakub Jelen 2021-03-29 13:01:22 UTC
Indeed, I am not striving for 100% compatibility, but I would like to have the a use case which is described in the manual page of the new netcat package working (as mentioned in the comment #1).

The dependency in a test I had was written just as a "nc" and in one system, where the nmap-ncat was installed, the above worked just fine, but in other system where nothing was installed, the netcat got a preference for some reason, which might cause some problems for some users. Not sure how the alternatives preferences and such work in detail though.

Comment 4 Ben Cotton 2022-05-12 16:55:20 UTC
This message is a reminder that Fedora Linux 34 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 34 on 2022-06-07.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '34'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 34 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 5 Ben Cotton 2022-06-08 06:28:16 UTC
Fedora Linux 34 entered end-of-life (EOL) status on 2022-06-07.

Fedora Linux 34 is no longer maintained, which means that it
will not receive any further security or bug fix updates. As a result we
are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release.

Thank you for reporting this bug and we are sorry it could not be fixed.