From 0909f123082dd81b68611d923bb42d7b9bc03067 Mon Sep 17 00:00:00 2001 From: sean Date: Sat, 30 Jun 2012 00:36:15 +0000 Subject: [PATCH] Removed the log-errors option from the code, by treating it as if it was always true. This was done for the action item of o Remove Nmap's --log-errors feature and make its behavior the default. I also updated the docs/refguide.xml to reflect this change. I have not yet compiled the Dockbook.xml however. --- NmapOps.cc | 1 - NmapOps.h | 3 +-- docs/refguide.xml | 31 +------------------------------ nmap.cc | 1 - nmap_error.cc | 30 ++++++++++++------------------ 5 files changed, 14 insertions(+), 52 deletions(-) diff --git a/NmapOps.cc b/NmapOps.cc index b539b2772..01044e741 100644 --- a/NmapOps.cc +++ b/NmapOps.cc @@ -316,7 +316,6 @@ void NmapOps::Initialize() { xsl_stylesheet = NULL; spoof_mac_set = false; mass_dns = true; - log_errors = false; deprecated_xml_osclass = false; resolve_all = 0; dns_servers = NULL; diff --git a/NmapOps.h b/NmapOps.h index 345571a6d..120104c62 100644 --- a/NmapOps.h +++ b/NmapOps.h @@ -321,8 +321,7 @@ class NmapOps { int resolve_all; char *dns_servers; - // Logging options - bool log_errors; + // If true, write as in xmloutputversion 1.03 // rather than as in 1.04 and later. bool deprecated_xml_osclass; diff --git a/docs/refguide.xml b/docs/refguide.xml index 8f5046619..8598013f1 100644 --- a/docs/refguide.xml +++ b/docs/refguide.xml @@ -3872,36 +3872,7 @@ hosts with at least one by Nmap. This is useful for debugging routing problems or device mischaracterization (such as Nmap treating a PPP connection as ethernet). - - - - (Log errors/warnings to normal mode output file) - - - - - Warnings and errors printed by Nmap usually go only to - the screen (interactive output), leaving any normal-format - output files (usually specified with ) - uncluttered. When you do want to see those messages in the - normal output file you specified, add this option. It is - useful when you aren't watching the interactive output or - when you want to record errors while debugging a problem. - The error and warning messages will still appear in - interactive mode too. This won't work for most errors - related to bad command-line arguments because Nmap may not - have initialized its output files yet. In addition, some - Nmap error and warning messages use a different system which - does not yet support this option. - - An alternative to is - redirecting interactive output (including the standard error - stream) to a file. Most Unix shells make this - approach easy, though it can be difficult on Windows. - - - - + Miscellaneous output options diff --git a/nmap.cc b/nmap.cc index 4b3f883fb..80119dce4 100644 --- a/nmap.cc +++ b/nmap.cc @@ -847,7 +847,6 @@ void parse_options(int argc, char **argv) { } else if (optcmp(long_options[option_index].name, "dns-servers") == 0) { o.dns_servers = strdup(optarg); } else if (optcmp(long_options[option_index].name, "log-errors") == 0) { - o.log_errors = 1; } else if (optcmp(long_options[option_index].name, "deprecated-xml-osclass") == 0) { o.deprecated_xml_osclass = true; } else if (strcmp(long_options[option_index].name, "webxml") == 0) { diff --git a/nmap_error.cc b/nmap_error.cc index 44023e0a5..1e2540eb5 100644 --- a/nmap_error.cc +++ b/nmap_error.cc @@ -115,12 +115,11 @@ void fatal(const char *fmt, ...) { va_start(ap, fmt); log_vwrite(LOG_STDERR, fmt, ap); va_end(ap); - if (o.log_errors) { - va_start(ap, fmt); - log_vwrite(LOG_NORMAL, fmt, ap); - va_end(ap); - } - log_write(o.log_errors? LOG_NORMAL|LOG_STDERR : LOG_STDERR, "\nQUITTING!\n"); + va_start(ap, fmt); + log_vwrite(LOG_NORMAL, fmt, ap); + va_end(ap); + + log_write(LOG_NORMAL|LOG_STDERR, "\nQUITTING!\n"); if (xml_tag_open()) xml_close_start_tag(); @@ -163,13 +162,10 @@ void error(const char *fmt, ...) { va_start(ap, fmt); log_vwrite(LOG_STDERR, fmt, ap); va_end(ap); - - if (o.log_errors) { - va_start(ap, fmt); + va_start(ap, fmt); log_vwrite(LOG_NORMAL, fmt, ap); va_end(ap); - } - log_write(o.log_errors? LOG_NORMAL|LOG_STDERR : LOG_STDERR, "\n"); + log_write(LOG_NORMAL|LOG_STDERR , "\n"); return; } @@ -197,7 +193,7 @@ void pfatal(const char *fmt, ...) { Vsnprintf(errbuf, sizeof(errbuf), fmt, ap); va_end(ap); - log_write(o.log_errors? LOG_NORMAL|LOG_STDERR : LOG_STDERR, "%s: %s (%d)\n", + log_write(LOG_NORMAL|LOG_STDERR, "%s: %s (%d)\n", errbuf, strerror_s, error_number); if (xml_tag_open()) @@ -230,7 +226,7 @@ void pfatal(const char *fmt, ...) { HeapFree(GetProcessHeap(), 0, strerror_s); #endif - if (o.log_errors) log_flush(LOG_NORMAL); + log_flush(LOG_NORMAL); fflush(stderr); exit(1); } @@ -255,19 +251,17 @@ void gh_perror(const char *fmt, ...) { va_start(ap, fmt); log_vwrite(LOG_STDERR, fmt, ap); va_end(ap); - if (o.log_errors) { - va_start(ap, fmt); + va_start(ap, fmt); log_vwrite(LOG_NORMAL, fmt, ap); va_end(ap); - } - log_write(o.log_errors? LOG_NORMAL|LOG_STDERR : LOG_STDERR, ": %s (%d)\n", + log_write(LOG_NORMAL|LOG_STDERR, ": %s (%d)\n", strerror_s, error_number); #ifdef WIN32 HeapFree(GetProcessHeap(), 0, strerror_s); #endif - if (o.log_errors) log_flush(LOG_NORMAL); + log_flush(LOG_NORMAL); fflush(stderr); return; }