wiretap: add a parameter to wtap_init() indicating whether plugins must be loaded

g995812c5f1 moved wiretap plugins registration from applications to
wiretap library init function.
As we do not want to load plugins for all users of libwiretap, let's
make it configurable.

Bug: 14314
Change-Id: Id8fdcc484e2d0d31d3ab0bd357d3a6678570f700
Reviewed-on: https://code.wireshark.org/review/25194
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Pascal Quantin 2018-01-09 09:55:37 +01:00 committed by Anders Broman
parent a7e29d8b66
commit fc9af81a13
19 changed files with 29 additions and 23 deletions

View File

@ -1467,7 +1467,7 @@ main(int argc, char *argv[])
init_report_message(failure_warning_message, failure_warning_message,
NULL, NULL, NULL);
wtap_init();
wtap_init(TRUE);
/* Process the options */
while ((opt = getopt_long(argc, argv, "abcdehiklmoqrstuvxyzABCEFHIKLMNQRST", long_options, NULL)) !=-1) {

View File

@ -145,7 +145,7 @@ main(int argc, char *argv[])
init_report_message(failure_warning_message, failure_warning_message,
NULL, NULL, NULL);
wtap_init();
wtap_init(TRUE);
/* Process the options */
while ((opt = getopt_long(argc, argv, "hv", long_options, NULL)) !=-1) {

View File

@ -72,7 +72,7 @@ main(int argc, char **argv)
timestamp_set_type(TS_RELATIVE);
timestamp_set_seconds_type(TS_SECONDS_DEFAULT);
wtap_init();
wtap_init(TRUE);
/* Register all dissectors; we must do this before checking for the
"-g" flag, as the "-g" flag dumps a list of fields registered

View File

@ -1030,7 +1030,7 @@ main(int argc, char *argv[])
init_report_message(failure_warning_message, failure_warning_message,
NULL, NULL, NULL);
wtap_init();
wtap_init(TRUE);
/* Process the options */
while ((opt = getopt_long(argc, argv, ":a:A:B:c:C:dD:E:F:hi:I:Lo:rs:S:t:T:vVw:", long_options, NULL)) != -1) {

View File

@ -432,7 +432,7 @@ static struct extcap_dumper extcap_dumper_open(char *fifo, int encap) {
#else
int err = 0;
wtap_init();
wtap_init(FALSE);
extcap_dumper.dumper.wtap = wtap_dump_open(fifo, WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC, encap, PACKET_LENGTH, FALSE, &err);
if (!extcap_dumper.dumper.wtap) {

View File

@ -272,6 +272,8 @@ int main(int argc, char *argv[])
goto end;
}
wtap_init(FALSE);
if (!all_random) {
produce_type = randpkt_parse_type(type);

View File

@ -299,7 +299,7 @@ main(int argc, char *argv[])
init_report_message(failure_warning_message, failure_warning_message,
NULL, NULL, NULL);
wtap_init();
wtap_init(TRUE);
/* Process the options first */
while ((opt = getopt_long(argc, argv, "aF:hI:s:vVw:", long_options, NULL)) != -1) {

View File

@ -138,7 +138,7 @@ main(int argc, char **argv)
init_report_message(failure_warning_message, failure_warning_message,
NULL, NULL, NULL);
wtap_init();
wtap_init(TRUE);
cmdarg_err_init(failure_warning_message, failure_message_cont);

View File

@ -661,8 +661,6 @@ int randpkt_example_init(randpkt_example* example, char* produce_filename, int p
pkt_rand = g_rand_new();
}
wtap_init();
if (strcmp(produce_filename, "-") == 0) {
/* Write to the standard output. */
example->dump = wtap_dump_open_stdout(WTAP_FILE_TYPE_SUBTYPE_PCAP,

View File

@ -514,7 +514,7 @@ main(int argc, char *argv[])
timestamp_set_precision(TS_PREC_AUTO);
timestamp_set_seconds_type(TS_SECONDS_DEFAULT);
wtap_init();
wtap_init(FALSE);
/* Register all dissectors; we must do this before checking for the
"-G" flag, as the "-G" flag dumps information registered by the

View File

@ -233,7 +233,7 @@ main(int argc, char *argv[])
init_report_message(failure_warning_message, failure_warning_message,
NULL, NULL, NULL);
wtap_init();
wtap_init(TRUE);
/* Process the options first */
while ((opt = getopt_long(argc, argv, "hnv", long_options, NULL)) != -1) {

View File

@ -161,7 +161,7 @@ main(int argc, char *argv[])
timestamp_set_precision(TS_PREC_AUTO);
timestamp_set_seconds_type(TS_SECONDS_DEFAULT);
wtap_init();
wtap_init(TRUE);
/* Register all dissectors; we must do this before checking for the
"-G" flag, as the "-G" flag dumps information registered by the

View File

@ -487,7 +487,7 @@ main(int argc, char *argv[])
timestamp_set_precision(TS_PREC_AUTO);
timestamp_set_seconds_type(TS_SECONDS_DEFAULT);
wtap_init();
wtap_init(TRUE);
/* Register all dissectors; we must do this before checking for the
"-G" flag, as the "-G" flag dumps information registered by the

View File

@ -219,7 +219,7 @@ fuzz_init(int argc _U_, char **argv)
timestamp_set_precision(TS_PREC_AUTO);
timestamp_set_seconds_type(TS_SECONDS_DEFAULT);
wtap_init();
wtap_init(TRUE);
/* Register all dissectors; we must do this before checking for the
"-G" flag, as the "-G" flag dumps information registered by the

View File

@ -893,7 +893,7 @@ main(int argc, char *argv[])
timestamp_set_precision(TS_PREC_AUTO);
timestamp_set_seconds_type(TS_SECONDS_DEFAULT);
wtap_init();
wtap_init(TRUE);
/* Register all dissectors; we must do this before checking for the
"-G" flag, as the "-G" flag dumps information registered by the

View File

@ -2192,7 +2192,7 @@ main(int argc, char *argv[])
g_free(init_progfile_dir_error);
}
wtap_init();
wtap_init(TRUE);
splash_update(RA_DISSECTORS, NULL, (gpointer)splash_win);

View File

@ -625,7 +625,7 @@ int main(int argc, char *qt_argv[])
open_failure_alert_box, read_failure_alert_box,
write_failure_alert_box);
wtap_init();
wtap_init(TRUE);
splash_update(RA_DISSECTORS, NULL, NULL);
#ifdef DEBUG_STARTUP_TIME

View File

@ -38,7 +38,7 @@
#ifdef HAVE_PLUGINS
static plugins_t *libwiretap_plugins;
static plugins_t *libwiretap_plugins = NULL;
static GSList *wtap_plugins = NULL;
void
@ -1427,14 +1427,16 @@ wtap_seek_read(wtap *wth, gint64 seek_off,
* Initialize the library.
*/
void
wtap_init(void)
wtap_init(gboolean load_wiretap_plugins)
{
init_open_routines();
wtap_opttypes_initialize();
wtap_init_encap_types();
#ifdef HAVE_PLUGINS
libwiretap_plugins = plugins_init("wiretap");
g_slist_foreach(wtap_plugins, call_plugin_register_wtap_module, NULL);
if (load_wiretap_plugins) {
libwiretap_plugins = plugins_init("wiretap");
g_slist_foreach(wtap_plugins, call_plugin_register_wtap_module, NULL);
}
#endif
}

View File

@ -1562,9 +1562,13 @@ struct file_type_subtype_info {
#define WTAP_TYPE_AUTO 0
/** Initialize the Wiretap library. */
/**
* @brief Initialize the Wiretap library.
*
* @param load_wiretap_plugins Load Wiretap plugins when initializing library.
*/
WS_DLL_PUBLIC
void wtap_init(void);
void wtap_init(gboolean load_wiretap_plugins);
/** On failure, "wtap_open_offline()" returns NULL, and puts into the
* "int" pointed to by its second argument: