Nmap Development mailing list archives
Re: RFE: ncat should call shutdown on EOF
From: Michal Hlavinka <mhlavink () redhat com>
Date: Tue, 27 Nov 2012 16:31:57 +0100
On 09/10/2012 10:17 PM, David Fifield wrote:
On Mon, Sep 10, 2012 at 09:23:20AM +0200, Michal Hlavinka wrote:On 09/07/2012 03:43 PM, Henri Doreau wrote:2012/8/2 Michal Hlavinka <mhlavink () redhat com>:Hi, we're replacing nc in fedora with ncat and testing if the behaviour is similar enough. One of the differences is old nc calls shutdown on EOF. When ncat is used and gets EOF (ctrl-d) as an input, it does nothing unless --send-only is used. Would it be possible to call shutdown(fd,SHUT_WR) when ncat gets EOF in input? I used following patch. It works, but I don't know if it's correct way and correct place for this. --- nmap-6.01/ncat/ncat_connect.c.shutdown 2012-06-19 09:49:19.000000000 +0200 +++ nmap-6.01/ncat/ncat_connect.c 2012-08-02 15:10:34.173929687 +0200 @@ -713,7 +713,7 @@ static void read_stdin_handler(nsock_poo if (o.sendonly) { /* In --send-only mode, exit after EOF on stdin. */ nsock_loop_quit(nsp); - } + } else shutdown(nsi_getsd(cs.sock_nsi), SHUT_WR); return; } else if (status == NSE_STATUS_ERROR) { loguser("%s.\n", socket_strerror(nse_errorcode(evt))); Cheers, MichalSounds good to me. Any concern for supported non UNIX-like platforms?This function exists on UNIXes and Windows, I did not check other platforms. Seems, there is one difference - windows uses different defines, so this is needed: #ifndef SHUT_WR # define SHUT_WR SD_SEND #endif in this file or in some header file.This sounds good to me. Henri, since you have already looked at this patch, would you apply it? Ideally there should be a new test for this in test/ncat-test.pl. Michal, would you take a look at that file and see if you can write a simple test? It will be along the lines of 1) Do a server_client_test, 2) write to $c_in then close $c_in, 3) check that you read EOF from $s_out.
Hi,I found that the eof shutdown patch was incomplete, because it fixes only one part of two. Attached is second part (server side) of the fix. This time with a test. I know nothing about perl except it exists, but I used test for previous part as template.
Cheers, Michal
Attachment:
ncat-shutdown2.patch
Description:
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://seclists.org/nmap-dev/
Current thread:
- Re: RFE: ncat should call shutdown on EOF David Fifield (Nov 06)
- Re: RFE: ncat should call shutdown on EOF Henri Doreau (Nov 07)
- Re: RFE: ncat should call shutdown on EOF David Fifield (Nov 07)
- Re: RFE: ncat should call shutdown on EOF Henri Doreau (Nov 07)
- Re: RFE: ncat should call shutdown on EOF David Fifield (Nov 07)
- Re: RFE: ncat should call shutdown on EOF Henri Doreau (Nov 08)
- Re: RFE: ncat should call shutdown on EOF David Fifield (Nov 07)
- Re: RFE: ncat should call shutdown on EOF Henri Doreau (Nov 07)
- <Possible follow-ups>
- Re: RFE: ncat should call shutdown on EOF Michal Hlavinka (Nov 28)
- Re: RFE: ncat should call shutdown on EOF David Fifield (Nov 28)