+/**
+ * Check if a plugin is compatible. Called by the load_plugin function
+ * to allow us to verify the plugin.
+ */
+static bool is_plugin_compatible(Plugin *plugin)
+{
+ psdInfo *info = (psdInfo *)plugin->pinfo;
+ Dmsg0(50, "is_plugin_compatible called\n");
+ if (chk_dbglvl(50)) {
+ dump_sd_plugin(plugin, stdin);
+ }
+ if (strcmp(info->plugin_magic, SD_PLUGIN_MAGIC) != 0) {
+ Jmsg(NULL, M_ERROR, 0, _("Plugin magic wrong. Plugin=%s wanted=%s got=%s\n"),
+ plugin->file, SD_PLUGIN_MAGIC, info->plugin_magic);
+ Dmsg3(000, "Plugin magic wrong. Plugin=%s wanted=%s got=%s\n",
+ plugin->file, SD_PLUGIN_MAGIC, info->plugin_magic);
+
+ return false;
+ }
+ if (info->version != SD_PLUGIN_INTERFACE_VERSION) {
+ Jmsg(NULL, M_ERROR, 0, _("Plugin version incorrect. Plugin=%s wanted=%d got=%d\n"),
+ plugin->file, SD_PLUGIN_INTERFACE_VERSION, info->version);
+ Dmsg3(000, "Plugin version incorrect. Plugin=%s wanted=%d got=%d\n",
+ plugin->file, SD_PLUGIN_INTERFACE_VERSION, info->version);
+ return false;
+ }
+ if (strcmp(info->plugin_license, "Bacula AGPLv3") != 0 &&
+ strcmp(info->plugin_license, "AGPLv3") != 0 &&
+ strcmp(info->plugin_license, "Bacula") != 0) {
+ Jmsg(NULL, M_ERROR, 0, _("Plugin license incompatible. Plugin=%s license=%s\n"),
+ plugin->file, info->plugin_license);
+ Dmsg2(000, "Plugin license incompatible. Plugin=%s license=%s\n",
+ plugin->file, info->plugin_license);
+ return false;
+ }
+ if (info->size != sizeof(psdInfo)) {
+ Jmsg(NULL, M_ERROR, 0,
+ _("Plugin size incorrect. Plugin=%s wanted=%d got=%d\n"),
+ plugin->file, sizeof(psdInfo), info->size);
+ return false;
+ }
+
+ return true;
+}
+
+