forked from osmocom/wireshark
wsutil: Make progfile_dir the main program file directory.
If our program file directory has a trailing "/extcap" or "\extcap", trim it off. This should let extcaps determine the proper data file and plugin directories. Fixes #15592.
This commit is contained in:
parent
e9176b652d
commit
5dcefc7777
|
@ -517,6 +517,20 @@ get_executable_path(void)
|
||||||
}
|
}
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
static void trim_progfile_dir(void)
|
||||||
|
{
|
||||||
|
char *progfile_last_dir = find_last_pathname_separator(progfile_dir);
|
||||||
|
|
||||||
|
if (! (progfile_last_dir && strncmp(progfile_last_dir + 1, "extcap", sizeof("extcap")) == 0)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
*progfile_last_dir = '\0';
|
||||||
|
char *extcap_progfile_dir = progfile_dir;
|
||||||
|
progfile_dir = g_strdup(extcap_progfile_dir);
|
||||||
|
g_free(extcap_progfile_dir);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the pathname of the directory from which the executable came,
|
* Get the pathname of the directory from which the executable came,
|
||||||
* and save it for future use. Returns NULL on success, and a
|
* and save it for future use. Returns NULL on success, and a
|
||||||
|
@ -558,6 +572,7 @@ configuration_init(
|
||||||
*/
|
*/
|
||||||
progfile_dir = g_path_get_dirname(prog_pathname);
|
progfile_dir = g_path_get_dirname(prog_pathname);
|
||||||
if (progfile_dir != NULL) {
|
if (progfile_dir != NULL) {
|
||||||
|
trim_progfile_dir();
|
||||||
return NULL; /* we succeeded */
|
return NULL; /* we succeeded */
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
|
@ -812,6 +827,7 @@ configuration_init(
|
||||||
* OK, we have the path we want.
|
* OK, we have the path we want.
|
||||||
*/
|
*/
|
||||||
progfile_dir = prog_pathname;
|
progfile_dir = prog_pathname;
|
||||||
|
trim_progfile_dir();
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -53,7 +53,11 @@ WS_DLL_PUBLIC const char *get_configuration_namespace(void);
|
||||||
WS_DLL_PUBLIC bool is_packet_configuration_namespace(void);
|
WS_DLL_PUBLIC bool is_packet_configuration_namespace(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the directory in which the program resides.
|
* Get the directory in which the main (Wireshark, TShark, Logray, etc)
|
||||||
|
* program resides.
|
||||||
|
* Extcaps should use get_extcap_dir() to get their path.
|
||||||
|
*
|
||||||
|
* @return The main program file directory.
|
||||||
*/
|
*/
|
||||||
WS_DLL_PUBLIC const char *get_progfile_dir(void);
|
WS_DLL_PUBLIC const char *get_progfile_dir(void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue