|author||Guy Harris <firstname.lastname@example.org>||2016-12-04 20:25:51 -0800|
|committer||Guy Harris <email@example.com>||2016-12-05 04:27:49 +0000|
Clean up initialization code for programs.
Make the init_progfile_dir() call unconditionally, even if plugins aren't supported, as that doesn't necessarily mean nobody uses the directory containing the executable. Report the error the same way in all programs, and free the error string after we're finished with it. Make the error - and the comment before the code - reflect what init_progfile_dir() is actually doing (the goal is to get the full pathname of the directory *containing* the executable; that's generally done by getting the pathname of the executable and stripping off the name of the executable, but that's won't necessarily always be the case). Also note for TShark that we won't be able to capture traffic, just as we do for Wireshark (if we don't have the pathname of the program file, we don't have a pathname to use to find dumpcap). Have the plugin scanner just fail silently if we weren't able to get the plugin directory path, so we don't have to worry about calling it if init_progfile_dir() fails. Clean up white space while we're at it. Change-Id: I8e580c719aab6fbf74a764bf6629962394fff7c8 Reviewed-on: https://code.wireshark.org/review/19076 Reviewed-by: Guy Harris <firstname.lastname@example.org>
Diffstat (limited to 'wsutil/plugins.c')
1 files changed, 7 insertions, 2 deletions
diff --git a/wsutil/plugins.c b/wsutil/plugins.c
index 5bb530dd23..12f85c962d 100644
@@ -276,9 +276,9 @@ scan_plugins(plugin_load_failure_mode mode)
WS_DIR *dir; /* scanned directory */
- WS_DIRENT *file; /* current file */
+ WS_DIRENT *file; /* current file */
- if (plugin_list == NULL) /* ensure scan_plugins is only run once */
+ if (plugin_list == NULL) /* only scan for plugins once */
* Scan the global plugin directory.
@@ -288,6 +288,11 @@ scan_plugins(plugin_load_failure_mode mode)
* they will contain plugins in the case of an in-tree build.
plugin_dir = get_plugin_dir();
+ if (plugin_dir == NULL)
+ /* We couldn't find the plugin directory. */
if ((dir = ws_dir_open(plugin_dir, 0, NULL)) != NULL)