diff --git a/docs/refguide.xml b/docs/refguide.xml index 01b454587..54b0b70ad 100644 --- a/docs/refguide.xml +++ b/docs/refguide.xml @@ -2318,12 +2318,12 @@ found: $NMAPDIRNMAPDIR environment variable ~/.nmap (not searched on Windows).nmap directory -HOME\AppData\Roaming\nmap (only on Windows).nmap directory +APPDATA\nmap (only on Windows).nmap directory the directory containing the nmap executable the directory containing the nmap -executable, followed by ../share/nmap -NMAPDATADIRNMAPDATADIR +executable, followed by ../share/nmap (not searched on Windows) +NMAPDATADIRNMAPDATADIR (not searched on Windows) the current directory. diff --git a/docs/scripting.xml b/docs/scripting.xml index ff4817593..549bcd4f9 100644 --- a/docs/scripting.xml +++ b/docs/scripting.xml @@ -665,11 +665,12 @@ found: $NMAPDIRNMAPDIR environment variable ~/.nmap (not searched on Windows).nmap directory +APPDATA\nmap (only on Windows).nmap directory the directory containing the nmap executable the directory containing the nmap -executable, followed by ../share/nmap -NMAPDATADIRNMAPDATADIR +executable, followed by ../share/nmap (not searched on Windows) +NMAPDATADIRNMAPDATADIR (not searched on Windows) the current directory. diff --git a/nmap.cc b/nmap.cc index 2040f0069..a6a6cfbe8 100644 --- a/nmap.cc +++ b/nmap.cc @@ -2558,13 +2558,15 @@ static int nmap_fetchfile_sub(char *filename_returned, int bufferlen, const char After that, the following directories are searched in order: * --datadir - * $NMAPDIR - * [Non-Windows only] ~/.nmap - * [Windows only] ...\Users\\AppData\Roaming\nmap + * $NMAPDIR environment variable + * User's home Nmap directory: + - [Windows] %APPDATA%\nmap + - [Non-Windows] ~/.nmap * The directory containing the nmap binary - * [Non-Windows only] The directory containing the nmap binary plus - "/../share/nmap" - * NMAPDATADIR */ + * [Non-Windows only]: + - The directory containing the nmap binary plus "../share/nmap" + - NMAPDATADIR (usually $prefix/share/nmap) + */ int nmap_fetchfile(char *filename_returned, int bufferlen, const char *file) { std::map::iterator iter; char buf[BUFSIZ]; @@ -2681,12 +2683,14 @@ static int nmap_fetchfile_sub(char *filename_returned, int bufferlen, const char free(dir); } +#ifndef WIN32 if (!foundsomething) { res = Snprintf(filename_returned, bufferlen, "%s/%s", NMAPDATADIR, file); if (res > 0 && res < bufferlen) { foundsomething = file_is_readable(filename_returned); } } +#endif if (foundsomething && (*filename_returned != '.')) { res = Snprintf(dot_buffer, sizeof(dot_buffer), "./%s", file); diff --git a/nmap_winconfig.h b/nmap_winconfig.h index 2dcef6403..10c5dd485 100644 --- a/nmap_winconfig.h +++ b/nmap_winconfig.h @@ -138,7 +138,6 @@ like strcpy() even if they are done safely */ #define _CRT_SECURE_NO_DEPRECATE 1 #define NMAP_PLATFORM "i686-pc-windows-windows" -#define NMAPDATADIR "c:\\nmap" /* FIXME: I really need to make this dynamic */ #define HAVE_OPENSSL 1 #define HAVE_SSL_SET_TLSEXT_HOST_NAME 1 diff --git a/osscan.cc b/osscan.cc index c805dad86..11d6a5362 100644 --- a/osscan.cc +++ b/osscan.cc @@ -1133,7 +1133,7 @@ FingerPrintDB *parse_fingerprint_reference_file(const char *dbname) { char filename[256]; if (nmap_fetchfile(filename, sizeof(filename), dbname) != 1) { - fatal("OS scan requested but I cannot find %s file. It should be in %s, ~/.nmap/ or .", dbname, NMAPDATADIR); + fatal("OS scan requested but I cannot find %s file.", dbname); } /* Record where this data file was found. */ o.loaded_data_files[dbname] = filename; diff --git a/service_scan.cc b/service_scan.cc index 93403e757..ecd360c75 100644 --- a/service_scan.cc +++ b/service_scan.cc @@ -1439,7 +1439,7 @@ static void parse_nmap_service_probes(AllProbes *AP) { char filename[256]; if (nmap_fetchfile(filename, sizeof(filename), "nmap-service-probes") != 1){ - fatal("Service scan requested but I cannot find nmap-service-probes file. It should be in %s, ~/.nmap/ or .", NMAPDATADIR); + fatal("Service scan requested but I cannot find nmap-service-probes file."); } parse_nmap_service_probe_file(AP, filename);