diff -rBu nmap-5.51-orig//configure.ac nmap-5.51/configure.ac --- nmap-5.51-orig//configure.ac 2010-09-29 18:09:26.000000000 +0200 +++ nmap-5.51/configure.ac 2011-09-27 04:14:49.669996252 +0200 @@ -8,6 +8,10 @@ dnl installed. This gets replaced with AM_GNU_GETTEXT for full gettext support. AM_NLS +AC_ARG_VAR([SYSETCDIR], [system config directory location, Default = "/etc"]) +AS_IF([test "x$SYSETCDIR" = x], [SYSETCDIR="/etc"]) +AC_DEFINE_UNQUOTED([SYS_ETC_DIR], ["$SYSETCDIR"]) + AC_ARG_WITH(localdirs, AC_HELP_STRING([--with-localdirs], [Explicitly ask compiler to use /usr/local/{include,libs} if they exist ]), [ case "$with_localdirs" in diff -rBu nmap-5.51-orig//nmap_config.h.in nmap-5.51/nmap_config.h.in --- nmap-5.51-orig//nmap_config.h.in 2011-01-21 01:04:16.000000000 +0100 +++ nmap-5.51/nmap_config.h.in 2011-09-27 04:08:55.328239161 +0200 @@ -190,4 +190,6 @@ #undef NETBSD #undef MACOSX +#undef SYS_ETC_DIR + #endif /* CONFIG_H */ diff -rBu nmap-5.51-orig//nmap_dns.cc nmap-5.51/nmap_dns.cc --- nmap-5.51-orig//nmap_dns.cc 2011-01-21 01:04:16.000000000 +0100 +++ nmap-5.51/nmap_dns.cc 2011-09-27 16:22:50.790512326 +0200 @@ -940,9 +940,9 @@ char fmt[32]; char ipaddr[INET6_ADDRSTRLEN]; - fp = fopen("/etc/resolv.conf", "r"); + fp = fopen(SYS_ETC_DIR "/resolv.conf", "r"); if (fp == NULL) { - if (firstrun) error("mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers"); + if (firstrun) error("mass_dns: warning: Unable to open %s/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers", SYS_ETC_DIR); return; } @@ -1101,7 +1101,7 @@ parse_etchosts(tpbuf); #else - parse_etchosts("/etc/hosts"); + parse_etchosts(SYS_ETC_DIR "/hosts"); #endif } diff -rBu nmap-5.51-orig//nmap_rpc.cc nmap-5.51/nmap_rpc.cc --- nmap-5.51-orig//nmap_rpc.cc 2011-01-21 01:04:16.000000000 +0100 +++ nmap-5.51/nmap_rpc.cc 2011-09-27 16:23:30.454709015 +0200 @@ -131,8 +131,8 @@ ri.numbers = (unsigned long *) cp_alloc(ri.num_alloc * sizeof(unsigned long)); if (nmap_fetchfile(filename, sizeof(filename), "nmap-rpc") != 1) { - error("Unable to find nmap-rpc! Resorting to /etc/rpc"); - strcpy(filename, "/etc/rpc"); + error("Unable to find nmap-rpc! Resorting to %s/rpc", SYS_ETC_DIR); + strncpy(filename, SYS_ETC_DIR "/rpc", 511); } fp = fopen(filename, "r"); diff -rBu nmap-5.51-orig//protocols.cc nmap-5.51/protocols.cc --- nmap-5.51-orig//protocols.cc 2011-01-21 01:04:16.000000000 +0100 +++ nmap-5.51/protocols.cc 2011-09-27 16:24:34.107024643 +0200 @@ -116,8 +116,8 @@ int res; if (nmap_fetchfile(filename, sizeof(filename), "nmap-protocols") != 1) { - error("Unable to find nmap-protocols! Resorting to /etc/protocols"); - strcpy(filename, "/etc/protocols"); + error("Unable to find nmap-protocols! Resorting to %s/protocols", SYS_ETC_DIR); + strncpy(filename, SYS_ETC_DIR "/protocols", 511); } fp = fopen(filename, "r"); diff -rBu nmap-5.51-orig//services.cc nmap-5.51/services.cc --- nmap-5.51-orig//services.cc 2011-01-21 01:04:16.000000000 +0100 +++ nmap-5.51/services.cc 2011-09-27 16:25:13.115218075 +0200 @@ -162,8 +162,8 @@ if (nmap_fetchfile(filename, sizeof(filename), "nmap-services") != 1) { #ifndef WIN32 - error("Unable to find nmap-services! Resorting to /etc/services"); - strcpy(filename, "/etc/services"); + error("Unable to find nmap-services! Resorting to %s/services", SYS_ETC_DIR); + strncpy(filename, SYS_ETC_DIR "/services", 511); #else int len, wnt = GetVersion() < 0x80000000; error("Unable to find nmap-services! Resorting to /etc/services");