From: Eric Bollengier Date: Tue, 23 Nov 2010 17:36:39 +0000 (+0100) Subject: Ensure that two plugins starting with the same name won't share events X-Git-Tag: Release-5.2.1~888 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dda0e407a4ad5e625448adf48a7fc9b97b36d626;p=bacula%2Fbacula Ensure that two plugins starting with the same name won't share events --- diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index f4e490538b..181a415821 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -327,8 +327,8 @@ int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level) /* Note, we stop the loop on the first plugin that matches the name */ foreach_alist(plugin, plugin_list) { - Dmsg3(dbglvl, "plugin=%s cmd=%s len=%d\n", plugin->file, cmd, len); - if (strncmp(plugin->file, cmd, len) != 0) { + Dmsg4(0, "plugin=%s plen=%d cmd=%s len=%d\n", plugin->file, plugin->len, cmd, len); + if ((plugin->len != len) || (strncmp(plugin->file, cmd, len) != 0)) { i++; continue; } diff --git a/bacula/src/lib/plugins.c b/bacula/src/lib/plugins.c index de0819dd7a..cd1071929e 100644 --- a/bacula/src/lib/plugins.c +++ b/bacula/src/lib/plugins.c @@ -155,6 +155,7 @@ bool load_plugins(void *binfo, void *bfuncs, const char *plugin_dir, plugin = new_plugin(); plugin->file = bstrdup(result->d_name); + plugin->len = strstr(plugin->file, "-fd.") - plugin->file; plugin->pHandle = dlopen(fname.c_str(), RTLD_NOW); if (!plugin->pHandle) { Jmsg(NULL, M_ERROR, 0, _("Plugin load %s failed: ERR=%s\n"), diff --git a/bacula/src/lib/plugins.h b/bacula/src/lib/plugins.h index 5ab1603ba0..7c10a1f99e 100644 --- a/bacula/src/lib/plugins.h +++ b/bacula/src/lib/plugins.h @@ -71,6 +71,7 @@ typedef bRC (*t_unloadPlugin)(void); class Plugin { public: char *file; + int32_t len; t_unloadPlugin unloadPlugin; void *pinfo; void *pfuncs;