If you use data_file_url(), you must first call init_progfile_dir().

And if you call init_progfile_dir(), you must call
init_process_policies() before that.

And even if you *don't* use data_file_url(), you might use it in the
future, or you might use other calls to get data file paths, so make
*all* the extcap programs make those calls.

(Yes, this is important on macOS, for example; it may also be important
on Windows.  On other UN*Xes we may just compile in the data file path,
but that's not true on *all* our platforms.)

Change-Id: I99265ed69ec24096884ec067feddd7d7f3855436
Reviewed-on: https://code.wireshark.org/review/32775
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2019-04-07 19:56:22 -07:00
parent 9f575c8dc9
commit bbc8cbfb9c
7 changed files with 126 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include <time.h>
#include <wsutil/strtoi.h>
#include <wsutil/filesystem.h>
#include <wsutil/privileges.h>
#include <ui/cmdarg_err.h>
#include <wsutil/inet_addr.h>
@ -2481,6 +2482,7 @@ static int capture_android_tcpdump(char *interface, char *fifo,
}
int main(int argc, char *argv[]) {
char *init_progfile_dir_error;
int ret = EXIT_CODE_GENERIC;
int option_idx = 0;
int result;
@ -2511,6 +2513,22 @@ int main(int argc, char *argv[]) {
cmdarg_err_init(failure_warning_message, failure_warning_message);
/*
* 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]);
if (init_progfile_dir_error != NULL) {
g_warning("Can't get pathname of directory containing the captype program: %s.",
init_progfile_dir_error);
g_free(init_progfile_dir_error);
}
extcap_conf = g_new0(extcap_parameters, 1);
help_url = data_file_url("androiddump.html");

View File

@ -16,6 +16,7 @@
#include <wsutil/interface.h>
#include <wsutil/strtoi.h>
#include <wsutil/filesystem.h>
#include <wsutil/privileges.h>
#include <extcap/ssh-base.h>
#include <writecap/pcapio.h>
@ -517,6 +518,7 @@ static int list_config(char *interface, unsigned int remote_port)
int main(int argc, char *argv[])
{
char* init_progfile_dir_error;
int result;
int option_idx = 0;
ssh_params_t* ssh_params = ssh_params_new();
@ -532,6 +534,22 @@ int main(int argc, char *argv[])
WSADATA wsaData;
#endif /* _WIN32 */
/*
* 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]);
if (init_progfile_dir_error != NULL) {
g_warning("Can't get pathname of directory containing the captype program: %s.",
init_progfile_dir_error);
g_free(init_progfile_dir_error);
}
help_url = data_file_url("ciscodump.html");
extcap_base_set_util_info(extcap_conf, argv[0], CISCODUMP_VERSION_MAJOR, CISCODUMP_VERSION_MINOR,
CISCODUMP_VERSION_RELEASE, help_url);

View File

@ -17,6 +17,7 @@
#include <wsutil/strtoi.h>
#include <wsutil/filesystem.h>
#include <wsutil/netlink.h>
#include <wsutil/privileges.h>
#include <writecap/pcapio.h>
#include <netlink/netlink.h>
@ -478,6 +479,7 @@ close_out:
int main(int argc, char *argv[])
{
char* init_progfile_dir_error;
int option_idx = 0;
int result;
unsigned int interface_id = 0;
@ -485,6 +487,22 @@ int main(int argc, char *argv[])
extcap_parameters* extcap_conf = g_new0(extcap_parameters, 1);
char* help_header = NULL;
/*
* 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]);
if (init_progfile_dir_error != NULL) {
g_warning("Can't get pathname of directory containing the captype program: %s.",
init_progfile_dir_error);
g_free(init_progfile_dir_error);
}
extcap_base_set_util_info(extcap_conf, argv[0], DPAUXMON_VERSION_MAJOR, DPAUXMON_VERSION_MINOR, DPAUXMON_VERSION_RELEASE,
NULL);
extcap_base_register_interface(extcap_conf, DPAUXMON_EXTCAP_INTERFACE, "DisplayPort AUX channel monitor capture", 275, "DisplayPort AUX channel monitor");

View File

@ -17,6 +17,7 @@
#include "randpkt_core/randpkt_core.h"
#include <wsutil/strtoi.h>
#include <wsutil/filesystem.h>
#include <wsutil/privileges.h>
#include <cli_main.h>
@ -123,6 +124,7 @@ static int list_config(char *interface)
int main(int argc, char *argv[])
{
char* init_progfile_dir_error;
int option_idx = 0;
int result;
guint16 maxbytes = 5000;
@ -144,6 +146,22 @@ int main(int argc, char *argv[])
char* help_url;
char* help_header = NULL;
/*
* 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]);
if (init_progfile_dir_error != NULL) {
g_warning("Can't get pathname of directory containing the captype program: %s.",
init_progfile_dir_error);
g_free(init_progfile_dir_error);
}
help_url = data_file_url("randpktdump.html");
extcap_base_set_util_info(extcap_conf, argv[0], RANDPKTDUMP_VERSION_MAJOR, RANDPKTDUMP_VERSION_MINOR,
RANDPKTDUMP_VERSION_RELEASE, help_url);

View File

@ -23,6 +23,7 @@
#include <wsutil/interface.h>
#include <wsutil/file_util.h>
#include <wsutil/filesystem.h>
#include <wsutil/privileges.h>
#include <writecap/pcapio.h>
#include <wiretap/wtap.h>
@ -328,6 +329,7 @@ static int list_config(char *interface)
int main(int argc, char **argv)
{
char* init_progfile_dir_error;
int result;
int option_idx = 0;
int start_from_entries = 10;
@ -337,6 +339,22 @@ int main(int argc, char **argv)
char* help_url;
char* help_header = NULL;
/*
* 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]);
if (init_progfile_dir_error != NULL) {
g_warning("Can't get pathname of directory containing the captype program: %s.",
init_progfile_dir_error);
g_free(init_progfile_dir_error);
}
help_url = data_file_url("sdjournal.html");
extcap_base_set_util_info(extcap_conf, argv[0], SDJOURNAL_VERSION_MAJOR, SDJOURNAL_VERSION_MINOR,
SDJOURNAL_VERSION_RELEASE, help_url);

View File

@ -18,6 +18,7 @@
#include <wsutil/file_util.h>
#include <wsutil/strtoi.h>
#include <wsutil/filesystem.h>
#include <wsutil/privileges.h>
#include <errno.h>
#include <string.h>
@ -336,6 +337,7 @@ static char* concat_filters(const char* extcap_filter, const char* remote_filter
int main(int argc, char *argv[])
{
char* init_progfile_dir_error;
int result;
int option_idx = 0;
ssh_params_t* ssh_params = ssh_params_new();
@ -354,6 +356,22 @@ int main(int argc, char *argv[])
WSADATA wsaData;
#endif /* _WIN32 */
/*
* 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]);
if (init_progfile_dir_error != NULL) {
g_warning("Can't get pathname of directory containing the captype program: %s.",
init_progfile_dir_error);
g_free(init_progfile_dir_error);
}
help_url = data_file_url("sshdump.html");
extcap_base_set_util_info(extcap_conf, argv[0], SSHDUMP_VERSION_MAJOR, SSHDUMP_VERSION_MINOR,
SSHDUMP_VERSION_RELEASE, help_url);

View File

@ -47,6 +47,7 @@
#include <wsutil/strtoi.h>
#include <wsutil/inet_addr.h>
#include <wsutil/filesystem.h>
#include <wsutil/privileges.h>
#include <cli_main.h>
@ -358,6 +359,7 @@ static void run_listener(const char* fifo, const guint16 port, const char* proto
int main(int argc, char *argv[])
{
char* init_progfile_dir_error;
int option_idx = 0;
int result;
guint16 port = 0;
@ -371,6 +373,22 @@ int main(int argc, char *argv[])
WSADATA wsaData;
#endif /* _WIN32 */
/*
* 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]);
if (init_progfile_dir_error != NULL) {
g_warning("Can't get pathname of directory containing the captype program: %s.",
init_progfile_dir_error);
g_free(init_progfile_dir_error);
}
help_url = data_file_url("udpdump.html");
extcap_base_set_util_info(extcap_conf, argv[0], UDPDUMP_VERSION_MAJOR, UDPDUMP_VERSION_MINOR, UDPDUMP_VERSION_RELEASE,
help_url);