Nmap Development mailing list archives
Re: BUG: ncat does not work when file is used as input
From: Henri Doreau <henri.doreau () gmail com>
Date: Sat, 4 Aug 2012 00:04:16 +0200
Hi, I had to make a tough choice: either introduce a cheesy hack into the code of ncat or bloat nsock. As explained in the link I posted earlier[1], epoll(7) can't deal with regular files the same way it does with sockets and pipes. The effect is what Michal could observe: "ncat localhost 1234 < file.c" fails, although "cat file.c | ncat localhost 1234" would work. The right way(tm) to do polling on regular file would involve two kind of recent linux-specific mechanisms which are eventfd and aio. I first tried this approach, and despite being fun this brings an absolutely undesired level of complexity to nsock. Especially since it's only for this specific case. Nsock, as name suggests, mostly handles sockets. To sum up what I did (maybe someone comes up with a smarter approach): - hook epoll_ctl() when registering/unregistering events for STDIN_FILENO - create an eventfd(), stored in the engine_info structure (hurk!) - Schedule an aio_read() as a replacement for the actual read(). This is where it started to become way too intrusive. The second approach I tried (patch attached) is hackish but simple, efficient and far less intrusive. If we're on linux (then epoll() is expected to be used, but not even necessarily) and stdin is a regular file, then we enforce the use of the select(2)-based nsock engine. Regards. [1] https://bugzilla.kernel.org/show_bug.cgi?id=15272 -- Henri
Attachment:
ncat_reg_stdin.diff
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:
- BUG: ncat does not work when file is used as input Michal Hlavinka (Aug 03)
- Re: BUG: ncat does not work when file is used as input Henri Doreau (Aug 03)
- Re: BUG: ncat does not work when file is used as input Henri Doreau (Aug 03)
- Re: BUG: ncat does not work when file is used as input Henri Doreau (Aug 09)
- Re: BUG: ncat does not work when file is used as input Michal Hlavinka (Aug 13)
- Re: BUG: ncat does not work when file is used as input Henri Doreau (Aug 18)
- Re: BUG: ncat does not work when file is used as input Henri Doreau (Aug 03)
- Re: BUG: ncat does not work when file is used as input Henri Doreau (Aug 03)