summaryrefslogtreecommitdiff
path: root/missing
diff options
context:
space:
mode:
authorAli Abdulkadir <autostart.ini@gmail.com>2017-11-15 18:39:39 +0300
committerAli Abdulkadir <autostart.ini@gmail.com>2017-11-15 18:39:39 +0300
commit4a000d3557e499b669b9193763939b82d2e48828 (patch)
treee67be0237de36d3944ce4e1aab1727c9321e3815 /missing
parent768d80e11f6afdcc8ed088d0723507140a7a633e (diff)
downloadtcpdump-4a000d3557e499b669b9193763939b82d2e48828.tar.gz
Updates for getservent.c
- fixed none _WIN32 implementation - on windows, see if a services file exists in the same directory as tcpdump and use that
Diffstat (limited to 'missing')
-rw-r--r--missing/getservent.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/missing/getservent.c b/missing/getservent.c
index c2dc620d..48b7465c 100644
--- a/missing/getservent.c
+++ b/missing/getservent.c
@@ -49,26 +49,26 @@ int _serv_stayopen;
const char *etc_path(const char *file);
/*
-* Return either "%SYSTEMROOT%\System32\drivers\etc\<file>",
-* $PREFIX/etc/<file> or simply "<file>" if those failed.
+* Check if <file> exists in the current directory and, if so, return it.
+* Else return either "%SYSTEMROOT%\System32\drivers\etc\<file>"
+* or $PREFIX/etc/<file>.
* "<file>" is aka __PATH_SERVICES (aka "services" on Windows and
-* "/etc/services" on other platforms that would need this)
+* "/etc/services" on other platforms that would need this).
*/
const char *etc_path(const char *file)
{
const char *env = getenv(__PATH_SYSROOT);
static char path[_MAX_PATH];
- if (!env)
-/*
-* #ifdef _DEBUG
-* printf("Warning: Environment Variable \"%s\" invalid\nResorting to [CurrentDirectory]/%s\n",
-* __PATH_SYSROOT, file);
-* #endif
-*/
+ /* see if "<file>" exists locally or whether __PATH_SYSROOT is valid */
+ if (fopen(file, "r") || !env)
return (file);
-
+ else
+#ifdef _WIN32
snprintf(path, sizeof(path), "%s%s%s", env, __PATH_ETC_INET, file);
+#else
+ snprintf(path, sizeof(path), "%s%s", env, file);
+#endif
return (path);
}