diff --git a/CHANGELOG b/CHANGELOG index 99a11b9bc..c809c444e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # Nmap Changelog ($Id$); -*-text-*- +o [Ncat] Use the fallback nsock engine by default in order to maximize + compatibility between systems and use cases. [Henri Doreau] + o [Ncat] Added support for Unix domain sockets. The new -U and --unixsock options activate this mode. [Tomas Hozza] diff --git a/ncat/ncat_connect.c b/ncat/ncat_connect.c index fd331dad0..82cbf8d1a 100644 --- a/ncat/ncat_connect.c +++ b/ncat/ncat_connect.c @@ -477,37 +477,17 @@ bail: return -1; } -#if defined(LINUX) -static int stdin_is_reg(void) { - struct stat buf; - - if (fstat(STDIN_FILENO, &buf) < 0) - bye("fstat(): %s", strerror(errno)); - - return S_ISREG(buf.st_mode); -} -#endif - int ncat_connect(void) { nsock_pool mypool; int rc; -#if defined(LINUX) - /* -- Hack!! - * epoll(7) doesn't support regular files (e.g.: ncat < file.c) - * If we detect that STDIN is a regular file, then we enforce - * the use of the select-based engine. */ - if (stdin_is_reg()) - nsock_set_default_engine("select"); -#elif defined(WIN32) - /* -- Hack!! - * Unconditionally use the select engine on windows. - * The poll engine (WSAPoll) is currently unable to handle - * read events on stdin. + /* Unless explicitely asked not to do so, ncat uses the + * fallback nsock engine to maximize compatibility between + * operating systems and the different use cases. */ - nsock_set_default_engine("select"); -#endif + if (!o.nsock_engine) + nsock_set_default_engine("select"); /* Create an nsock pool */ if ((mypool = nsp_new(NULL)) == NULL) diff --git a/ncat/ncat_core.c b/ncat/ncat_core.c index ae43ee5d7..e6cb16c68 100644 --- a/ncat/ncat_core.c +++ b/ncat/ncat_core.c @@ -160,6 +160,8 @@ void options_init(void) addrset_init(&o.denyset); o.httpserver = 0; + o.nsock_engine = 0; + o.numsrcrtes = 0; o.srcrteptr = 4; diff --git a/ncat/ncat_core.h b/ncat/ncat_core.h index 59755c427..46d8717b1 100644 --- a/ncat/ncat_core.h +++ b/ncat/ncat_core.h @@ -142,6 +142,7 @@ struct options { struct addrset allowset; struct addrset denyset; int httpserver; + int nsock_engine; /* Loose source-routing stuff */ struct in_addr srcrtes[8]; diff --git a/ncat/ncat_main.c b/ncat/ncat_main.c index 42d6a14a2..788de543d 100644 --- a/ncat/ncat_main.c +++ b/ncat/ncat_main.c @@ -424,6 +424,7 @@ int main(int argc, char *argv[]) } else if (strcmp(long_options[option_index].name, "nsock-engine") == 0) { if (nsock_set_default_engine(optarg) < 0) bye("Unknown or non-available engine: %s.", optarg); + o.nsock_engine = 1; } else if (strcmp(long_options[option_index].name, "broker") == 0) { o.broker = 1; /* --broker implies --listen. */