diff options
-rw-r--r-- | capinfos.c | 39 | ||||
-rw-r--r-- | captype.c | 40 | ||||
-rw-r--r-- | dftest.c | 6 | ||||
-rw-r--r-- | editcap.c | 40 | ||||
-rw-r--r-- | mergecap.c | 41 | ||||
-rw-r--r-- | randpkt.c | 42 | ||||
-rw-r--r-- | rawshark.c | 3 | ||||
-rw-r--r-- | reordercap.c | 50 | ||||
-rw-r--r-- | tfshark.c | 7 | ||||
-rw-r--r-- | tshark.c | 9 | ||||
-rw-r--r-- | ui/gtk/main.c | 5 | ||||
-rw-r--r-- | wireshark-qt.cpp | 3 | ||||
-rw-r--r-- | wsutil/plugins.c | 9 |
13 files changed, 168 insertions, 126 deletions
diff --git a/capinfos.c b/capinfos.c index d1773113b4..a6539cc672 100644 --- a/capinfos.c +++ b/capinfos.c @@ -1405,6 +1405,7 @@ main(int argc, char *argv[]) { GString *comp_info_str; GString *runtime_info_str; + char *init_progfile_dir_error; wtap *wth; int err; gchar *err_info; @@ -1417,9 +1418,6 @@ main(int argc, char *argv[]) }; int status = 0; -#ifdef HAVE_PLUGINS - char *init_progfile_dir_error; -#endif #ifdef HAVE_LIBGCRYPT FILE *fh; char *hash_buf = NULL; @@ -1459,26 +1457,33 @@ main(int argc, char *argv[]) */ init_process_policies(); + /* + * Attempt to get the pathname of the directory containing the + * executable file. + */ + init_progfile_dir_error = init_progfile_dir(argv[0], main); + if (init_progfile_dir_error != NULL) { + fprintf(stderr, + "capinfos: Can't get pathname of directory containing the capinfos program: %s.\n", + init_progfile_dir_error); + g_free(init_progfile_dir_error); + } + wtap_init(); #ifdef HAVE_PLUGINS - if ((init_progfile_dir_error = init_progfile_dir(argv[0], main))) { - g_warning("capinfos: init_progfile_dir(): %s", init_progfile_dir_error); - g_free(init_progfile_dir_error); - } else { - init_report_err(failure_message, NULL, NULL, NULL); + init_report_err(failure_message, NULL, NULL, NULL); - /* Scan for plugins. This does *not* call their registration routines; - that's done later. + /* Scan for plugins. This does *not* call their registration routines; + that's done later. - Don't report failures to load plugins because most (non-wiretap) - plugins *should* fail to load (because we're not linked against - libwireshark and dissector plugins need libwireshark). */ - scan_plugins(DONT_REPORT_LOAD_FAILURE); + Don't report failures to load plugins because most (non-wiretap) + plugins *should* fail to load (because we're not linked against + libwireshark and dissector plugins need libwireshark). */ + scan_plugins(DONT_REPORT_LOAD_FAILURE); - /* Register all libwiretap plugin modules. */ - register_all_wiretap_modules(); - } + /* Register all libwiretap plugin modules. */ + register_all_wiretap_modules(); #endif /* Process the options */ @@ -86,6 +86,7 @@ main(int argc, char *argv[]) { GString *comp_info_str; GString *runtime_info_str; + char *init_progfile_dir_error; wtap *wth; int err; gchar *err_info; @@ -98,10 +99,6 @@ main(int argc, char *argv[]) {0, 0, 0, 0 } }; -#ifdef HAVE_PLUGINS - char *init_progfile_dir_error; -#endif - /* Set the C-language locale to the native environment. */ setlocale(LC_ALL, ""); @@ -131,26 +128,33 @@ main(int argc, char *argv[]) */ init_process_policies(); + /* + * Attempt to get the pathname of the directory containing the + * executable file. + */ + init_progfile_dir_error = init_progfile_dir(argv[0], main); + if (init_progfile_dir_error != NULL) { + fprintf(stderr, + "captype: Can't get pathname of directory containing the captype program: %s.\n", + init_progfile_dir_error); + g_free(init_progfile_dir_error); + } + wtap_init(); #ifdef HAVE_PLUGINS - if ((init_progfile_dir_error = init_progfile_dir(argv[0], main))) { - g_warning("captype: init_progfile_dir(): %s", init_progfile_dir_error); - g_free(init_progfile_dir_error); - } else { - init_report_err(failure_message,NULL,NULL,NULL); + init_report_err(failure_message,NULL,NULL,NULL); - /* Scan for plugins. This does *not* call their registration routines; - that's done later. + /* Scan for plugins. This does *not* call their registration routines; + that's done later. - Don't report failures to load plugins because most (non-wiretap) - plugins *should* fail to load (because we're not linked against - libwireshark and dissector plugins need libwireshark). */ - scan_plugins(DONT_REPORT_LOAD_FAILURE); + Don't report failures to load plugins because most (non-wiretap) + plugins *should* fail to load (because we're not linked against + libwireshark and dissector plugins need libwireshark). */ + scan_plugins(DONT_REPORT_LOAD_FAILURE); - /* Register all libwiretap plugin modules. */ - register_all_wiretap_modules(); - } + /* Register all libwiretap plugin modules. */ + register_all_wiretap_modules(); #endif /* Process the options */ @@ -68,12 +68,14 @@ main(int argc, char **argv) init_process_policies(); /* - * Attempt to get the pathname of the executable file. + * Attempt to get the pathname of the directory containing the + * executable file. */ init_progfile_dir_error = init_progfile_dir(argv[0], main); if (init_progfile_dir_error != NULL) { - fprintf(stderr, "dftest: Can't get pathname of dftest program: %s.\n", + fprintf(stderr, "dftest: Can't get pathname of directory containing the dftest program: %s.\n", init_progfile_dir_error); + g_free(init_progfile_dir_error); } init_report_err(failure_message, open_failure_message, @@ -942,6 +942,7 @@ main(int argc, char *argv[]) { GString *comp_info_str; GString *runtime_info_str; + char *init_progfile_dir_error; wtap *wth; int i, j, read_err, write_err; gchar *read_err_info, *write_err_info; @@ -982,10 +983,6 @@ main(int argc, char *argv[]) GArray *nrb_hdrs = NULL; char *shb_user_appl; -#ifdef HAVE_PLUGINS - char* init_progfile_dir_error; -#endif - cmdarg_err_init(failure_message, failure_message_cont); #ifdef _WIN32 @@ -1014,27 +1011,34 @@ main(int argc, char *argv[]) */ init_process_policies(); + /* + * Attempt to get the pathname of the directory containing the + * executable file. + */ + init_progfile_dir_error = init_progfile_dir(argv[0], main); + if (init_progfile_dir_error != NULL) { + fprintf(stderr, + "editcap: Can't get pathname of directory containing the editcap program: %s.\n", + init_progfile_dir_error); + g_free(init_progfile_dir_error); + } + wtap_init(); #ifdef HAVE_PLUGINS /* Register wiretap plugins */ - if ((init_progfile_dir_error = init_progfile_dir(argv[0], main))) { - g_warning("editcap: init_progfile_dir(): %s", init_progfile_dir_error); - g_free(init_progfile_dir_error); - } else { - init_report_err(failure_message,NULL,NULL,NULL); + init_report_err(failure_message,NULL,NULL,NULL); - /* Scan for plugins. This does *not* call their registration routines; - that's done later. + /* Scan for plugins. This does *not* call their registration routines; + that's done later. - Don't report failures to load plugins because most (non-wiretap) - plugins *should* fail to load (because we're not linked against - libwireshark and dissector plugins need libwireshark). */ - scan_plugins(DONT_REPORT_LOAD_FAILURE); + Don't report failures to load plugins because most (non-wiretap) + plugins *should* fail to load (because we're not linked against + libwireshark and dissector plugins need libwireshark). */ + scan_plugins(DONT_REPORT_LOAD_FAILURE); - /* Register all libwiretap plugin modules. */ - register_all_wiretap_modules(); - } + /* Register all libwiretap plugin modules. */ + register_all_wiretap_modules(); #endif /* Process the options */ diff --git a/mergecap.c b/mergecap.c index f3cf9224e8..fd2c2838c3 100644 --- a/mergecap.c +++ b/mergecap.c @@ -242,6 +242,7 @@ main(int argc, char *argv[]) { GString *comp_info_str; GString *runtime_info_str; + char *init_progfile_dir_error; int opt; static const struct option long_options[] = { {"help", no_argument, NULL, 'h'}, @@ -266,10 +267,6 @@ main(int argc, char *argv[]) gboolean use_stdout = FALSE; merge_progress_callback_t cb; -#ifdef HAVE_PLUGINS - char *init_progfile_dir_error; -#endif - cmdarg_err_init(mergecap_cmdarg_err, mergecap_cmdarg_err_cont); #ifdef _WIN32 @@ -298,27 +295,33 @@ main(int argc, char *argv[]) */ init_process_policies(); + /* + * Attempt to get the pathname of the directory containing the + * executable file. + */ + init_progfile_dir_error = init_progfile_dir(argv[0], main); + if (init_progfile_dir_error != NULL) { + fprintf(stderr, + "mergecap: Can't get pathname of directory containing the mergecap program: %s.\n", + init_progfile_dir_error); + g_free(init_progfile_dir_error); + } + wtap_init(); #ifdef HAVE_PLUGINS - /* Register wiretap plugins */ - if ((init_progfile_dir_error = init_progfile_dir(argv[0], main))) { - g_warning("mergecap: init_progfile_dir(): %s", init_progfile_dir_error); - g_free(init_progfile_dir_error); - } else { - init_report_err(failure_message,NULL,NULL,NULL); + init_report_err(failure_message,NULL,NULL,NULL); - /* Scan for plugins. This does *not* call their registration routines; - that's done later. + /* Scan for plugins. This does *not* call their registration routines; + that's done later. - Don't report failures to load plugins because most (non-wiretap) - plugins *should* fail to load (because we're not linked against - libwireshark and dissector plugins need libwireshark).*/ - scan_plugins(DONT_REPORT_LOAD_FAILURE); + Don't report failures to load plugins because most (non-wiretap) + plugins *should* fail to load (because we're not linked against + libwireshark and dissector plugins need libwireshark).*/ + scan_plugins(DONT_REPORT_LOAD_FAILURE); - /* Register all libwiretap plugin modules. */ - register_all_wiretap_modules(); - } + /* Register all libwiretap plugin modules. */ + register_all_wiretap_modules(); #endif /* Process the options first */ @@ -110,6 +110,7 @@ usage(gboolean is_error) int main(int argc, char **argv) { + char *init_progfile_dir_error; int opt; int produce_type = -1; char *produce_filename = NULL; @@ -124,15 +125,23 @@ main(int argc, char **argv) {0, 0, 0, 0 } }; -#ifdef HAVE_PLUGINS - char *init_progfile_dir_error; -#endif - /* * Get credential information for later use. */ init_process_policies(); + /* + * Attempt to get the pathname of the directory containing the + * executable file. + */ + init_progfile_dir_error = init_progfile_dir(argv[0], main); + if (init_progfile_dir_error != NULL) { + fprintf(stderr, + "capinfos: Can't get pathname of directory containing the capinfos program: %s.\n", + init_progfile_dir_error); + g_free(init_progfile_dir_error); + } + wtap_init(); cmdarg_err_init(failure_message, failure_message_cont); @@ -144,24 +153,19 @@ main(int argc, char **argv) #ifdef HAVE_PLUGINS /* Register wiretap plugins */ - if ((init_progfile_dir_error = init_progfile_dir(argv[0], main))) { - g_warning("randpkt: init_progfile_dir(): %s", init_progfile_dir_error); - g_free(init_progfile_dir_error); - } else { - init_report_err(failure_message,NULL,NULL,NULL); + init_report_err(failure_message,NULL,NULL,NULL); - /* Scan for plugins. This does *not* call their registration routines; - that's done later. + /* Scan for plugins. This does *not* call their registration routines; + that's done later. - Don't report failures to load plugins because most - (non-wiretap) plugins *should* fail to load (because - we're not linked against libwireshark and dissector - plugins need libwireshark). */ - scan_plugins(DONT_REPORT_LOAD_FAILURE); + Don't report failures to load plugins because most + (non-wiretap) plugins *should* fail to load (because + we're not linked against libwireshark and dissector + plugins need libwireshark). */ + scan_plugins(DONT_REPORT_LOAD_FAILURE); - /* Register all libwiretap plugin modules. */ - register_all_wiretap_modules(); - } + /* Register all libwiretap plugin modules. */ + register_all_wiretap_modules(); #endif while ((opt = getopt_long(argc, argv, "b:c:ht:r", long_options, NULL)) != -1) { diff --git a/rawshark.c b/rawshark.c index ed88215047..f9d0a5702c 100644 --- a/rawshark.c +++ b/rawshark.c @@ -485,7 +485,8 @@ main(int argc, char *argv[]) string_fmts = g_ptr_array_new(); /* - * Attempt to get the pathname of the executable file. + * Attempt to get the pathname of the directory containing the + * executable file. */ init_progfile_dir_error = init_progfile_dir(argv[0], main); if (init_progfile_dir_error != NULL) { diff --git a/reordercap.c b/reordercap.c index 004cb158b7..4f453dc464 100644 --- a/reordercap.c +++ b/reordercap.c @@ -167,6 +167,7 @@ main(int argc, char *argv[]) { GString *comp_info_str; GString *runtime_info_str; + char *init_progfile_dir_error; wtap *wth = NULL; wtap_dumper *pdh = NULL; struct wtap_pkthdr dump_phdr; @@ -195,10 +196,6 @@ main(int argc, char *argv[]) char *infile; const char *outfile; -#ifdef HAVE_PLUGINS - char *init_progfile_dir_error; -#endif - /* Get the compile-time version information string */ comp_info_str = get_compiled_version_info(NULL, NULL); @@ -215,32 +212,39 @@ main(int argc, char *argv[]) g_string_free(comp_info_str, TRUE); g_string_free(runtime_info_str, TRUE); - /* - * Get credential information for later use. - */ - init_process_policies(); + /* + * Get credential information for later use. + */ + init_process_policies(); + + /* + * Attempt to get the pathname of the directory containing the + * executable file. + */ + init_progfile_dir_error = init_progfile_dir(argv[0], main); + if (init_progfile_dir_error != NULL) { + fprintf(stderr, + "reordercap: Can't get pathname of directory containing the reordercap program: %s.\n", + init_progfile_dir_error); + g_free(init_progfile_dir_error); + } - wtap_init(); + wtap_init(); #ifdef HAVE_PLUGINS /* Register wiretap plugins */ - if ((init_progfile_dir_error = init_progfile_dir(argv[0], main))) { - g_warning("reordercap: init_progfile_dir(): %s", init_progfile_dir_error); - g_free(init_progfile_dir_error); - } else { - init_report_err(failure_message,NULL,NULL,NULL); + init_report_err(failure_message,NULL,NULL,NULL); - /* Scan for plugins. This does *not* call their registration routines; - that's done later. + /* Scan for plugins. This does *not* call their registration routines; + that's done later. - Don't report failures to load plugins because most (non-wiretap) - plugins *should* fail to load (because we're not linked against - libwireshark and dissector plugins need libwireshark). */ - scan_plugins(DONT_REPORT_LOAD_FAILURE); + Don't report failures to load plugins because most (non-wiretap) + plugins *should* fail to load (because we're not linked against + libwireshark and dissector plugins need libwireshark). */ + scan_plugins(DONT_REPORT_LOAD_FAILURE); - /* Register all libwiretap plugin modules. */ - register_all_wiretap_modules(); - } + /* Register all libwiretap plugin modules. */ + register_all_wiretap_modules(); #endif /* Process the options first */ @@ -393,12 +393,15 @@ main(int argc, char *argv[]) print_current_user(); /* - * Attempt to get the pathname of the executable file. + * Attempt to get the pathname of the directory containing the + * executable file. */ init_progfile_dir_error = init_progfile_dir(argv[0], main); if (init_progfile_dir_error != NULL) { - fprintf(stderr, "tfshark: Can't get pathname of tfshark program: %s.\n", + fprintf(stderr, + "tfshark: Can't get pathname of directory containing the tfshark program: %s.\n", init_progfile_dir_error); + g_free(init_progfile_dir_error); } initialize_funnel_ops(); @@ -736,12 +736,17 @@ main(int argc, char *argv[]) print_current_user(); /* - * Attempt to get the pathname of the executable file. + * Attempt to get the pathname of the directory containing the + * executable file. */ init_progfile_dir_error = init_progfile_dir(argv[0], main); if (init_progfile_dir_error != NULL) { - fprintf(stderr, "tshark: Can't get pathname of tshark program: %s.\n", + fprintf(stderr, + "tshark: Can't get pathname of directory containing the tshark program: %s.\n" + "It won't be possible to capture traffic.\n" + "Report this to the Wireshark developers.", init_progfile_dir_error); + g_free(init_progfile_dir_error); } initialize_funnel_ops(); diff --git a/ui/gtk/main.c b/ui/gtk/main.c index 4cb793f775..ce5ab50d44 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -2115,7 +2115,8 @@ main(int argc, char *argv[]) relinquish_special_privs_perm(); /* - * Attempt to get the pathname of the executable file. + * Attempt to get the pathname of the directory containing the + * executable file. */ init_progfile_dir_error = init_progfile_dir(argv[0], main); @@ -2280,7 +2281,7 @@ main(int argc, char *argv[]) splash_win = splash_new("Loading Wireshark ..."); if (init_progfile_dir_error != NULL) { simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, - "Can't get pathname of Wireshark: %s.\n" + "Can't get pathname of directory containing Wireshark: %s.\n" "It won't be possible to capture traffic.\n" "Report this to the Wireshark developers.", init_progfile_dir_error); diff --git a/wireshark-qt.cpp b/wireshark-qt.cpp index 504ff0a6f8..f0f1b084d3 100644 --- a/wireshark-qt.cpp +++ b/wireshark-qt.cpp @@ -375,7 +375,8 @@ int main(int argc, char *qt_argv[]) relinquish_special_privs_perm(); /* - * Attempt to get the pathname of the executable file. + * 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); diff --git a/wsutil/plugins.c b/wsutil/plugins.c index 5bb530dd23..12f85c962d 100644 --- a/wsutil/plugins.c +++ b/wsutil/plugins.c @@ -276,9 +276,9 @@ scan_plugins(plugin_load_failure_mode mode) char *plugin_dir_path; char *plugins_pers_dir; 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. */ + return; + } if (running_in_build_directory()) { if ((dir = ws_dir_open(plugin_dir, 0, NULL)) != NULL) |