diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-09-05 16:26:29 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-09-05 23:27:02 +0000 |
commit | 2a38dc74ede3eba69f0d73b61f1735a4036528c1 (patch) | |
tree | c03b1f72dcd66c54907d546a45c28315ba35fd27 /wsutil/plugins.c | |
parent | ae877942ea507128d3191e17075a26b86e52615d (diff) |
Have scan_plugins() take an argument specify what to do on load failures.
That's a less gross hack to suppress load failures due to not having
libwiretap than providing a no-op failure-message routine, as it at
least allows other code using a failure-message routine, such as
cmdarg_err() and routines that call it, to be used.
We really should put libwiretap and libwireshark plugins into separate
subdirectories of the plugin directories, and avoid even looking at
libwireshark plugins in programs that don't use libwireshark.
Change-Id: I0a6ec01ecb4e718ed36233cfaf638a317f839a73
Reviewed-on: https://code.wireshark.org/review/17506
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wsutil/plugins.c')
-rw-r--r-- | wsutil/plugins.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/wsutil/plugins.c b/wsutil/plugins.c index 8a390948f5..f2da1f57d2 100644 --- a/wsutil/plugins.c +++ b/wsutil/plugins.c @@ -143,7 +143,7 @@ call_plugin_callback(gpointer data, gpointer user_data) } static void -plugins_scan_dir(const char *dirname) +plugins_scan_dir(const char *dirname, plugin_load_failure_mode mode) { #define FILENAME_LEN 1024 WS_DIR *dir; /* scanned directory */ @@ -175,8 +175,21 @@ plugins_scan_dir(const char *dirname) dirname, name); if ((handle = g_module_open(filename, G_MODULE_BIND_LOCAL)) == NULL) { - report_failure("Couldn't load module %s: %s", filename, - g_module_error()); + /* + * Only report load failures if we were asked to. + * + * XXX - we really should put different types of plugins + * (libwiretap, libwireshark) in different subdirectories, + * give libwiretap and libwireshark init routines that + * load the plugins, and have them scan the appropriate + * subdirectories so tha we don't even *try* to, for + * example, load libwireshark plugins in programs that + * only use libwiretap. + */ + if (mode == REPORT_LOAD_FAILURE) { + report_failure("Couldn't load module %s: %s", filename, + g_module_error()); + } continue; } @@ -241,7 +254,7 @@ plugins_scan_dir(const char *dirname) * Scan for plugins. */ void -scan_plugins(void) +scan_plugins(plugin_load_failure_mode mode) { const char *plugin_dir; const char *name; @@ -264,7 +277,7 @@ scan_plugins(void) { if ((dir = ws_dir_open(plugin_dir, 0, NULL)) != NULL) { - plugins_scan_dir(plugin_dir); + plugins_scan_dir(plugin_dir, mode); while ((file = ws_dir_read_name(dir)) != NULL) { name = ws_dir_get_name(file); @@ -290,14 +303,14 @@ scan_plugins(void) plugin_dir_path = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", plugin_dir, name); } - plugins_scan_dir(plugin_dir_path); + plugins_scan_dir(plugin_dir_path, mode); g_free(plugin_dir_path); } ws_dir_close(dir); } } else - plugins_scan_dir(plugin_dir); + plugins_scan_dir(plugin_dir, mode); /* * If the program wasn't started with special privileges, @@ -310,7 +323,7 @@ scan_plugins(void) if (!started_with_special_privs()) { plugins_pers_dir = get_plugins_pers_dir(); - plugins_scan_dir(plugins_pers_dir); + plugins_scan_dir(plugins_pers_dir, mode); g_free(plugins_pers_dir); } } |