aboutsummaryrefslogtreecommitdiffstats
path: root/extcap.c
diff options
context:
space:
mode:
authorRoland Knall <rknall@gmail.com>2019-11-05 15:10:23 +0000
committerRoland Knall <rknall@gmail.com>2019-11-05 16:57:09 +0000
commit0e64e9f3ca36e9917fae0017a7a5afbe28e46469 (patch)
tree1e48d428d8a33cbd3046c920c09e24d6b3e0f8bd /extcap.c
parenta802000a2e6d078a9875d6fef3f7a1630414da04 (diff)
extcap: Allow loading of extcap files from personal directory
Allow the storage of extcap plugins in the personal directory and enable loading from there. It will also take precedence of any system-wide extcaps with an identical name Change-Id: Ib88e09a26c4f99cf5e793327f2808c7445c6b1b5 Reviewed-on: https://code.wireshark.org/review/34988 Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'extcap.c')
-rw-r--r--extcap.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/extcap.c b/extcap.c
index fcf3ab8f78..8921915c7a 100644
--- a/extcap.c
+++ b/extcap.c
@@ -219,17 +219,13 @@ extcap_dump_all(void)
extcap_get_descriptions(print_extcap_description, NULL);
}
-/**
- * Obtains a list of extcap program paths. Use g_slist_free_full(paths, g_free)
- * to destroy the list.
- */
static GSList *
-extcap_get_extcap_paths(void)
+extcap_get_extcap_paths_from_dir(GSList * list, const char * dirname)
{
- GDir *dir;
- const char *dirname = get_extcap_dir();
- const gchar *file;
- GSList *paths = NULL;
+ GDir * dir;
+ const char * file;
+
+ GSList * paths = list;
if ((dir = g_dir_open(dirname, 0, NULL)) != NULL) {
while ((file = g_dir_read_name(dir)) != NULL) {
@@ -250,6 +246,21 @@ extcap_get_extcap_paths(void)
return paths;
}
+/**
+ * Obtains a list of extcap program paths. Use g_slist_free_full(paths, g_free)
+ * to destroy the list.
+ */
+static GSList *
+extcap_get_extcap_paths(void)
+{
+ GSList *paths = NULL;
+
+ paths = extcap_get_extcap_paths_from_dir(paths, get_persconffile_path("extcap", FALSE));
+ paths = extcap_get_extcap_paths_from_dir(paths, get_extcap_dir());
+
+ return paths;
+}
+
static extcap_interface *
extcap_find_interface_for_ifname(const gchar *ifname)
{
@@ -1688,6 +1699,9 @@ extcap_ensure_interface(const gchar * toolname, gboolean create_if_nonexist)
_loaded_interfaces = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, extcap_free_interface);
element = (extcap_info *) g_hash_table_lookup(_loaded_interfaces, toolname );
+ if ( element )
+ return NULL;
+
if ( ! element && create_if_nonexist )
{
g_hash_table_insert(_loaded_interfaces, g_strdup(toolname), g_new0(extcap_info, 1));
@@ -1753,7 +1767,8 @@ process_new_extcap(const char *extcap, char *output)
element = extcap_ensure_interface(toolname, TRUE);
if ( element == NULL )
{
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_ERROR, "Cannot store interface %s, maybe duplicate?", extcap );
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_WARNING,
+ "Cannot store interface %s, already loaded as personal plugin", extcap );
g_list_foreach(interfaces, remove_extcap_entry, NULL);
g_list_free(interfaces);
g_list_free(interface_keys);