extcap, plugins: Check for identical personal plugin directory

Check for an identical personal plugin or extcap directory, and don't
try to load extcap or plugins a second time from an identical directory.
This mostly can happen when using the --global-profile option, though I
suppose there are other methods as well like links.

Prevents some warnings about trying to load the same plugin or extcap
(or a plugin or extcap of the same name) like:

tshark: The plugin 'usbdump.dll' was found in multiple directories
 ** (tshark:11896) 07:28:36.907856 [Extcap WARNING] C:\gitlab-builds\builds\MsQ3pox2\0\wireshark\wireshark\extcap.c:1955 -- process_new_extcap(): Cannot store interface C:\Program Files\Wireshark\extcap\ciscodump.exe, already loaded as personal plugin
 tshark: Unable to load sinsp plugin C:\Development\wsbuild68\run\RelWithDebInfo\plugins\falco\cloudtrail.dll: Caught sinsp exception cannot register plugin C:\Development\wsbuild68\run\RelWithDebInfo\plugins\falco\cloudtrail.dll in inspector: found another plugin with name cloudtrail. Aborting..

Ping #20454
This commit is contained in:
John Thacker 2025-06-15 14:40:57 -04:00
parent 4015e9250c
commit a7aff4f333
3 changed files with 6 additions and 4 deletions

View File

@ -274,7 +274,9 @@ extcap_get_extcap_paths(void)
GSList *paths = NULL;
paths = extcap_get_extcap_paths_from_dir(paths, get_extcap_pers_dir());
paths = extcap_get_extcap_paths_from_dir(paths, get_extcap_dir());
if (!files_identical(get_extcap_pers_dir(), get_extcap_dir())) {
paths = extcap_get_extcap_paths_from_dir(paths, get_extcap_dir());
}
return paths;
}

View File

@ -1608,7 +1608,7 @@ proto_register_falcoplugin(void)
ws_dir_close(dir);
}
if ((dir = ws_dir_open(ppdname, 0, NULL)) != NULL) {
if (!files_identical(ppdname, spdname) && (dir = ws_dir_open(ppdname, 0, NULL)) != NULL) {
while ((ws_dir_read_name(dir)) != NULL) {
nbridges++;
}
@ -1633,7 +1633,7 @@ proto_register_falcoplugin(void)
ws_dir_close(dir);
}
if ((dir = ws_dir_open(ppdname, 0, NULL)) != NULL) {
if (!files_identical(ppdname, spdname) && (dir = ws_dir_open(ppdname, 0, NULL)) != NULL) {
while ((file = ws_dir_read_name(dir)) != NULL) {
filename = g_build_filename(ppdname, ws_dir_get_name(file), NULL);
import_plugin(filename);

View File

@ -251,7 +251,7 @@ plugins_init(plugin_type_e type)
* if we need privileges to start capturing, we'd need to
* reclaim them before each time we start capturing.)
*/
if (!started_with_special_privs()) {
if (!started_with_special_privs() && !files_identical(get_plugins_dir_with_version(), get_plugins_pers_dir_with_version())) {
scan_plugins_dir(plugins_module, get_plugins_pers_dir_with_version(), type, true);
}