/*
Bacula® - The Network Backup Solution
- Copyright (C) 2007-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2007-2011 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
extern CLIENT *me;
extern DLL_IMP_EXP char *exepath;
+extern DLL_IMP_EXP char *version;
+extern DLL_IMP_EXP char *dist_name;
+extern DLL_IMP_EXP int beef;
const int dbglvl = 150;
#ifdef HAVE_WIN32
case bEventEndVerifyJob:
call_if_canceled = true;
break;
+ case bEventStartRestoreJob:
+ if (jcr->plugin) {
+ jcr->plugin->restoreFileStarted = false;
+ jcr->plugin->createFileCalled = false;
+ }
+ break;
case bEventEndRestoreJob:
call_if_canceled = true;
if (jcr->plugin && jcr->plugin->restoreFileStarted) {
plug_func(jcr->plugin)->endRestoreFile(jcr->plugin_ctx);
jcr->plugin->restoreFileStarted = false;
+ jcr->plugin->createFileCalled = false;
}
break;
default:
/* Note, we stop the loop on the first plugin that matches the name */
foreach_alist(plugin, plugin_list) {
- Dmsg4(0, "plugin=%s plen=%d cmd=%s len=%d\n", plugin->file, plugin->file_len, cmd, len);
+ Dmsg4(dbglvl, "plugin=%s plen=%d cmd=%s len=%d\n", plugin->file, plugin->file_len, cmd, len);
if (!for_this_plug(plugin, cmd, len)) {
i++;
continue;
stat = sd->fsend("%ld 1 %d %s%c", index, sp->portable, sp->cmd, 0);
} else {
/* Send end of data */
- stat = sd->fsend("0 0");
+ stat = sd->fsend("%ld 0", jcr->JobFiles);
}
if (!stat) {
Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
if (jcr->plugin && jcr->plugin->restoreFileStarted) {
plug_func(jcr->plugin)->endRestoreFile(jcr->plugin_ctx);
jcr->plugin->restoreFileStarted = false;
+ jcr->plugin->createFileCalled = false;
}
jcr->plugin_ctx = NULL;
jcr->plugin = NULL;
&event, cmd) != bRC_OK) {
goto bail_out;
}
- /* ***FIXME**** check error code */
- if (plugin->restoreFileStarted) {
- plug_func(jcr->plugin)->endRestoreFile(jcr->plugin_ctx);
+ if (plugin->restoreFileStarted)
+ {
+ Jmsg0(jcr, M_FATAL, 0, "Unbalanced call to startRestoreFile\n");
+ goto bail_out;
}
- plug_func(plugin)->startRestoreFile((bpContext *)jcr->plugin_ctx, cmd);
+ plug_func(plugin)->startRestoreFile(jcr->plugin_ctx, cmd);
plugin->restoreFileStarted = true;
goto bail_out;
}
if (rp.attrEx) {
Dmsg1(dbglvl, "attrEx=\"%s\"\n", rp.attrEx);
}
+ if (!plugin->restoreFileStarted || plugin->createFileCalled)
+ {
+ Jmsg0(jcr, M_FATAL, 0, "Unbalanced call to createFile\n");
+ return CF_ERROR;
+ }
rc = plug_func(plugin)->createFile(plugin_ctx, &rp);
if (rc != bRC_OK) {
Qmsg2(jcr, M_ERROR, 0, _("Plugin createFile call failed. Stat=%d file=%s\n"),
plugin->file, info->plugin_license);
return false;
}
-
+ if (info->size != sizeof(pInfo)) {
+ Jmsg(NULL, M_ERROR, 0, _("Plugin size mismatch.\n"));
+ return false;
+ }
return true;
}
case bVarExePath:
*(char **)value = exepath;
break;
+ case bVarVersion:
+ *(char **)value = version;
+ break;
+ case bVarDistName:
+ *(char **)value = dist_name;
+ break;
+ case bVarBEEF:
+ *((int *)value) = beef;
+ break;
default:
break;
}
case bVarFDName: /* get warning with g++ if we missed one */
case bVarWorkingDir:
case bVarExePath:
+ case bVarVersion:
+ case bVarDistName:
+ case bVarBEEF:
break;
}
return bRC_OK;