aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--capinfos.c2
-rw-r--r--captype.c2
-rw-r--r--cmakeconfig.h.in3
-rw-r--r--dftest.c2
-rw-r--r--editcap.c2
-rw-r--r--mergecap.c2
-rw-r--r--randpkt.c2
-rw-r--r--rawshark.c2
-rw-r--r--reordercap.c2
-rw-r--r--sharkd.c2
-rw-r--r--tfshark.c2
-rw-r--r--tools/oss-fuzzshark/fuzzshark.c2
-rw-r--r--tshark.c2
-rw-r--r--ui/gtk/main.c2
-rw-r--r--wireshark-qt.cpp3
-rw-r--r--wsutil/filesystem.c88
-rw-r--r--wsutil/filesystem.h2
17 files changed, 46 insertions, 76 deletions
diff --git a/capinfos.c b/capinfos.c
index 8e8af1fa28..52ef4ec33c 100644
--- a/capinfos.c
+++ b/capinfos.c
@@ -1458,7 +1458,7 @@ main(int argc, char *argv[])
* Attempt to get the pathname of the directory containing the
* executable file.
*/
- init_progfile_dir_error = init_progfile_dir(argv[0], main);
+ init_progfile_dir_error = init_progfile_dir(argv[0]);
if (init_progfile_dir_error != NULL) {
fprintf(stderr,
"capinfos: Can't get pathname of directory containing the capinfos program: %s.\n",
diff --git a/captype.c b/captype.c
index b47a66ef2a..9083b5d8cf 100644
--- a/captype.c
+++ b/captype.c
@@ -134,7 +134,7 @@ main(int argc, char *argv[])
* Attempt to get the pathname of the directory containing the
* executable file.
*/
- init_progfile_dir_error = init_progfile_dir(argv[0], main);
+ init_progfile_dir_error = init_progfile_dir(argv[0]);
if (init_progfile_dir_error != NULL) {
fprintf(stderr,
"captype: Can't get pathname of directory containing the captype program: %s.\n",
diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in
index 89913c881d..57d7d59db1 100644
--- a/cmakeconfig.h.in
+++ b/cmakeconfig.h.in
@@ -53,9 +53,6 @@
/* Define to use c-ares library */
#cmakedefine HAVE_C_ARES 1
-/* Define to 1 if you have the `dladdr' function. */
-#cmakedefine HAVE_DLADDR 1
-
/* Define to 1 if you have the <fcntl.h> header file. */
#cmakedefine HAVE_FCNTL_H 1
diff --git a/dftest.c b/dftest.c
index 24e6002c14..e6e09b41e1 100644
--- a/dftest.c
+++ b/dftest.c
@@ -58,7 +58,7 @@ main(int argc, char **argv)
* Attempt to get the pathname of the directory containing the
* executable file.
*/
- init_progfile_dir_error = init_progfile_dir(argv[0], main);
+ init_progfile_dir_error = init_progfile_dir(argv[0]);
if (init_progfile_dir_error != NULL) {
fprintf(stderr, "dftest: Can't get pathname of directory containing the dftest program: %s.\n",
init_progfile_dir_error);
diff --git a/editcap.c b/editcap.c
index 71ecf018e7..b9b980c034 100644
--- a/editcap.c
+++ b/editcap.c
@@ -1021,7 +1021,7 @@ main(int argc, char *argv[])
* Attempt to get the pathname of the directory containing the
* executable file.
*/
- init_progfile_dir_error = init_progfile_dir(argv[0], main);
+ init_progfile_dir_error = init_progfile_dir(argv[0]);
if (init_progfile_dir_error != NULL) {
fprintf(stderr,
"editcap: Can't get pathname of directory containing the editcap program: %s.\n",
diff --git a/mergecap.c b/mergecap.c
index 73cb8439a5..bc55d63bc9 100644
--- a/mergecap.c
+++ b/mergecap.c
@@ -288,7 +288,7 @@ main(int argc, char *argv[])
* Attempt to get the pathname of the directory containing the
* executable file.
*/
- init_progfile_dir_error = init_progfile_dir(argv[0], main);
+ init_progfile_dir_error = init_progfile_dir(argv[0]);
if (init_progfile_dir_error != NULL) {
fprintf(stderr,
"mergecap: Can't get pathname of directory containing the mergecap program: %s.\n",
diff --git a/randpkt.c b/randpkt.c
index fe3cc9d43f..ff36dec77e 100644
--- a/randpkt.c
+++ b/randpkt.c
@@ -127,7 +127,7 @@ main(int argc, char **argv)
* Attempt to get the pathname of the directory containing the
* executable file.
*/
- init_progfile_dir_error = init_progfile_dir(argv[0], main);
+ init_progfile_dir_error = init_progfile_dir(argv[0]);
if (init_progfile_dir_error != NULL) {
fprintf(stderr,
"capinfos: Can't get pathname of directory containing the capinfos program: %s.\n",
diff --git a/rawshark.c b/rawshark.c
index 4371c5b058..59df200187 100644
--- a/rawshark.c
+++ b/rawshark.c
@@ -486,7 +486,7 @@ main(int argc, char *argv[])
* Attempt to get the pathname of the directory containing the
* executable file.
*/
- init_progfile_dir_error = init_progfile_dir(argv[0], main);
+ init_progfile_dir_error = init_progfile_dir(argv[0]);
if (init_progfile_dir_error != NULL) {
fprintf(stderr, "rawshark: Can't get pathname of rawshark program: %s.\n",
init_progfile_dir_error);
diff --git a/reordercap.c b/reordercap.c
index 7cbdea2ed8..b9a9711e89 100644
--- a/reordercap.c
+++ b/reordercap.c
@@ -222,7 +222,7 @@ main(int argc, char *argv[])
* Attempt to get the pathname of the directory containing the
* executable file.
*/
- init_progfile_dir_error = init_progfile_dir(argv[0], main);
+ init_progfile_dir_error = init_progfile_dir(argv[0]);
if (init_progfile_dir_error != NULL) {
fprintf(stderr,
"reordercap: Can't get pathname of directory containing the reordercap program: %s.\n",
diff --git a/sharkd.c b/sharkd.c
index 77c0c2630b..0070bcbc70 100644
--- a/sharkd.c
+++ b/sharkd.c
@@ -124,7 +124,7 @@ main(int argc, char *argv[])
/*
* Attempt to get the pathname of the executable file.
*/
- init_progfile_dir_error = init_progfile_dir(argv[0], main);
+ init_progfile_dir_error = init_progfile_dir(argv[0]);
if (init_progfile_dir_error != NULL) {
fprintf(stderr, "sharkd: Can't get pathname of sharkd program: %s.\n",
init_progfile_dir_error);
diff --git a/tfshark.c b/tfshark.c
index 89a02c581e..935fae76f7 100644
--- a/tfshark.c
+++ b/tfshark.c
@@ -378,7 +378,7 @@ main(int argc, char *argv[])
* Attempt to get the pathname of the directory containing the
* executable file.
*/
- init_progfile_dir_error = init_progfile_dir(argv[0], main);
+ init_progfile_dir_error = init_progfile_dir(argv[0]);
if (init_progfile_dir_error != NULL) {
fprintf(stderr,
"tfshark: Can't get pathname of directory containing the tfshark program: %s.\n",
diff --git a/tools/oss-fuzzshark/fuzzshark.c b/tools/oss-fuzzshark/fuzzshark.c
index e8c8224821..8412b49f29 100644
--- a/tools/oss-fuzzshark/fuzzshark.c
+++ b/tools/oss-fuzzshark/fuzzshark.c
@@ -234,7 +234,7 @@ fuzz_init(int argc _U_, char **argv)
/*
* Attempt to get the pathname of the executable file.
*/
- init_progfile_dir_error = init_progfile_dir(argv[0], fuzz_init);
+ init_progfile_dir_error = init_progfile_dir(argv[0]);
if (init_progfile_dir_error != NULL)
fprintf(stderr, "fuzzshark: Can't get pathname of oss-fuzzshark program: %s.\n", init_progfile_dir_error);
diff --git a/tshark.c b/tshark.c
index 82f3ddf0e9..b67c94c0f7 100644
--- a/tshark.c
+++ b/tshark.c
@@ -783,7 +783,7 @@ main(int argc, char *argv[])
* Attempt to get the pathname of the directory containing the
* executable file.
*/
- init_progfile_dir_error = init_progfile_dir(argv[0], main);
+ init_progfile_dir_error = init_progfile_dir(argv[0]);
if (init_progfile_dir_error != NULL) {
fprintf(stderr,
"tshark: Can't get pathname of directory containing the tshark program: %s.\n"
diff --git a/ui/gtk/main.c b/ui/gtk/main.c
index 398120da9e..35ef6b6339 100644
--- a/ui/gtk/main.c
+++ b/ui/gtk/main.c
@@ -2013,7 +2013,7 @@ main(int argc, char *argv[])
* Attempt to get the pathname of the directory containing the
* executable file.
*/
- init_progfile_dir_error = init_progfile_dir(argv[0], main);
+ init_progfile_dir_error = init_progfile_dir(argv[0]);
/* initialize the funnel mini-api */
initialize_funnel_ops();
diff --git a/wireshark-qt.cpp b/wireshark-qt.cpp
index 55d91a52e1..7b8d48ebad 100644
--- a/wireshark-qt.cpp
+++ b/wireshark-qt.cpp
@@ -422,8 +422,7 @@ int main(int argc, char *qt_argv[])
* Attempt to get the pathname of the directory containing the
* executable file.
*/
- /* init_progfile_dir_error = */ init_progfile_dir(argv[0],
- (int (*)(int, char **)) get_gui_compiled_info);
+ /* init_progfile_dir_error = */ init_progfile_dir(argv[0]);
g_log(NULL, G_LOG_LEVEL_DEBUG, "progfile_dir: %s", get_progfile_dir());
#ifdef _WIN32
diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c
index 4fa77ea21f..8e8e8a372d 100644
--- a/wsutil/filesystem.c
+++ b/wsutil/filesystem.c
@@ -10,13 +10,6 @@
#include <config.h>
-/*
- * Required with GNU libc to get dladdr().
- * We define it here because <dlfcn.h> apparently gets included by
- * one of the headers we include below.
- */
-#define _GNU_SOURCE
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -273,15 +266,31 @@ static gboolean running_in_build_directory_flag = FALSE;
* passed to the program, so it shouldn't be fooled by an argv[0]
* that doesn't match the executable path.
*
- * Sadly, not all UN*Xes necessarily have dladdr(), and those that
- * do don't necessarily have dladdr(main) return information about
- * the executable image, and those that do aren't necessarily running
- * on a platform wherein the executable image can get its own path
- * from the kernel (either by a call or by it being handed to it along
- * with argv[] and the environment), and those that can don't
- * necessarily use that to supply the path you get from dladdr(main),
- * so we try this first and, if that fails, use dladdr(main) if
- * available.
+ * We don't use dladdr() because:
+ *
+ * not all UN*Xes necessarily have dladdr();
+ *
+ * those that do have it don't necessarily have dladdr(main)
+ * return information about the executable image;
+ *
+ * those that do have a dladdr() where dladdr(main) returns
+ * information about the executable image don't necessarily
+ * have a mechanism by which the executable image can get
+ * its own path from the kernel (either by a call or by it
+ * being handed to it along with argv[] and the environment),
+ * so they just fall back on getting it from argv[0], which we
+ * already have code to do;
+ *
+ * those that do have such a mechanism don't necessarily use
+ * it in dladdr(), and, instead, just fall back on getting it
+ * from argv[0];
+ *
+ * so the only places where it's worth bothering to use dladdr()
+ * are platforms where dladdr(main) return information about the
+ * executable image by getting it from the kernel rather than
+ * by looking at argv[0], and where we can't get at that information
+ * ourselves, and we haven't seen any indication that there are any
+ * such platforms.
*
* In particular, some dynamic linkers supply a dladdr() such that
* dladdr(main) just returns something derived from argv[0], so
@@ -289,21 +298,11 @@ static gboolean running_in_build_directory_flag = FALSE;
* another mechanism that can get you a more reliable version of
* the executable path.
*
- * However, at least in newer versions of DragonFly BSD, the dynamic
- * linker *does* get it from the aux vector passed to the program
- * by the kernel, readlink /proc/curproc/file - which came first?
- *
- * On OpenBSD, dladdr(main) returns a value derived from argv[0],
- * and there doesn't appear to be any way to get the executable path
- * from the kernel, so we're out of luck there.
- *
- * So, on platforms where some versions have a version of dladdr()
- * that gives an argv[0]-based path and that also have a mechanism
- * to get a more reliable version of the path, we try that. On
- * other platforms, we return NULL. If our caller gets back a NULL
- * from us, it falls back on dladdr(main) if dladdr() is available,
- * and if that fails or is unavailable, it falls back on processing
- * argv[0] itself.
+ * So, on platforms where we know of a mechanism to get that path
+ * (where getting that path doesn't involve argv[0], which is not
+ * guaranteed to reflect the path to the binary), this routine
+ * attempsts to use that platform's mechanism. On other platforms,
+ * it just returns NULL.
*
* This is not guaranteed to return an absolute path; if it doesn't,
* our caller must prepend the current directory if it's a path.
@@ -456,10 +455,6 @@ init_progfile_dir(const char *arg0
#ifdef _WIN32
_U_
#endif
-, int (*function_addr)(int, char **)
-#if defined(_WIN32) || !defined(HAVE_DLADDR)
- _U_
-#endif
)
{
#ifdef _WIN32
@@ -522,9 +517,6 @@ init_progfile_dir(const char *arg0
msg, error);
}
#else
-#ifdef HAVE_DLADDR
- Dl_info info;
-#endif
const char *execname;
char *prog_pathname;
char *curdir;
@@ -550,24 +542,6 @@ init_progfile_dir(const char *arg0
running_in_build_directory_flag = TRUE;
execname = get_executable_path();
-#ifdef HAVE_DLADDR
- if (function_addr != NULL && execname == NULL) {
- /*
- * Try to use dladdr() to find the pathname of the executable.
- * dladdr() is not guaranteed to give you anything better than
- * argv[0] (i.e., it might not contain a / at all, much less
- * being an absolute path), and doesn't appear to do so on
- * Linux, but on other platforms it could give you an absolute
- * path and obviate the need for us to determine the absolute
- * path.
- */
-DIAG_OFF(pedantic)
- if (dladdr((void *)function_addr, &info)) {
-DIAG_ON(pedantic)
- execname = info.dli_fname;
- }
- }
-#endif
if (execname == NULL) {
/*
* OK, guess based on argv[0].
@@ -578,7 +552,7 @@ DIAG_ON(pedantic)
/*
* Try to figure out the directory in which the currently running
* program resides, given something purporting to be the executable
- * name (from dladdr() or from the argv[0] it was started with.
+ * name (from an OS mechanism or from the argv[0] it was started with).
* That might be the absolute path of the program, or a path relative
* to the current directory of the process that started it, or
* just a name for the program if it was started from the command
diff --git a/wsutil/filesystem.h b/wsutil/filesystem.h
index da45aeb0bf..e7c44848ed 100644
--- a/wsutil/filesystem.h
+++ b/wsutil/filesystem.h
@@ -29,7 +29,7 @@ extern "C" {
* and save it for future use. Returns NULL on success, and a
* g_mallocated string containing an error on failure.
*/
-WS_DLL_PUBLIC char *init_progfile_dir(const char *arg0, int (*function_addr)(int, char **));
+WS_DLL_PUBLIC char *init_progfile_dir(const char *arg0);
/*
* Get the directory in which the program resides.