Nmap Development mailing list archives

Nmap doesn't register signal handlers


From: ithilgore <ithilgore.ryu.l () gmail com>
Date: Wed, 12 Aug 2009 00:52:21 +0300

Hello.

While experimenting with signal handlers in Ncrack, I noticed that Nmap never
registers the sigdie() handler. This is caused, because there is no check in the
configure.ac for the signal function, and thus HAVE_SIGNAL stays always
undefined. You can see that the signal handler doesn't work, because no message
is printed whenever you press Ctrl+C to stop Nmap from continuing. Normally,
something like "caught SIGNAL <signame>, cleaning up" should be printed,
according to sigdie():


void sigdie(int signo) {
  int abt = 0;

  fflush(stdout);

  switch(signo) {
  case SIGINT:
    error("caught SIGINT signal, cleaning up");
    break;

#ifdef SIGTERM
  case SIGTERM:
    error("caught SIGTERM signal, cleaning up");
    break;
#endif

#ifdef SIGHUP
  case SIGHUP:
    error("caught SIGHUP signal, cleaning up");
    break;
#endif

#ifdef SIGSEGV
  case SIGSEGV:
    error("caught SIGSEGV signal, cleaning up");
    abt = 1;
    break;
#endif

#ifdef SIGBUS
  case SIGBUS:
    error("caught SIGBUS signal, cleaning up");
    abt = 1;
    break;
#endif

  default:
    error("caught signal %d, cleaning up", signo);
    abt = 1;
    break;
  }

  fflush(stderr);
  log_close(LOG_MACHINE|LOG_NORMAL|LOG_SKID);
  if (abt) abort();
  exit(1);
}


In Ncrack I just added this line in its configure.ac :

AC_CHECK_FUNCS(signal)

and added

#undef HAVE_SIGNAL

at ncrack_config.h.in


The equivalent works for Nmap. Let me know if there was another reason that you
may have deliberately chosen not to compile in signal support (e.g for debugging
reasons) so that I can commit the changes to Nmap's svn repository, if needed.

Regards,
ithilgore






_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org


Current thread: