2 * Bacula File Daemon Job processing
4 * Kern Sibbald, October MM
10 Copyright (C) 2000-2005 Kern Sibbald
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation; either version 2 of
15 the License, or (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 General Public License for more details.
22 You should have received a copy of the GNU General Public
23 License along with this program; if not, write to the Free
24 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
32 extern char my_name[];
33 extern CLIENT *me; /* our client resource */
35 /* Imported functions */
36 extern int status_cmd(JCR *jcr);
37 extern int qstatus_cmd(JCR *jcr);
39 /* Forward referenced functions */
40 static int backup_cmd(JCR *jcr);
41 static int bootstrap_cmd(JCR *jcr);
42 static int cancel_cmd(JCR *jcr);
43 static int setdebug_cmd(JCR *jcr);
44 static int estimate_cmd(JCR *jcr);
45 static int hello_cmd(JCR *jcr);
46 static int job_cmd(JCR *jcr);
47 static int fileset_cmd(JCR *jcr);
48 static int level_cmd(JCR *jcr);
49 static int verify_cmd(JCR *jcr);
50 static int restore_cmd(JCR *jcr);
51 static int storage_cmd(JCR *jcr);
52 static int session_cmd(JCR *jcr);
53 static int response(JCR *jcr, BSOCK *sd, char *resp, const char *cmd);
54 static void filed_free_jcr(JCR *jcr);
55 static int open_sd_read_session(JCR *jcr);
56 static int send_bootstrap_file(JCR *jcr);
57 static int runbefore_cmd(JCR *jcr);
58 static int runafter_cmd(JCR *jcr);
59 static bool run_cmd(JCR *jcr, char *cmd, const char *name);
60 static void set_options(findFOPTS *fo, const char *opts);
63 /* Exported functions */
68 int monitoraccess; /* specify if monitors have access to this function */
72 * The following are the recognized commands from the Director.
74 static struct s_cmds cmds[] = {
75 {"backup", backup_cmd, 0},
76 {"cancel", cancel_cmd, 0},
77 {"setdebug=", setdebug_cmd, 0},
78 {"estimate", estimate_cmd, 0},
79 {"Hello", hello_cmd, 1},
80 {"fileset", fileset_cmd, 0},
81 {"JobId=", job_cmd, 0},
82 {"level = ", level_cmd, 0},
83 {"restore", restore_cmd, 0},
84 {"session", session_cmd, 0},
85 {"status", status_cmd, 1},
86 {".status", qstatus_cmd, 1},
87 {"storage ", storage_cmd, 0},
88 {"verify", verify_cmd, 0},
89 {"bootstrap", bootstrap_cmd, 0},
90 {"RunBeforeJob", runbefore_cmd, 0},
91 {"RunAfterJob", runafter_cmd, 0},
92 {NULL, NULL} /* list terminator */
95 /* Commands received from director that need scanning */
96 static char jobcmd[] = "JobId=%d Job=%127s SDid=%d SDtime=%d Authorization=%100s";
97 static char storaddr[] = "storage address=%s port=%d ssl=%d\n";
98 static char sessioncmd[] = "session %127s %ld %ld %ld %ld %ld %ld\n";
99 static char restorecmd[] = "restore replace=%c prelinks=%d where=%s\n";
100 static char restorecmd1[] = "restore replace=%c prelinks=%d where=\n";
101 static char verifycmd[] = "verify level=%30s\n";
102 static char estimatecmd[] = "estimate listing=%d\n";
103 static char runbefore[] = "RunBeforeJob %s\n";
104 static char runafter[] = "RunAfterJob %s\n";
106 /* Responses sent to Director */
107 static char errmsg[] = "2999 Invalid command\n";
108 static char no_auth[] = "2998 No Authorization\n";
109 static char illegal_cmd[] = "2997 Illegal command for a Director with Monitor directive enabled\n";
110 static char OKinc[] = "2000 OK include\n";
111 static char OKest[] = "2000 OK estimate files=%u bytes=%s\n";
112 static char OKlevel[] = "2000 OK level\n";
113 static char OKbackup[] = "2000 OK backup\n";
114 static char OKbootstrap[] = "2000 OK bootstrap\n";
115 static char OKverify[] = "2000 OK verify\n";
116 static char OKrestore[] = "2000 OK restore\n";
117 static char OKsession[] = "2000 OK session\n";
118 static char OKstore[] = "2000 OK storage\n";
119 static char OKjob[] = "2000 OK Job %s,%s,%s";
120 static char OKsetdebug[] = "2000 OK setdebug=%d\n";
121 static char BADjob[] = "2901 Bad Job\n";
122 static char EndJob[] = "2800 End Job TermCode=%d JobFiles=%u ReadBytes=%s JobBytes=%s Errors=%u\n";
123 static char OKRunBefore[] = "2000 OK RunBefore\n";
124 static char OKRunAfter[] = "2000 OK RunAfter\n";
126 /* Responses received from Storage Daemon */
127 static char OK_end[] = "3000 OK end\n";
128 static char OK_close[] = "3000 OK close Status = %d\n";
129 static char OK_open[] = "3000 OK open ticket = %d\n";
130 static char OK_data[] = "3000 OK data\n";
131 static char OK_append[] = "3000 OK append data\n";
132 static char OKSDbootstrap[] = "3000 OK bootstrap\n";
135 /* Commands sent to Storage Daemon */
136 static char append_open[] = "append open session\n";
137 static char append_data[] = "append data %d\n";
138 static char append_end[] = "append end session %d\n";
139 static char append_close[] = "append close session %d\n";
140 static char read_open[] = "read open session = %s %ld %ld %ld %ld %ld %ld\n";
141 static char read_data[] = "read data %d\n";
142 static char read_close[] = "read close session %d\n";
145 * Accept requests from a Director
147 * NOTE! We are running as a separate thread
149 * Send output one line
150 * at a time followed by a zero length transmission.
152 * Return when the connection is terminated or there
155 * Basic task here is:
156 * Authenticate Director (during Hello command).
157 * Accept commands one at a time from the Director
161 void *handle_client_request(void *dirp)
166 BSOCK *dir = (BSOCK *)dirp;
168 jcr = new_jcr(sizeof(JCR), filed_free_jcr); /* create JCR */
169 jcr->dir_bsock = dir;
170 jcr->ff = init_find_files();
171 jcr->start_time = time(NULL);
172 jcr->last_fname = get_pool_memory(PM_FNAME);
173 jcr->last_fname[0] = 0;
174 jcr->client_name = get_memory(strlen(my_name) + 1);
175 pm_strcpy(jcr->client_name, my_name);
177 enable_backup_privileges(NULL, 1 /* ignore_errors */);
179 /**********FIXME******* add command handler error code */
181 for (quit=false; !quit;) {
184 if (bnet_recv(dir) < 0) {
185 break; /* connection terminated */
187 dir->msg[dir->msglen] = 0;
188 Dmsg1(100, "<dird: %s", dir->msg);
190 for (i=0; cmds[i].cmd; i++) {
191 if (strncmp(cmds[i].cmd, dir->msg, strlen(cmds[i].cmd)) == 0) {
192 found = true; /* indicate command found */
193 if (!jcr->authenticated && cmds[i].func != hello_cmd) {
194 bnet_fsend(dir, no_auth);
195 bnet_sig(dir, BNET_EOD);
198 if ((jcr->authenticated) && (!cmds[i].monitoraccess) && (jcr->director->monitor)) {
199 Dmsg1(100, "Command %s illegal.\n", cmds[i].cmd);
200 bnet_fsend(dir, illegal_cmd);
201 bnet_sig(dir, BNET_EOD);
204 Dmsg1(100, "Executing %s command.\n", cmds[i].cmd);
205 if (!cmds[i].func(jcr)) { /* do command */
206 quit = true; /* error or fully terminated, get out */
207 Dmsg1(20, "Quit command loop. Canceled=%d\n", job_canceled(jcr));
212 if (!found) { /* command not found */
213 bnet_fsend(dir, errmsg);
219 /* Inform Storage daemon that we are done */
220 if (jcr->store_bsock) {
221 bnet_sig(jcr->store_bsock, BNET_TERMINATE);
224 if (jcr->RunAfterJob && !job_canceled(jcr)) {
225 run_cmd(jcr, jcr->RunAfterJob, "ClientRunAfterJob");
227 generate_daemon_event(jcr, "JobEnd");
229 dequeue_messages(jcr); /* send any queued messages */
231 /* Inform Director that we are done */
232 bnet_sig(dir, BNET_TERMINATE);
234 /* Clean up fileset */
235 FF_PKT *ff = (FF_PKT *)jcr->ff;
236 findFILESET *fileset = ff->fileset;
239 /* Delete FileSet Include lists */
240 for (i=0; i<fileset->include_list.size(); i++) {
241 findINCEXE *incexe = (findINCEXE *)fileset->include_list.get(i);
242 for (j=0; j<incexe->opts_list.size(); j++) {
243 findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
244 for (k=0; k<fo->regex.size(); k++) {
245 regfree((regex_t *)fo->regex.get(k));
248 fo->regexdir.destroy();
249 fo->regexfile.destroy();
251 fo->wilddir.destroy();
252 fo->wildfile.destroy();
254 fo->fstype.destroy();
262 incexe->opts_list.destroy();
263 incexe->name_list.destroy();
265 fileset->include_list.destroy();
267 /* Delete FileSet Exclude lists */
268 for (i=0; i<fileset->exclude_list.size(); i++) {
269 findINCEXE *incexe = (findINCEXE *)fileset->exclude_list.get(i);
270 for (j=0; j<incexe->opts_list.size(); j++) {
271 findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
273 fo->regexdir.destroy();
274 fo->regexfile.destroy();
276 fo->wilddir.destroy();
277 fo->wildfile.destroy();
279 fo->fstype.destroy();
281 incexe->opts_list.destroy();
282 incexe->name_list.destroy();
284 fileset->exclude_list.destroy();
288 Dmsg0(100, "Calling term_find_files\n");
289 term_find_files((FF_PKT *)jcr->ff);
291 Dmsg0(100, "Done with term_find_files\n");
292 free_jcr(jcr); /* destroy JCR record */
293 Dmsg0(100, "Done with free_jcr\n");
298 * Hello from Director he must identify himself and provide his
301 static int hello_cmd(JCR *jcr)
303 Dmsg0(120, "Calling Authenticate\n");
304 if (!authenticate_director(jcr)) {
307 Dmsg0(120, "OK Authenticate\n");
308 jcr->authenticated = true;
315 static int cancel_cmd(JCR *jcr)
317 BSOCK *dir = jcr->dir_bsock;
318 char Job[MAX_NAME_LENGTH];
321 if (sscanf(dir->msg, "cancel Job=%127s", Job) == 1) {
322 if (!(cjcr=get_jcr_by_full_name(Job))) {
323 bnet_fsend(dir, "2901 Job %s not found.\n", Job);
325 if (cjcr->store_bsock) {
327 cjcr->store_bsock->timed_out = 1;
328 cjcr->store_bsock->terminated = 1;
330 * #if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32)
332 #if !defined(HAVE_CYGWIN)
333 pthread_kill(cjcr->my_thread_id, TIMEOUT_SIGNAL);
337 set_jcr_job_status(cjcr, JS_Canceled);
339 bnet_fsend(dir, _("2001 Job %s marked to be canceled.\n"), Job);
342 bnet_fsend(dir, _("2902 Error scanning cancel command.\n"));
344 bnet_sig(dir, BNET_EOD);
350 * Set debug level as requested by the Director
353 static int setdebug_cmd(JCR *jcr)
355 BSOCK *dir = jcr->dir_bsock;
356 int level, trace_flag;
358 Dmsg1(110, "setdebug_cmd: %s", dir->msg);
359 if (sscanf(dir->msg, "setdebug=%d trace=%d", &level, &trace_flag) != 2 || level < 0) {
360 pm_strcpy(jcr->errmsg, dir->msg);
361 bnet_fsend(dir, "2991 Bad setdebug command: %s\n", jcr->errmsg);
365 set_trace(trace_flag);
366 return bnet_fsend(dir, OKsetdebug, level);
370 static int estimate_cmd(JCR *jcr)
372 BSOCK *dir = jcr->dir_bsock;
375 if (sscanf(dir->msg, estimatecmd, &jcr->listing) != 1) {
376 pm_strcpy(jcr->errmsg, dir->msg);
377 Jmsg(jcr, M_FATAL, 0, _("Bad estimate command: %s"), jcr->errmsg);
378 bnet_fsend(dir, "2992 Bad estimate command.\n");
382 bnet_fsend(dir, OKest, jcr->num_files_examined,
383 edit_uint64_with_commas(jcr->JobBytes, ed2));
384 bnet_sig(dir, BNET_EOD);
389 * Get JobId and Storage Daemon Authorization key from Director
391 static int job_cmd(JCR *jcr)
393 BSOCK *dir = jcr->dir_bsock;
394 POOLMEM *sd_auth_key;
396 sd_auth_key = get_memory(dir->msglen);
397 if (sscanf(dir->msg, jobcmd, &jcr->JobId, jcr->Job,
398 &jcr->VolSessionId, &jcr->VolSessionTime,
400 pm_strcpy(jcr->errmsg, dir->msg);
401 Jmsg(jcr, M_FATAL, 0, _("Bad Job Command: %s"), jcr->errmsg);
402 bnet_fsend(dir, BADjob);
403 free_pool_memory(sd_auth_key);
406 jcr->sd_auth_key = bstrdup(sd_auth_key);
407 free_pool_memory(sd_auth_key);
408 Dmsg2(120, "JobId=%d Auth=%s\n", jcr->JobId, jcr->sd_auth_key);
409 return bnet_fsend(dir, OKjob, HOST_OS, DISTNAME, DISTVER);
412 static int runbefore_cmd(JCR *jcr)
415 BSOCK *dir = jcr->dir_bsock;
416 POOLMEM *cmd = get_memory(dir->msglen+1);
418 Dmsg1(100, "runbefore_cmd: %s", dir->msg);
419 if (sscanf(dir->msg, runbefore, cmd) != 1) {
420 pm_strcpy(jcr->errmsg, dir->msg);
421 Jmsg1(jcr, M_FATAL, 0, _("Bad RunBeforeJob command: %s\n"), jcr->errmsg);
422 bnet_fsend(dir, "2905 Bad RunBeforeJob command.\n");
428 /* Run the command now */
429 ok = run_cmd(jcr, cmd, "ClientRunBeforeJob");
432 bnet_fsend(dir, OKRunBefore);
435 bnet_fsend(dir, "2905 Bad RunBeforeJob command.\n");
440 static int runafter_cmd(JCR *jcr)
442 BSOCK *dir = jcr->dir_bsock;
443 POOLMEM *msg = get_memory(dir->msglen+1);
445 Dmsg1(100, "runafter_cmd: %s", dir->msg);
446 if (sscanf(dir->msg, runafter, msg) != 1) {
447 pm_strcpy(jcr->errmsg, dir->msg);
448 Jmsg1(jcr, M_FATAL, 0, _("Bad RunAfter command: %s\n"), jcr->errmsg);
449 bnet_fsend(dir, "2905 Bad RunAfterJob command.\n");
454 if (jcr->RunAfterJob) {
455 free_pool_memory(jcr->RunAfterJob);
457 jcr->RunAfterJob = get_pool_memory(PM_FNAME);
458 pm_strcpy(jcr->RunAfterJob, msg);
459 free_pool_memory(msg);
460 return bnet_fsend(dir, OKRunAfter);
463 static bool run_cmd(JCR *jcr, char *cmd, const char *name)
465 POOLMEM *ecmd = get_pool_memory(PM_FNAME);
468 char line[MAXSTRING];
470 ecmd = edit_job_codes(jcr, ecmd, cmd, "");
471 bpipe = open_bpipe(ecmd, 0, "r");
472 free_pool_memory(ecmd);
475 Jmsg(jcr, M_FATAL, 0, _("%s could not execute. ERR=%s\n"), name,
479 while (fgets(line, sizeof(line), bpipe->rfd)) {
480 int len = strlen(line);
481 if (len > 0 && line[len-1] == '\n') {
484 Jmsg(jcr, M_INFO, 0, _("%s: %s\n"), name, line);
486 status = close_bpipe(bpipe);
489 Jmsg(jcr, M_FATAL, 0, _("%s returned non-zero status=%d. ERR=%s\n"), name,
490 status, be.strerror(status));
496 static bool init_fileset(JCR *jcr)
499 findFILESET *fileset;
504 ff = (FF_PKT *)jcr->ff;
508 fileset = (findFILESET *)malloc(sizeof(findFILESET));
509 memset(fileset, 0, sizeof(findFILESET));
510 ff->fileset = fileset;
511 fileset->state = state_none;
512 fileset->include_list.init(1, true);
513 fileset->exclude_list.init(1, true);
517 static findFOPTS *start_options(FF_PKT *ff)
519 int state = ff->fileset->state;
520 findINCEXE *incexe = ff->fileset->incexe;
522 if (state != state_options) {
523 ff->fileset->state = state_options;
524 findFOPTS *fo = (findFOPTS *)malloc(sizeof(findFOPTS));
525 memset(fo, 0, sizeof(findFOPTS));
526 fo->regex.init(1, true);
527 fo->regexdir.init(1, true);
528 fo->regexfile.init(1, true);
529 fo->wild.init(1, true);
530 fo->wilddir.init(1, true);
531 fo->wildfile.init(1, true);
532 fo->base.init(1, true);
533 fo->fstype.init(1, true);
534 incexe->current_opts = fo;
535 incexe->opts_list.append(fo);
537 return incexe->current_opts;
542 * Add fname to include/exclude fileset list. First check for
543 * | and < and if necessary perform command.
545 static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *fileset)
557 p++; /* skip over | */
558 fn = get_pool_memory(PM_FNAME);
559 fn = edit_job_codes(jcr, fn, p, "");
560 bpipe = open_bpipe(fn, 0, "r");
561 free_pool_memory(fn);
563 Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
567 while (fgets(buf, sizeof(buf), bpipe->rfd)) {
568 strip_trailing_junk(buf);
569 fileset->incexe->name_list.append(bstrdup(buf));
571 if ((stat=close_bpipe(bpipe)) != 0) {
572 Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"),
573 p, stat, strerror(errno));
578 Dmsg0(100, "Doing < include on client.\n");
579 p++; /* skip over < */
580 if ((ffd = fopen(p, "r")) == NULL) {
582 Jmsg(jcr, M_FATAL, 0, _("Cannot open FileSet input file: %s. ERR=%s\n"),
586 while (fgets(buf, sizeof(buf), ffd)) {
587 strip_trailing_junk(buf);
588 Dmsg1(100, "%s\n", buf);
589 fileset->incexe->name_list.append(bstrdup(buf));
594 fileset->incexe->name_list.append(bstrdup(fname));
600 static void add_fileset(JCR *jcr, const char *item)
602 FF_PKT *ff = (FF_PKT *)jcr->ff;
603 findFILESET *fileset = ff->fileset;
604 int state = fileset->state;
605 findFOPTS *current_opts;
607 /* Get code, optional subcode, and position item past the dividing space */
608 Dmsg1(100, "%s\n", item);
613 int subcode = ' '; /* A space is always a valid subcode */
614 if (item[0] != '\0' && item[0] != ' ') {
622 /* Skip all lines we receive after an error */
623 if (state == state_error) {
628 * The switch tests the code for validity.
629 * The subcode is always good if it is a space, otherwise we must confirm.
630 * We set state to state_error first assuming the subcode is invalid,
631 * requiring state to be set in cases below that handle subcodes.
633 if (subcode != ' ') {
639 fileset->incexe = (findINCEXE *)malloc(sizeof(findINCEXE));
640 memset(fileset->incexe, 0, sizeof(findINCEXE));
641 fileset->incexe->opts_list.init(1, true);
642 fileset->incexe->name_list.init(1, true);
643 fileset->include_list.append(fileset->incexe);
647 fileset->incexe = (findINCEXE *)malloc(sizeof(findINCEXE));
648 memset(fileset->incexe, 0, sizeof(findINCEXE));
649 fileset->incexe->opts_list.init(1, true);
650 fileset->incexe->name_list.init(1, true);
651 fileset->exclude_list.append(fileset->incexe);
657 /* File item to either include/include list */
658 state = state_include;
659 add_file_to_fileset(jcr, item, fileset);
662 current_opts = start_options(ff);
666 preg = (regex_t *)malloc(sizeof(regex_t));
667 if (current_opts->flags & FO_IGNORECASE) {
668 rc = regcomp(preg, item, REG_EXTENDED|REG_ICASE);
670 rc = regcomp(preg, item, REG_EXTENDED);
673 regerror(rc, preg, prbuf, sizeof(prbuf));
676 Jmsg(jcr, M_FATAL, 0, "REGEX %s compile error. ERR=%s\n", item, prbuf);
680 state = state_options;
681 if (subcode == ' ') {
682 current_opts->regex.append(preg);
683 } else if (subcode == 'D') {
684 current_opts->regexdir.append(preg);
685 } else if (subcode == 'F') {
686 current_opts->regexfile.append(preg);
692 current_opts = start_options(ff);
693 current_opts->base.append(bstrdup(item));
694 state = state_options;
697 current_opts = start_options(ff);
698 current_opts->fstype.append(bstrdup(item));
699 state = state_options;
702 current_opts = start_options(ff);
703 state = state_options;
704 if (subcode == ' ') {
705 current_opts->wild.append(bstrdup(item));
706 } else if (subcode == 'D') {
707 current_opts->wilddir.append(bstrdup(item));
708 } else if (subcode == 'F') {
709 current_opts->wildfile.append(bstrdup(item));
715 current_opts = start_options(ff);
716 set_options(current_opts, item);
717 state = state_options;
720 current_opts = start_options(ff);
721 current_opts->reader = bstrdup(item);
722 state = state_options;
725 current_opts = start_options(ff);
726 current_opts->writer = bstrdup(item);
727 state = state_options;
730 Jmsg(jcr, M_FATAL, 0, "Invalid FileSet command: %s\n", item);
734 ff->fileset->state = state;
737 static bool term_fileset(JCR *jcr)
739 FF_PKT *ff = (FF_PKT *)jcr->ff;
740 findFILESET *fileset = ff->fileset;
743 for (i=0; i<fileset->include_list.size(); i++) {
744 findINCEXE *incexe = (findINCEXE *)fileset->include_list.get(i);
746 for (j=0; j<incexe->opts_list.size(); j++) {
747 findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
748 for (k=0; k<fo->regex.size(); k++) {
749 Dmsg1(400, "R %s\n", (char *)fo->regex.get(k));
751 for (k=0; k<fo->regexdir.size(); k++) {
752 Dmsg1(400, "RD %s\n", (char *)fo->regexdir.get(k));
754 for (k=0; k<fo->regexfile.size(); k++) {
755 Dmsg1(400, "RF %s\n", (char *)fo->regexfile.get(k));
757 for (k=0; k<fo->wild.size(); k++) {
758 Dmsg1(400, "W %s\n", (char *)fo->wild.get(k));
760 for (k=0; k<fo->wilddir.size(); k++) {
761 Dmsg1(400, "WD %s\n", (char *)fo->wilddir.get(k));
763 for (k=0; k<fo->wildfile.size(); k++) {
764 Dmsg1(400, "WF %s\n", (char *)fo->wildfile.get(k));
766 for (k=0; k<fo->base.size(); k++) {
767 Dmsg1(400, "B %s\n", (char *)fo->base.get(k));
769 for (k=0; k<fo->fstype.size(); k++) {
770 Dmsg1(400, "X %s\n", (char *)fo->fstype.get(k));
773 Dmsg1(400, "D %s\n", fo->reader);
776 Dmsg1(400, "T %s\n", fo->writer);
779 for (j=0; j<incexe->name_list.size(); j++) {
780 Dmsg1(400, "F %s\n", (char *)incexe->name_list.get(j));
783 for (i=0; i<fileset->exclude_list.size(); i++) {
784 findINCEXE *incexe = (findINCEXE *)fileset->exclude_list.get(i);
786 for (j=0; j<incexe->opts_list.size(); j++) {
787 findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
788 for (k=0; k<fo->regex.size(); k++) {
789 Dmsg1(400, "R %s\n", (char *)fo->regex.get(k));
791 for (k=0; k<fo->regexdir.size(); k++) {
792 Dmsg1(400, "RD %s\n", (char *)fo->regexdir.get(k));
794 for (k=0; k<fo->regexfile.size(); k++) {
795 Dmsg1(400, "RF %s\n", (char *)fo->regexfile.get(k));
797 for (k=0; k<fo->wild.size(); k++) {
798 Dmsg1(400, "W %s\n", (char *)fo->wild.get(k));
800 for (k=0; k<fo->wilddir.size(); k++) {
801 Dmsg1(400, "WD %s\n", (char *)fo->wilddir.get(k));
803 for (k=0; k<fo->wildfile.size(); k++) {
804 Dmsg1(400, "WF %s\n", (char *)fo->wildfile.get(k));
806 for (k=0; k<fo->base.size(); k++) {
807 Dmsg1(400, "B %s\n", (char *)fo->base.get(k));
809 for (k=0; k<fo->fstype.size(); k++) {
810 Dmsg1(400, "X %s\n", (char *)fo->fstype.get(k));
813 for (j=0; j<incexe->name_list.size(); j++) {
814 Dmsg1(400, "F %s\n", (char *)incexe->name_list.get(j));
817 return ff->fileset->state != state_error;
822 * As an optimization, we should do this during
823 * "compile" time in filed/job.c, and keep only a bit mask
824 * and the Verify options.
826 static void set_options(findFOPTS *fo, const char *opts)
831 for (p=opts; *p; p++) {
833 case 'a': /* alway replace */
834 case '0': /* no option */
837 fo->flags |= FO_EXCLUDE;
840 fo->flags |= FO_MULTIFS;
842 case 'h': /* no recursion */
843 fo->flags |= FO_NO_RECURSION;
845 case 'H': /* no hard link handling */
846 fo->flags |= FO_NO_HARDLINK;
849 fo->flags |= FO_IGNORECASE;
855 fo->flags |= FO_NOREPLACE;
857 case 'p': /* use portable data format */
858 fo->flags |= FO_PORTABLE;
860 case 'R': /* Resource forks and Finder Info */
861 fo->flags |= FO_HFSPLUS;
862 case 'r': /* read fifo */
863 fo->flags |= FO_READFIFO;
866 fo->flags |= FO_SHA1;
869 fo->flags |= FO_SPARSE;
872 fo->flags |= FO_MTIMEONLY;
875 fo->flags |= FO_KEEPATIME;
880 case 'V': /* verify options */
881 /* Copy Verify Options */
882 for (j=0; *p && *p != ':'; p++) {
883 fo->VerifyOpts[j] = *p;
884 if (j < (int)sizeof(fo->VerifyOpts) - 1) {
888 fo->VerifyOpts[j] = 0;
891 fo->flags |= FO_IF_NEWER;
893 case 'Z': /* gzip compression */
894 fo->flags |= FO_GZIP;
895 fo->GZIP_level = *++p - '0';
896 Dmsg1(200, "Compression level=%d\n", fo->GZIP_level);
899 Emsg1(M_ERROR, 0, "Unknown include/exclude option: %c\n", *p);
907 * Director is passing his Fileset
909 static int fileset_cmd(JCR *jcr)
911 BSOCK *dir = jcr->dir_bsock;
913 if (!init_fileset(jcr)) {
916 while (bnet_recv(dir) >= 0) {
917 strip_trailing_junk(dir->msg);
918 Dmsg1(400, "Fileset: %s\n", dir->msg);
919 add_fileset(jcr, dir->msg);
921 if (!term_fileset(jcr)) {
924 return bnet_fsend(dir, OKinc);
929 * The Director sends us the bootstrap file, which
930 * we will in turn pass to the SD.
932 static int bootstrap_cmd(JCR *jcr)
934 BSOCK *dir = jcr->dir_bsock;
935 POOLMEM *fname = get_pool_memory(PM_FNAME);
938 if (jcr->RestoreBootstrap) {
939 unlink(jcr->RestoreBootstrap);
940 free_pool_memory(jcr->RestoreBootstrap);
942 Mmsg(fname, "%s/%s.%s.bootstrap", me->working_directory, me->hdr.name,
944 Dmsg1(400, "bootstrap=%s\n", fname);
945 jcr->RestoreBootstrap = fname;
946 bs = fopen(fname, "a+"); /* create file */
950 * Suck up what he is sending to us so that he will then
951 * read our error message.
953 while (bnet_recv(dir) >= 0)
956 Jmsg(jcr, M_FATAL, 0, _("Could not create bootstrap file %s: ERR=%s\n"),
957 jcr->RestoreBootstrap, be.strerror());
958 free_pool_memory(jcr->RestoreBootstrap);
959 jcr->RestoreBootstrap = NULL;
960 set_jcr_job_status(jcr, JS_ErrorTerminated);
964 while (bnet_recv(dir) >= 0) {
965 Dmsg1(200, "filed<dird: bootstrap file %s\n", dir->msg);
970 return bnet_fsend(dir, OKbootstrap);
975 * Get backup level from Director
978 static int level_cmd(JCR *jcr)
980 BSOCK *dir = jcr->dir_bsock;
981 POOLMEM *level, *buf = NULL;
984 level = get_memory(dir->msglen+1);
985 Dmsg1(110, "level_cmd: %s", dir->msg);
986 if (sscanf(dir->msg, "level = %s ", level) != 1) {
989 /* Base backup requested? */
990 if (strcmp(level, "base") == 0) {
991 jcr->JobLevel = L_BASE;
992 /* Full backup requested? */
993 } else if (strcmp(level, "full") == 0) {
994 jcr->JobLevel = L_FULL;
995 } else if (strcmp(level, "differential") == 0) {
996 jcr->JobLevel = L_DIFFERENTIAL;
999 } else if (strcmp(level, "incremental") == 0) {
1000 jcr->JobLevel = L_INCREMENTAL;
1004 * We get his UTC since time, then sync the clocks and correct it
1005 * to agree with our clock.
1007 } else if (strcmp(level, "since_utime") == 0) {
1008 buf = get_memory(dir->msglen+1);
1009 utime_t since_time, adj;
1010 btime_t his_time, bt_start, rt=0, bt_adj=0;
1011 if (jcr->JobLevel == L_NONE) {
1012 jcr->JobLevel = L_SINCE; /* if no other job level set, do it now */
1014 if (sscanf(dir->msg, "level = since_utime %s mtime_only=%d",
1015 buf, &mtime_only) != 2) {
1018 since_time = str_to_uint64(buf); /* this is the since time */
1019 char ed1[50], ed2[50];
1021 * Sync clocks by polling him for the time. We take
1022 * 10 samples of his time throwing out the first two.
1024 for (int i=0; i<10; i++) {
1025 bt_start = get_current_btime();
1026 bnet_sig(dir, BNET_BTIME); /* poll for time */
1027 if (bnet_recv(dir) <= 0) { /* get response */
1030 if (sscanf(dir->msg, "btime %s", buf) != 1) {
1033 if (i < 2) { /* toss first two results */
1036 his_time = str_to_uint64(buf);
1037 rt = get_current_btime() - bt_start; /* compute round trip time */
1038 bt_adj -= his_time - bt_start - rt/2;
1039 Dmsg2(200, "rt=%s adj=%s\n", edit_uint64(rt, ed1), edit_uint64(bt_adj, ed2));
1042 bt_adj = bt_adj / 8; /* compute average time */
1043 Dmsg2(100, "rt=%s adj=%s\n", edit_uint64(rt, ed1), edit_uint64(bt_adj, ed2));
1044 adj = btime_to_utime(bt_adj);
1045 since_time += adj; /* adjust for clock difference */
1047 Jmsg(jcr, M_INFO, 0, _("DIR and FD clocks differ by %d seconds, FD automatically adjusting.\n"), adj);
1049 bnet_sig(dir, BNET_EOD);
1051 Dmsg2(100, "adj = %d since_time=%d\n", (int)adj, (int)since_time);
1052 jcr->incremental = 1; /* set incremental or decremental backup */
1053 jcr->mtime = (time_t)since_time; /* set since time */
1055 Jmsg1(jcr, M_FATAL, 0, "Unknown backup level: %s\n", level);
1063 return bnet_fsend(dir, OKlevel);
1066 pm_strcpy(jcr->errmsg, dir->msg);
1067 Jmsg1(jcr, M_FATAL, 0, _("Bad level command: %s\n"), jcr->errmsg);
1076 * Get session parameters from Director -- this is for a Restore command
1078 static int session_cmd(JCR *jcr)
1080 BSOCK *dir = jcr->dir_bsock;
1082 Dmsg1(100, "SessionCmd: %s", dir->msg);
1083 if (sscanf(dir->msg, sessioncmd, jcr->VolumeName,
1084 &jcr->VolSessionId, &jcr->VolSessionTime,
1085 &jcr->StartFile, &jcr->EndFile,
1086 &jcr->StartBlock, &jcr->EndBlock) != 7) {
1087 pm_strcpy(jcr->errmsg, dir->msg);
1088 Jmsg(jcr, M_FATAL, 0, "Bad session command: %s", jcr->errmsg);
1092 return bnet_fsend(dir, OKsession);
1096 * Get address of storage daemon from Director
1099 static int storage_cmd(JCR *jcr)
1101 int stored_port; /* storage daemon port */
1102 int enable_ssl; /* enable ssl to sd */
1103 BSOCK *dir = jcr->dir_bsock;
1104 BSOCK *sd; /* storage daemon bsock */
1106 Dmsg1(100, "StorageCmd: %s", dir->msg);
1107 if (sscanf(dir->msg, storaddr, &jcr->stored_addr, &stored_port, &enable_ssl) != 3) {
1108 pm_strcpy(jcr->errmsg, dir->msg);
1109 Jmsg(jcr, M_FATAL, 0, _("Bad storage command: %s"), jcr->errmsg);
1112 Dmsg3(110, "Open storage: %s:%d ssl=%d\n", jcr->stored_addr, stored_port, enable_ssl);
1113 /* Open command communications with Storage daemon */
1114 /* Try to connect for 1 hour at 10 second intervals */
1115 sd = bnet_connect(jcr, 10, (int)me->SDConnectTimeout, _("Storage daemon"),
1116 jcr->stored_addr, NULL, stored_port, 1);
1118 Jmsg(jcr, M_FATAL, 0, _("Failed to connect to Storage daemon: %s:%d\n"),
1119 jcr->stored_addr, stored_port);
1120 Dmsg2(100, "Failed to connect to Storage daemon: %s:%d\n",
1121 jcr->stored_addr, stored_port);
1124 Dmsg0(110, "Connection OK to SD.\n");
1126 jcr->store_bsock = sd;
1128 bnet_fsend(sd, "Hello Start Job %s\n", jcr->Job);
1129 if (!authenticate_storagedaemon(jcr)) {
1130 Jmsg(jcr, M_FATAL, 0, _("Failed to authenticate Storage daemon.\n"));
1133 Dmsg0(110, "Authenticated with SD.\n");
1135 /* Send OK to Director */
1136 return bnet_fsend(dir, OKstore);
1141 * Do a backup. For now, we handle only Full and Incremental.
1143 static int backup_cmd(JCR *jcr)
1145 BSOCK *dir = jcr->dir_bsock;
1146 BSOCK *sd = jcr->store_bsock;
1149 char ed1[50], ed2[50];
1151 set_jcr_job_status(jcr, JS_Blocked);
1152 jcr->JobType = JT_BACKUP;
1153 Dmsg1(100, "begin backup ff=%p\n", (FF_PKT *)jcr->ff);
1156 Jmsg(jcr, M_FATAL, 0, _("Cannot contact Storage daemon\n"));
1160 bnet_fsend(dir, OKbackup);
1161 Dmsg1(110, "bfiled>dird: %s", dir->msg);
1164 * Send Append Open Session to Storage daemon
1166 bnet_fsend(sd, append_open);
1167 Dmsg1(110, ">stored: %s", sd->msg);
1169 * Expect to receive back the Ticket number
1171 if (bget_msg(sd) >= 0) {
1172 Dmsg1(110, "<stored: %s", sd->msg);
1173 if (sscanf(sd->msg, OK_open, &jcr->Ticket) != 1) {
1174 Jmsg(jcr, M_FATAL, 0, _("Bad response to append open: %s\n"), sd->msg);
1177 Dmsg1(110, "Got Ticket=%d\n", jcr->Ticket);
1179 Jmsg(jcr, M_FATAL, 0, _("Bad response from stored to open command\n"));
1184 * Send Append data command to Storage daemon
1186 bnet_fsend(sd, append_data, jcr->Ticket);
1187 Dmsg1(110, ">stored: %s", sd->msg);
1190 * Expect to get OK data
1192 Dmsg1(110, "<stored: %s", sd->msg);
1193 if (!response(jcr, sd, OK_data, "Append Data")) {
1197 generate_daemon_event(jcr, "JobStart");
1200 * Send Files to Storage daemon
1202 Dmsg1(110, "begin blast ff=%p\n", (FF_PKT *)jcr->ff);
1203 if (!blast_data_to_storage_daemon(jcr, NULL)) {
1204 set_jcr_job_status(jcr, JS_ErrorTerminated);
1205 bnet_suppress_error_messages(sd, 1);
1206 bget_msg(sd); /* Read final response from append_data */
1207 Dmsg0(110, "Error in blast_data.\n");
1209 set_jcr_job_status(jcr, JS_Terminated);
1210 if (jcr->JobStatus != JS_Terminated) {
1211 bnet_suppress_error_messages(sd, 1);
1212 goto cleanup; /* bail out now */
1215 * Expect to get response to append_data from Storage daemon
1217 if (!response(jcr, sd, OK_append, "Append Data")) {
1218 set_jcr_job_status(jcr, JS_ErrorTerminated);
1223 * Send Append End Data to Storage daemon
1225 bnet_fsend(sd, append_end, jcr->Ticket);
1227 if (!response(jcr, sd, OK_end, "Append End")) {
1228 set_jcr_job_status(jcr, JS_ErrorTerminated);
1233 * Send Append Close to Storage daemon
1235 bnet_fsend(sd, append_close, jcr->Ticket);
1236 while (bget_msg(sd) >= 0) { /* stop on signal or error */
1237 if (sscanf(sd->msg, OK_close, &SDJobStatus) == 1) {
1239 Dmsg2(200, "SDJobStatus = %d %c\n", SDJobStatus, (char)SDJobStatus);
1243 Jmsg(jcr, M_FATAL, 0, _("Append Close with SD failed.\n"));
1246 if (SDJobStatus != JS_Terminated) {
1247 Jmsg(jcr, M_FATAL, 0, _("Bad status %d returned from Storage Daemon.\n"),
1253 bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles,
1254 edit_uint64(jcr->ReadBytes, ed1),
1255 edit_uint64(jcr->JobBytes, ed2), jcr->Errors);
1256 Dmsg1(110, "End FD msg: %s\n", dir->msg);
1258 return 0; /* return and stop command loop */
1262 * Do a Verify for Director
1265 static int verify_cmd(JCR *jcr)
1267 BSOCK *dir = jcr->dir_bsock;
1268 BSOCK *sd = jcr->store_bsock;
1269 char level[100], ed1[50], ed2[50];
1271 jcr->JobType = JT_VERIFY;
1272 if (sscanf(dir->msg, verifycmd, level) != 1) {
1273 bnet_fsend(dir, "2994 Bad verify command: %s\n", dir->msg);
1277 if (strcasecmp(level, "init") == 0) {
1278 jcr->JobLevel = L_VERIFY_INIT;
1279 } else if (strcasecmp(level, "catalog") == 0){
1280 jcr->JobLevel = L_VERIFY_CATALOG;
1281 } else if (strcasecmp(level, "volume") == 0){
1282 jcr->JobLevel = L_VERIFY_VOLUME_TO_CATALOG;
1283 } else if (strcasecmp(level, "data") == 0){
1284 jcr->JobLevel = L_VERIFY_DATA;
1285 } else if (strcasecmp(level, "disk_to_catalog") == 0) {
1286 jcr->JobLevel = L_VERIFY_DISK_TO_CATALOG;
1288 bnet_fsend(dir, "2994 Bad verify level: %s\n", dir->msg);
1292 bnet_fsend(dir, OKverify);
1294 generate_daemon_event(jcr, "JobStart");
1296 Dmsg1(110, "bfiled>dird: %s", dir->msg);
1298 switch (jcr->JobLevel) {
1300 case L_VERIFY_CATALOG:
1303 case L_VERIFY_VOLUME_TO_CATALOG:
1304 if (!open_sd_read_session(jcr)) {
1307 start_dir_heartbeat(jcr);
1308 do_verify_volume(jcr);
1309 stop_dir_heartbeat(jcr);
1311 * Send Close session command to Storage daemon
1313 bnet_fsend(sd, read_close, jcr->Ticket);
1314 Dmsg1(130, "bfiled>stored: %s", sd->msg);
1316 /* ****FIXME**** check response */
1317 bget_msg(sd); /* get OK */
1319 /* Inform Storage daemon that we are done */
1320 bnet_sig(sd, BNET_TERMINATE);
1323 case L_VERIFY_DISK_TO_CATALOG:
1327 bnet_fsend(dir, "2994 Bad verify level: %s\n", dir->msg);
1331 bnet_sig(dir, BNET_EOD);
1333 /* Send termination status back to Dir */
1334 bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles,
1335 edit_uint64(jcr->ReadBytes, ed1),
1336 edit_uint64(jcr->JobBytes, ed2), jcr->Errors);
1338 /* Inform Director that we are done */
1339 bnet_sig(dir, BNET_TERMINATE);
1340 return 0; /* return and terminate command loop */
1344 * Do a Restore for Director
1347 static int restore_cmd(JCR *jcr)
1349 BSOCK *dir = jcr->dir_bsock;
1350 BSOCK *sd = jcr->store_bsock;
1354 char ed1[50], ed2[50];
1357 * Scan WHERE (base directory for restore) from command
1359 Dmsg0(150, "restore command\n");
1360 /* Pickup where string */
1361 where = get_memory(dir->msglen+1);
1364 if (sscanf(dir->msg, restorecmd, &replace, &prefix_links, where) != 3) {
1365 if (sscanf(dir->msg, restorecmd1, &replace, &prefix_links) != 2) {
1366 pm_strcpy(jcr->errmsg, dir->msg);
1367 Jmsg(jcr, M_FATAL, 0, _("Bad replace command. CMD=%s\n"), jcr->errmsg);
1372 /* Turn / into nothing */
1373 if (where[0] == '/' && where[1] == 0) {
1377 Dmsg2(150, "Got replace %c, where=%s\n", replace, where);
1378 unbash_spaces(where);
1379 jcr->where = bstrdup(where);
1380 free_pool_memory(where);
1381 jcr->replace = replace;
1382 jcr->prefix_links = prefix_links;
1384 bnet_fsend(dir, OKrestore);
1385 Dmsg1(110, "bfiled>dird: %s", dir->msg);
1387 jcr->JobType = JT_RESTORE;
1389 set_jcr_job_status(jcr, JS_Blocked);
1391 if (!open_sd_read_session(jcr)) {
1392 set_jcr_job_status(jcr, JS_ErrorTerminated);
1396 set_jcr_job_status(jcr, JS_Running);
1399 * Do restore of files and data
1401 start_dir_heartbeat(jcr);
1402 generate_daemon_event(jcr, "JobStart");
1404 stop_dir_heartbeat(jcr);
1406 set_jcr_job_status(jcr, JS_Terminated);
1407 if (jcr->JobStatus != JS_Terminated) {
1408 bnet_suppress_error_messages(sd, 1);
1412 * Send Close session command to Storage daemon
1414 bnet_fsend(sd, read_close, jcr->Ticket);
1415 Dmsg1(130, "bfiled>stored: %s", sd->msg);
1417 bget_msg(sd); /* get OK */
1419 /* Inform Storage daemon that we are done */
1420 bnet_sig(sd, BNET_TERMINATE);
1425 set_jcr_job_status(jcr, JS_ErrorTerminated);
1427 /* Send termination status back to Dir */
1428 bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles,
1429 edit_uint64(jcr->ReadBytes, ed1),
1430 edit_uint64(jcr->JobBytes, ed2), jcr->Errors);
1432 /* Inform Director that we are done */
1433 bnet_sig(dir, BNET_TERMINATE);
1435 Dmsg0(130, "Done in job.c\n");
1436 return 0; /* return and terminate command loop */
1439 static int open_sd_read_session(JCR *jcr)
1441 BSOCK *sd = jcr->store_bsock;
1444 Jmsg(jcr, M_FATAL, 0, _("Improper calling sequence.\n"));
1447 Dmsg4(120, "VolSessId=%ld VolsessT=%ld SF=%ld EF=%ld\n",
1448 jcr->VolSessionId, jcr->VolSessionTime, jcr->StartFile, jcr->EndFile);
1449 Dmsg2(120, "JobId=%d vol=%s\n", jcr->JobId, "DummyVolume");
1451 * Open Read Session with Storage daemon
1453 bnet_fsend(sd, read_open, jcr->VolumeName,
1454 jcr->VolSessionId, jcr->VolSessionTime, jcr->StartFile, jcr->EndFile,
1455 jcr->StartBlock, jcr->EndBlock);
1456 Dmsg1(110, ">stored: %s", sd->msg);
1461 if (bget_msg(sd) >= 0) {
1462 Dmsg1(110, "bfiled<stored: %s", sd->msg);
1463 if (sscanf(sd->msg, OK_open, &jcr->Ticket) != 1) {
1464 Jmsg(jcr, M_FATAL, 0, _("Bad response to SD read open: %s\n"), sd->msg);
1467 Dmsg1(110, "bfiled: got Ticket=%d\n", jcr->Ticket);
1469 Jmsg(jcr, M_FATAL, 0, _("Bad response from stored to read open command\n"));
1473 if (!send_bootstrap_file(jcr)) {
1478 * Start read of data with Storage daemon
1480 bnet_fsend(sd, read_data, jcr->Ticket);
1481 Dmsg1(110, ">stored: %s", sd->msg);
1486 if (!response(jcr, sd, OK_data, "Read Data")) {
1493 * Destroy the Job Control Record and associated
1494 * resources (sockets).
1496 static void filed_free_jcr(JCR *jcr)
1498 if (jcr->store_bsock) {
1499 bnet_close(jcr->store_bsock);
1501 if (jcr->RestoreBootstrap) {
1502 unlink(jcr->RestoreBootstrap);
1503 free_pool_memory(jcr->RestoreBootstrap);
1504 jcr->RestoreBootstrap = NULL;
1506 if (jcr->last_fname) {
1507 free_pool_memory(jcr->last_fname);
1509 if (jcr->RunAfterJob) {
1510 free_pool_memory(jcr->RunAfterJob);
1518 * Get response from Storage daemon to a command we
1519 * sent. Check that the response is OK.
1521 * Returns: 0 on failure
1524 int response(JCR *jcr, BSOCK *sd, char *resp, const char *cmd)
1529 if (bget_msg(sd) > 0) {
1530 Dmsg0(110, sd->msg);
1531 if (strcmp(sd->msg, resp) == 0) {
1535 if (job_canceled(jcr)) {
1536 return 0; /* if canceled avoid useless error messages */
1538 if (is_bnet_error(sd)) {
1539 Jmsg2(jcr, M_FATAL, 0, _("Comm error with SD. bad response to %s. ERR=%s\n"),
1540 cmd, bnet_strerror(sd));
1542 Jmsg3(jcr, M_FATAL, 0, _("Bad response to %s command. Wanted %s, got %s\n"),
1543 cmd, resp, sd->msg);
1548 static int send_bootstrap_file(JCR *jcr)
1552 BSOCK *sd = jcr->store_bsock;
1553 const char *bootstrap = "bootstrap\n";
1556 Dmsg1(400, "send_bootstrap_file: %s\n", jcr->RestoreBootstrap);
1557 if (!jcr->RestoreBootstrap) {
1560 bs = fopen(jcr->RestoreBootstrap, "r");
1563 Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"),
1564 jcr->RestoreBootstrap, be.strerror());
1565 set_jcr_job_status(jcr, JS_ErrorTerminated);
1568 sd->msglen = pm_strcpy(sd->msg, bootstrap);
1570 while (fgets(buf, sizeof(buf), bs)) {
1571 sd->msglen = Mmsg(sd->msg, "%s", buf);
1574 bnet_sig(sd, BNET_EOD);
1576 if (!response(jcr, sd, OKSDbootstrap, "Bootstrap")) {
1577 set_jcr_job_status(jcr, JS_ErrorTerminated);
1583 if (jcr->RestoreBootstrap) {
1584 unlink(jcr->RestoreBootstrap);
1585 free_pool_memory(jcr->RestoreBootstrap);
1586 jcr->RestoreBootstrap = NULL;