Bug 845075

Summary: ncat: does not call shutdown(2) on EOF
Product: [Fedora] Fedora Reporter: Enrico Scholz <rh-bugzilla>
Component: nmapAssignee: Michal Hlavinka <mhlavink>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 17CC: athmanem, isenfeld, mhlavink, psabata, tmraz
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: nmap-6.01-2.fc17 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 879275 (view as bug list) Environment:
Last Closed: 2012-12-07 04:23:35 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:
Bug Depends On:    
Bug Blocks: 879275    

Description Enrico Scholz 2012-08-01 16:32:15 UTC
Description of problem:

Because ncat is going to replace nc:

Old 'nc' calls shutdown(2) when the corresponding site has been closed.  This makes data transfer very easy because both sites terminate automatically when all data have been sent. New 'ncat' does not shutdown the fds which causes the programs to stay forever:

--- new ---

$ nc -l 1234 > /tmp/foo         # program #1 / server

$ ncat `hostname` 1234          # program #2 / client
type-some-text
^D

---> neither program #1 nor #2 terminate


--- old ---

$ nc -l 1234 > /tmp/foo         # program #1 / server

$ nc `hostname` 1234            # program #2 / client
type-some-text
^D

--> program #1 and #2 terminate on EOF of client


(Note: examples use manually typed input; a more common example is something like

  nc `hostname` 1234 < some-file

which does not work with ncat anymore)


Version-Release number of selected component (if applicable):

nmap-6.00-1.fc17.x86_64

Comment 1 Michal Hlavinka 2012-08-02 11:30:44 UTC
ncat does not call close nor shutdown on EOF. If you want it to terminate connection on EOF, use --send-only. Anyway, I can see it'd be nice if it called shutdown(fd, SHUT_WR) in the above case. I'll ask upstream for their opinion.

Comment 2 Enrico Scholz 2012-08-02 14:56:26 UTC
fwiw, in my use case, the server side reads the file completely over TCP, processes it and gives a status output to client.  With '--sent-only' the status output will be supressed and (yet more) worse, a broken pipe might be seen on server when client terminates the connection on stdin EOF instead of waiting for the server closing the connection.

E.g. server makes:

| timeout -t 600 cat > some-file
| echo "Processing file..."
| process-file
| echo "Done"

Comment 3 Michal Hlavinka 2012-09-19 15:31:57 UTC
upstream accepted the patch

Comment 4 Fedora Update System 2012-09-19 15:35:00 UTC
nmap-6.01-2.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/nmap-6.01-2.fc17

Comment 5 Fedora Update System 2012-09-19 15:35:13 UTC
nmap-6.01-6.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/nmap-6.01-6.fc18

Comment 6 Fedora Update System 2012-09-20 05:57:44 UTC
Package nmap-6.01-6.fc18:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing nmap-6.01-6.fc18'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-14386/nmap-6.01-6.fc18
then log in and leave karma (feedback).

Comment 7 Fedora Update System 2012-09-27 05:09:24 UTC
nmap-6.01-6.fc18 has been pushed to the Fedora 18 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 8 Tomas Mraz 2012-11-22 13:10:51 UTC
This is still not fully fixed. The EOF handling works from client to server but not the other way. That is:

$ nc -l 1234
Type something
^D

$ nc localhost 1234 > data

Does not terminate too.

if I replace the listening netcat with the original (not from nmap) one, it will terminate fine regardless of whether the client side is original or nmap netcat.

Comment 9 Fedora Update System 2012-11-29 12:20:09 UTC
nmap-6.01-3.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/nmap-6.01-3.fc17

Comment 10 Fedora Update System 2012-11-29 12:20:24 UTC
nmap-6.01-2.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/nmap-6.01-2.fc16

Comment 11 Fedora Update System 2012-11-29 12:20:35 UTC
nmap-6.01-8.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/nmap-6.01-8.fc18

Comment 12 Fedora Update System 2012-11-30 06:42:11 UTC
Package nmap-6.01-8.fc18:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing nmap-6.01-8.fc18'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-19398/nmap-6.01-8.fc18
then log in and leave karma (feedback).

Comment 13 Fedora Update System 2012-12-07 04:23:38 UTC
nmap-6.01-8.fc18 has been pushed to the Fedora 18 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 14 Fedora Update System 2012-12-15 18:03:13 UTC
nmap-6.01-3.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 15 Fedora Update System 2013-01-05 06:51:11 UTC
nmap-6.01-2.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.