From 39124f2f8f3419b624a9e3bab9fac4c2cfe23e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Fri, 20 Jan 2023 14:06:59 +0000 Subject: [PATCH] Fix Personal Extcap folder path The personal extcap folder $XDG_CONFIG_DIR/wireshark on Linux is inconsistent with the global extcap folder (lib/wireshark/extcap) and personal plugins folder (.local/lib/wireshark/plugins) and also the configuration folder should not contain architecture-specific files. The extcap personal folder is changed from: .config/wireshark/extcap to: .local/lib/wireshark/extcap --- docbook/release-notes.adoc | 5 +++++ ui/qt/about_dialog.cpp | 4 ++-- wsutil/filesystem.c | 24 ++++++++++++++++++++++++ wsutil/filesystem.h | 5 +++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/docbook/release-notes.adoc b/docbook/release-notes.adoc index dcbe2b3e4d..f736176e6f 100644 --- a/docbook/release-notes.adoc +++ b/docbook/release-notes.adoc @@ -28,6 +28,11 @@ Display filter autocomplete is smarter about not suggesting invalid syntax. The Windows build has a new SpeexDSP external dependency (https://www.speex.org). The speex code that was previously bundled has been removed. +The personal extcap plugin folder location on Unix has been changed to +follow existing conventions for architecture-dependent files. +The extcap personal folder is now ``$HOME/.local/lib/extcap``. +Previously it was ``$XDG_CONFIG_HOME/wireshark/extcap``. + Many other improvements have been made. See the “New and Updated Features” section below for more details. diff --git a/ui/qt/about_dialog.cpp b/ui/qt/about_dialog.cpp index 7bdbfd29ad..ab640cc59b 100644 --- a/ui/qt/about_dialog.cpp +++ b/ui/qt/about_dialog.cpp @@ -215,8 +215,8 @@ FolderListModel::FolderListModel(QObject * parent): #endif /* Extcap */ - appendRow(QStringList() << tr("Personal Extcap path") << QString(get_persconffile_path("extcap", FALSE)).trimmed() << tr("external capture (extcap) plugins")); - appendRow(QStringList() << tr("Global Extcap path") << QString(get_extcap_dir()).trimmed() << tr("external capture (extcap) plugins")); + appendRow(QStringList() << tr("Personal Extcap path") << QString(get_extcap_pers_dir()) << tr("external capture (extcap) plugins")); + appendRow(QStringList() << tr("Global Extcap path") << QString(get_extcap_dir()) << tr("external capture (extcap) plugins")); #ifdef HAVE_MAXMINDDB /* MaxMind DB */ diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c index 2785ca6baf..e905fc5e4d 100644 --- a/wsutil/filesystem.c +++ b/wsutil/filesystem.c @@ -49,6 +49,7 @@ #define PROFILES_DIR "profiles" #define PLUGINS_DIR_NAME "plugins" +#define EXTCAP_DIR_NAME "extcap" #define PROFILES_INFO_NAME "profile_files.txt" #define _S G_DIR_SEPARATOR_S @@ -1124,6 +1125,7 @@ static char *plugin_dir = NULL; static char *plugin_dir_with_version = NULL; static char *plugin_pers_dir = NULL; static char *plugin_pers_dir_with_version = NULL; +static char *extcap_pers_dir = NULL; static void init_plugin_dir(void) @@ -1351,6 +1353,17 @@ init_extcap_dir(void) #endif } +static void +init_extcap_pers_dir(void) +{ +#ifdef _WIN32 + extcap_pers_dir = get_persconffile_path(EXTCAP_DIR_NAME, FALSE); +#else + extcap_pers_dir = g_build_filename(g_get_home_dir(), ".local/lib", + CONFIGURATION_NAMESPACE_LOWER, EXTCAP_DIR_NAME, (gchar *)NULL); +#endif +} + /* * Get the directory in which the extcap hooks are stored. * @@ -1363,6 +1376,15 @@ get_extcap_dir(void) return extcap_dir; } +/* Get the personal plugin dir */ +const char * +get_extcap_pers_dir(void) +{ + if (!extcap_pers_dir) + init_extcap_pers_dir(); + return extcap_pers_dir; +} + /* * Get the flag indicating whether we're running from a build * directory. @@ -2656,6 +2678,8 @@ free_progdirs(void) #endif g_free(extcap_dir); extcap_dir = NULL; + g_free(extcap_pers_dir); + extcap_pers_dir = NULL; } /* diff --git a/wsutil/filesystem.h b/wsutil/filesystem.h index 19c9db81f7..5700368027 100644 --- a/wsutil/filesystem.h +++ b/wsutil/filesystem.h @@ -102,6 +102,11 @@ WS_DLL_PUBLIC const char *get_plugins_pers_dir_with_version(void); */ WS_DLL_PUBLIC const char *get_extcap_dir(void); +/* + * Get the personal extcap dir. + */ +WS_DLL_PUBLIC const char *get_extcap_pers_dir(void); + /* * Get the flag indicating whether we're running from a build * directory.