From: Alain Spineux Date: Tue, 3 Aug 2021 11:25:56 +0000 (+0200) Subject: Ensure that the DIR will reject catalog update from the FD X-Git-Tag: Release-11.3.2~393 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6b16e779ad6ead011518a66799e7a0712512f2a;p=thirdparty%2Fbacula.git Ensure that the DIR will reject catalog update from the FD - bget_dirmsg() allows or denies some operation reagarding the role --- diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index e5b5a2c81..664c62c86 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -365,7 +365,7 @@ bool send_store_addr_to_fd(JCR *jcr, STORE *store, * Send Storage address to the FD */ jcr->file_bsock->fsend(storaddr, store_address, store_port, tls_need); - if (!response(jcr, jcr->file_bsock, OKstore, "Storage", DISPLAY_ERROR)) { + if (!response(jcr, jcr->file_bsock, BSOCK_TYPE_FD, OKstore, "Storage", DISPLAY_ERROR)) { return false; } return true; @@ -390,7 +390,7 @@ bool send_client_addr_to_sd(JCR *jcr) * Send Client address to the SD */ sd->fsend(clientaddr, get_client_address(jcr, jcr->client, buf.addr()), jcr->client->FDport, tls_need); - if (!response(jcr, sd, OKclient, "Client", DISPLAY_ERROR)) { + if (!response(jcr, sd, BSOCK_TYPE_SD, OKclient, "Client", DISPLAY_ERROR)) { return false; } return true; @@ -734,7 +734,7 @@ bool do_backup(JCR *jcr) /* Send backup command */ fd->fsend(backupcmd, jcr->JobFiles); Dmsg1(100, ">filed: %s", fd->msg); - if (!response(jcr, fd, OKbackup, "backup", DISPLAY_ERROR)) { + if (!response(jcr, fd, BSOCK_TYPE_FD, OKbackup, "backup", DISPLAY_ERROR)) { goto bail_out; } @@ -791,7 +791,7 @@ int wait_for_job_termination(JCR *jcr, int timeout) tid = start_bsock_timer(fd, timeout); /* TODO: New timeout directive??? */ } /* Wait for Client to terminate */ - while ((n = bget_dirmsg(fd)) >= 0) { + while ((n = bget_dirmsg(jcr, fd, BSOCK_TYPE_FD)) >= 0) { if (!fd_ok && (sscanf(fd->msg, newEndJob, &jcr->FDJobStatus, &JobFiles, &ReadBytes, &JobBytes, &JobErrors, &VSS, &Encrypt, diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index 8e3f7e679..6bc7df5ee 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -180,7 +180,7 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time, memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key)); } Dmsg1(100, ">filed: %s", fd->msg); - if (bget_dirmsg(fd) > 0) { + if (bget_dirmsg(jcr, fd, BSOCK_TYPE_FD) > 0) { Dmsg1(110, "msg); if (strncmp(fd->msg, OKjob, strlen(OKjob)) != 0) { Jmsg(jcr, M_FATAL, 0, _("File daemon \"%s\" rejected Job command: %s\n"), @@ -407,7 +407,7 @@ static void send_since_time(JCR *jcr) stime = str_to_utime(jcr->stime); fd->fsend(levelcmd, "", NT_("since_utime "), edit_uint64(stime, ed1), 0, NT_("prev_job="), jcr->PrevJob); - while (bget_dirmsg(fd) >= 0) { /* allow him to poll us to sync clocks */ + while (bget_dirmsg(jcr, fd, BSOCK_TYPE_FD) >= 0) { /* allow him to poll us to sync clocks */ Jmsg(jcr, M_INFO, 0, "%s\n", fd->msg); } } @@ -417,7 +417,7 @@ bool send_bwlimit(JCR *jcr, const char *Job) BSOCK *fd = jcr->file_bsock; if (jcr->FDVersion >= 4) { fd->fsend(bandwidthcmd, jcr->max_bandwidth, Job); - if (!response(jcr, fd, OKBandwidth, "Bandwidth", DISPLAY_ERROR)) { + if (!response(jcr, fd, BSOCK_TYPE_FD, OKBandwidth, "Bandwidth", DISPLAY_ERROR)) { jcr->max_bandwidth = 0; /* can't set bandwidth limit */ return false; } @@ -462,7 +462,7 @@ bool send_level_command(JCR *jcr) return 0; } Dmsg1(120, ">filed: %s", fd->msg); - if (!response(jcr, fd, OKlevel, "Level", DISPLAY_ERROR)) { + if (!response(jcr, fd, BSOCK_TYPE_FD, OKlevel, "Level", DISPLAY_ERROR)) { return false; } return true; @@ -613,7 +613,7 @@ static bool send_fileset(JCR *jcr) } fd->signal(BNET_EOD); /* end of data */ - if (!response(jcr, fd, OKinc, "Include", DISPLAY_ERROR)) { + if (!response(jcr, fd, BSOCK_TYPE_FD, OKinc, "Include", DISPLAY_ERROR)) { goto bail_out; } return true; @@ -730,7 +730,7 @@ bool send_ls_plugin_fileset(JCR *jcr, const char *plugin, const char *path) fd->fsend("N\n"); fd->signal(BNET_EOD); /* end of data */ - if (!response(jcr, fd, OKinc, "Include", DISPLAY_ERROR)) { + if (!response(jcr, fd, BSOCK_TYPE_FD, OKinc, "Include", DISPLAY_ERROR)) { return false; } return true; @@ -751,7 +751,7 @@ bool send_ls_fileset(JCR *jcr, const char *path) fd->fsend("N\n"); fd->signal(BNET_EOD); /* end of data */ - if (!response(jcr, fd, OKinc, "Include", DISPLAY_ERROR)) { + if (!response(jcr, fd, BSOCK_TYPE_FD, OKinc, "Include", DISPLAY_ERROR)) { return false; } return true; @@ -781,10 +781,10 @@ int send_runscript_with_old_proto(JCR *jcr, int when, POOLMEM *msg) Dmsg1(120, "bdird: sending old runcommand to fd '%s'\n",msg); if (when & SCRIPT_Before) { jcr->file_bsock->fsend(runbefore, msg); - ret = response(jcr, jcr->file_bsock, OKRunBefore, "ClientRunBeforeJob", DISPLAY_ERROR); + ret = response(jcr, jcr->file_bsock, BSOCK_TYPE_FD, OKRunBefore, "ClientRunBeforeJob", DISPLAY_ERROR); } else { jcr->file_bsock->fsend(runafter, msg); - ret = response(jcr, jcr->file_bsock, OKRunAfter, "ClientRunAfterJob", DISPLAY_ERROR); + ret = response(jcr, jcr->file_bsock, BSOCK_TYPE_FD, OKRunAfter, "ClientRunAfterJob", DISPLAY_ERROR); } return ret; } /* END OF TODO */ @@ -830,7 +830,7 @@ int send_runscripts_commands(JCR *jcr) cmd->when, msg); - result = response(jcr, fd, OKRunScript, "RunScript", DISPLAY_ERROR); + result = response(jcr, fd, BSOCK_TYPE_FD, OKRunScript, "RunScript", DISPLAY_ERROR); launch_before_cmd = true; } @@ -850,7 +850,7 @@ int send_runscripts_commands(JCR *jcr) /* Tell the FD to execute the ClientRunBeforeJob */ if (launch_before_cmd) { fd->fsend(runbeforenow); - if (!response(jcr, fd, OKRunBeforeNow, "RunBeforeNow", DISPLAY_ERROR)) { + if (!response(jcr, fd, BSOCK_TYPE_FD, OKRunBeforeNow, "RunBeforeNow", DISPLAY_ERROR)) { goto bail_out; } } @@ -1010,7 +1010,7 @@ static bool get_plugin_features(JCR *jcr, PluginFeatures **ret) */ fd->fsend("PluginFeatures\n"); - while (bget_dirmsg(fd) > 0) { + while (bget_dirmsg(jcr, fd, BSOCK_TYPE_FD) > 0) { buf.check_size(fd->msglen+1); if (sscanf(fd->msg, "2000 plugin=%127s features=%s", ed1, buf.c_str()) == 2) { /* We have buf=feature1,feature2,feature3 */ @@ -1094,7 +1094,7 @@ bool send_restore_objects(JCR *jcr) if (octx.count > 0) { fd = jcr->file_bsock; fd->fsend("restoreobject end\n"); - if (!response(jcr, fd, OKRestoreObject, "RestoreObject", DISPLAY_ERROR)) { + if (!response(jcr, fd, BSOCK_TYPE_FD, OKRestoreObject, "RestoreObject", DISPLAY_ERROR)) { Jmsg(jcr, M_FATAL, 0, _("RestoreObject failed.\n")); return false; } @@ -1131,7 +1131,7 @@ bool send_component_info(JCR *jcr) Dmsg1(050, "Send component_info to FD: %s\n", buf); } fd->signal(BNET_EOD); - if (!response(jcr, fd, OKComponentInfo, "ComponentInfo", DISPLAY_ERROR)) { + if (!response(jcr, fd, BSOCK_TYPE_FD, OKComponentInfo, "ComponentInfo", DISPLAY_ERROR)) { Jmsg(jcr, M_FATAL, 0, _("ComponentInfo failed.\n")); ok = false; } @@ -1164,7 +1164,7 @@ int get_attributes_and_put_in_catalog(JCR *jcr) Dmsg0(120, "bdird: waiting to receive file attributes\n"); /* Pickup file attributes and digest */ - while (!fd->errors && (n = bget_dirmsg(fd)) > 0) { + while (!fd->errors && (n = bget_dirmsg(jcr, fd, BSOCK_TYPE_FD)) > 0) { int32_t file_index; int stream, len; char *p, *fn; diff --git a/bacula/src/dird/getmsg.c b/bacula/src/dird/getmsg.c index d12b44067..69f06b15c 100644 --- a/bacula/src/dird/getmsg.c +++ b/bacula/src/dird/getmsg.c @@ -134,8 +134,11 @@ static bool is_msgid(char *msg) * *System* for the Job name, and hence no JCR is obtained. This * is a *rare* case where a jcr is not really needed. * + * role is the role of component at the other side of the BSOCK + * BSOCK_TYPE_FD for a file daemon (that cannot update the catalog) + * BSOCK_TYPE_SD for a storage daemon */ -int bget_dirmsg(BSOCK *bs) +int bget_dirmsg(JCR *jcr, BSOCK *bs, BSOCK_CLIENT_TYPE role) { int32_t n = BNET_TERMINATE; char Job[MAX_NAME_LENGTH]; @@ -143,7 +146,6 @@ int bget_dirmsg(BSOCK *bs) char MsgType[20]; int type; utime_t mtime; /* message time */ - JCR *jcr = bs->jcr(); char *msg; for ( ; !bs->is_stop() && !bs->is_timed_out(); ) { @@ -253,21 +255,25 @@ int bget_dirmsg(BSOCK *bs) dispatch_message(jcr, type, mtime, msg); continue; } + /* - * Here we expact a CatReq message - * CatReq JobId=nn Catalog-Request-Message + * Here we expect a catalog request message from the SD + * CatReq JobId=nn ..... + * UpdCat JobId=nn ...... + * BlastAttr JobId=nn .... + * */ - if (bs->msg[0] == 'C') { /* Catalog request */ + if (role==BSOCK_TYPE_SD && bs->msg[0] == 'C') { /* Catalog request */ Dmsg2(900, "Catalog req jcr=%p: %s", jcr, bs->msg); catalog_request(jcr, bs); continue; } - if (bs->msg[0] == 'U') { /* SD sending attributes */ + if (role==BSOCK_TYPE_SD && bs->msg[0] == 'U') { /* SD sending attributes */ Dmsg2(900, "Catalog upd jcr=%p: %s", jcr, bs->msg); catalog_update(jcr, bs); continue; } - if (bs->msg[0] == 'B') { /* SD sending file spool attributes */ + if (role==BSOCK_TYPE_SD && bs->msg[0] == 'B') { /* SD sending file spool attributes */ Dmsg2(100, "Blast attributes jcr=%p: %s", jcr, bs->msg); char filename[256]; if (sscanf(bs->msg, "BlastAttr JobId=%ld File=%255s", @@ -284,7 +290,7 @@ int bget_dirmsg(BSOCK *bs) continue; } /* Get Progress: files, bytes, bytes/sec */ - if (bs->msg[0] == 'P') { /* Progress report */ + if (role==BSOCK_TYPE_FD && bs->msg[0] == 'P') { /* Progress report */ uint32_t files, bps; uint64_t bytes; if ((sscanf(bs->msg, "Progress JobId=%ld files=%ld bytes=%lld bps=%ld\n", @@ -303,7 +309,7 @@ int bget_dirmsg(BSOCK *bs) } continue; } - if (bs->msg[0] == 'S') { /* Status change */ + if (role==BSOCK_TYPE_SD && bs->msg[0] == 'S') { /* Status change */ int JobStatus; if (sscanf(bs->msg, Job_status, &JobId, &JobStatus) == 2) { set_jcr_sd_job_status(jcr, JobStatus); /* current status */ @@ -314,7 +320,7 @@ int bget_dirmsg(BSOCK *bs) } #ifdef needed /* No JCR for Device Updates! */ - if (bs->msg[0] = 'D') { /* Device update */ + if (role==BSOCK_TYPE_SD && bs->msg[0] = 'D') { /* Device update */ DEVICE *dev; POOL_MEM dev_name, changer_name, media_type, volume_name; int dev_open, dev_append, dev_read, dev_labeled; @@ -394,14 +400,14 @@ static char *find_msg_start(char *msg) * Returns: false on failure * true on success */ -bool response(JCR *jcr, BSOCK *bs, char *resp, const char *cmd, e_prtmsg prtmsg) +bool response(JCR *jcr, BSOCK *bs, BSOCK_CLIENT_TYPE role, const char *resp, const char *cmd, e_prtmsg prtmsg) { int n; if (bs->is_error()) { return false; } - if ((n = bget_dirmsg(bs)) >= 0) { + if ((n = bget_dirmsg(jcr, bs, role)) >= 0) { if (strcmp(bs->msg, resp) == 0) { return true; } diff --git a/bacula/src/dird/mac.c b/bacula/src/dird/mac.c index fea49f647..7754299d1 100644 --- a/bacula/src/dird/mac.c +++ b/bacula/src/dird/mac.c @@ -340,7 +340,7 @@ static bool send_store_addr_to_sd(JCR *jcr, char *Job, char *sd_auth_key, Dmsg2(200, "=== Job=%s sd auth key=%s\n", Job, sd_auth_key); jcr->store_bsock->fsend(storaddr, store_address, store_port, tls_need, Job, sd_auth_key); - if (!response(jcr, jcr->store_bsock, OKstore, "Storage", DISPLAY_ERROR)) { + if (!response(jcr, jcr->store_bsock, BSOCK_TYPE_SD, OKstore, "Storage", DISPLAY_ERROR)) { Dmsg4(050, "Response fail for: JobId=%d storeaddr=%s:%d Job=%s\n", jcr->JobId, store_address, store_port, Job); Jmsg3(jcr, M_FATAL, 0, "Response failure: storeddr=%s:%d Job=%s\n", diff --git a/bacula/src/dird/msgchan.c b/bacula/src/dird/msgchan.c index 275081098..17a47db6f 100644 --- a/bacula/src/dird/msgchan.c +++ b/bacula/src/dird/msgchan.c @@ -179,7 +179,7 @@ bool update_device_res(JCR *jcr, DEVICE *dev) sd->fsend(query_device, device_name.c_str()); Dmsg1(100, ">stored: %s\n", sd->msg); /* The data is returned through Device_update */ - if (bget_dirmsg(sd) <= 0) { + if (bget_dirmsg(jcr, sd, BSOCK_TYPE_SD) <= 0) { return false; } return true; @@ -252,7 +252,7 @@ bool start_storage_daemon_job(JCR *jcr, alist *rstore, alist *wstore, bool wait, Dmsg1(100, ">stored: %s", sd->msg); Dmsg2(100, "=== rstore=%p wstore=%p\n", rstore, wstore); - if (bget_dirmsg(sd) > 0) { + if (bget_dirmsg(jcr, sd, BSOCK_TYPE_SD) > 0) { Dmsg1(100, "msg); if (sscanf(sd->msg, OKjob, &jcr->VolSessionId, &jcr->VolSessionTime, &sd_auth_key) != 3) { @@ -271,7 +271,7 @@ bool start_storage_daemon_job(JCR *jcr, alist *rstore, alist *wstore, bool wait, } if (send_bsr && (!send_bootstrap_file(jcr, sd) || - !response(jcr, sd, OKbootstrap, "Bootstrap", DISPLAY_ERROR))) { + !response(jcr, sd, BSOCK_TYPE_SD, OKbootstrap, "Bootstrap", DISPLAY_ERROR))) { return false; } @@ -321,7 +321,7 @@ bool start_storage_daemon_job(JCR *jcr, alist *rstore, alist *wstore, bool wait, sd->signal(BNET_EOD); /* end of Devices */ } sd->signal(BNET_EOD); /* end of Storages */ - if (bget_dirmsg(sd) > 0) { + if (bget_dirmsg(jcr, sd, BSOCK_TYPE_SD) > 0) { Dmsg1(100, "msg); ok = sscanf(sd->msg, OK_device, device_name.c_str()) == 1; } else { @@ -360,7 +360,7 @@ bool start_storage_daemon_job(JCR *jcr, alist *rstore, alist *wstore, bool wait, sd->signal(BNET_EOD); /* end of Devices */ } sd->signal(BNET_EOD); /* end of Storages */ - if (bget_dirmsg(sd) > 0) { + if (bget_dirmsg(jcr, sd, BSOCK_TYPE_SD) > 0) { Dmsg1(100, "msg); ok = sscanf(sd->msg, OK_device, device_name.c_str()) == 1; } else { @@ -455,7 +455,7 @@ extern "C" void *msg_thread(void *arg) */ Dmsg0(100, "Start msg_thread loop\n"); n = 0; - while (!job_canceled(jcr) && (n=bget_dirmsg(sd)) >= 0) { + while (!job_canceled(jcr) && (n=bget_dirmsg(jcr, sd, BSOCK_TYPE_SD)) >= 0) { Dmsg1(400, "msg); if (sscanf(sd->msg, Job_start, Job) == 1) { continue; diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index b03a83e77..a2e6a3af5 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -117,7 +117,7 @@ enum e_prtmsg { DISPLAY_ERROR, NO_DISPLAY }; -extern bool response(JCR *jcr, BSOCK *fd, char *resp, const char *cmd, e_prtmsg prtmsg); +extern bool response(JCR *jcr, BSOCK *fd, BSOCK_CLIENT_TYPE role, const char *resp, const char *cmd, e_prtmsg prtmsg); /* job.c */ extern bool allow_duplicate_job(JCR *jcr); @@ -170,7 +170,7 @@ extern bool connect_to_storage_daemon(JCR *jcr, int retry_interval, extern bool start_storage_daemon_job(JCR *jcr, alist *rstore, alist *wstore, bool wait, bool send_bsr=false); extern bool start_storage_daemon_message_thread(JCR *jcr); -extern int bget_dirmsg(BSOCK *bs); +extern int bget_dirmsg(JCR *jcr, BSOCK *bs, BSOCK_CLIENT_TYPE role); extern void wait_for_storage_daemon_termination(JCR *jcr); extern bool send_bootstrap_file(JCR *jcr, BSOCK *sd); diff --git a/bacula/src/dird/restore.c b/bacula/src/dird/restore.c index cddf5b427..6c8410b10 100644 --- a/bacula/src/dird/restore.c +++ b/bacula/src/dird/restore.c @@ -420,7 +420,7 @@ bool restore_bootstrap(JCR *jcr) * Send the bootstrap file -- what Volumes/files to restore */ if (!send_bootstrap_file(jcr, sd, info) || - !response(jcr, sd, OKbootstrap, "Bootstrap", DISPLAY_ERROR)) { + !response(jcr, sd, BSOCK_TYPE_SD, OKbootstrap, "Bootstrap", DISPLAY_ERROR)) { goto bail_out; } @@ -481,7 +481,7 @@ bool restore_bootstrap(JCR *jcr) fd->fsend(storaddr, store_address, store_port, tls_need, jcr->sd_auth_key); memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key)); Dmsg1(6, "dird>filed: %s\n", fd->msg); - if (!response(jcr, fd, OKstore, "Storage", DISPLAY_ERROR)) { + if (!response(jcr, fd, BSOCK_TYPE_FD, OKstore, "Storage", DISPLAY_ERROR)) { goto bail_out; } @@ -511,14 +511,14 @@ bool restore_bootstrap(JCR *jcr) } fd->fsend("%s", restore_cmd.c_str()); - if (!response(jcr, fd, OKrestore, "Restore", DISPLAY_ERROR)) { + if (!response(jcr, fd, BSOCK_TYPE_FD, OKrestore, "Restore", DISPLAY_ERROR)) { goto bail_out; } if (jcr->FDVersion < 2) { /* Old FD */ break; /* we do only one loop */ } else { - if (!response(jcr, fd, OKstoreend, "Store end", DISPLAY_ERROR)) { + if (!response(jcr, fd, BSOCK_TYPE_FD, OKstoreend, "Store end", DISPLAY_ERROR)) { goto bail_out; } wait_for_storage_daemon_termination(jcr); diff --git a/bacula/src/dird/snapshot.c b/bacula/src/dird/snapshot.c index b9403edf8..e578450cb 100644 --- a/bacula/src/dird/snapshot.c +++ b/bacula/src/dird/snapshot.c @@ -138,7 +138,7 @@ bool send_snapshot_retention(JCR *jcr, utime_t val) char ed1[50]; if (val > 0 && jcr->FDVersion >= 13) { fd->fsend(snapretentioncmd, edit_uint64(val, ed1)); - if (!response(jcr, fd, (char*)"2000 Snapshot retention\n", "set Snapshot Retention", DISPLAY_ERROR)) { + if (!response(jcr, fd, BSOCK_TYPE_FD, "2000 Snapshot retention\n", "set Snapshot Retention", DISPLAY_ERROR)) { jcr->snapshot_retention = 0; /* can't set snapshot retention */ return false; } diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 8f2a7aca2..2731def16 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -2574,7 +2574,7 @@ int cloud_volumes_cmd(UAContext *ua, const char *cmd, const char *mode) unbash_spaces(truncate_option); /* Check for valid response */ - while (bget_dirmsg(sd) >= 0) { + while (bget_dirmsg(ua->jcr, sd, BSOCK_TYPE_SD) >= 0) { if (strncmp(sd->msg, "3000 OK truncate cache", 22) == 0) { ua->send_msg("%s", sd->msg); ok = true; diff --git a/bacula/src/dird/ua_label.c b/bacula/src/dird/ua_label.c index b89ac403b..695b86bad 100644 --- a/bacula/src/dird/ua_label.c +++ b/bacula/src/dird/ua_label.c @@ -474,7 +474,7 @@ checkName: bash_spaces(dev_name); sd->fsend("mount %s drive=%d slot=%d", dev_name, drive, mr.Slot); unbash_spaces(dev_name); - while (bget_dirmsg(sd) >= 0) { + while (bget_dirmsg(ua->jcr, sd, BSOCK_TYPE_SD) >= 0) { ua->send_msg("%s", sd->msg); /* Here we can get * 3001 OK mount. Device=xxx or @@ -712,7 +712,7 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, dev_name, mr->VolumeName, pr->Name, mr->MediaType, mr->Slot, drive); } - while (bget_dirmsg(sd) >= 0) { + while (bget_dirmsg(ua->jcr, sd, BSOCK_TYPE_SD) >= 0) { ua->send_msg("%s", sd->msg); if (sscanf(sd->msg, "3000 OK label. VolBytes=%llu VolABytes=%lld VolType=%d ", &VolBytes, &VolABytes, &VolType) == 3) { diff --git a/bacula/src/dird/ua_purge.c b/bacula/src/dird/ua_purge.c index 0a529813c..d7f122657 100644 --- a/bacula/src/dird/ua_purge.c +++ b/bacula/src/dird/ua_purge.c @@ -651,7 +651,7 @@ static void truncate_volume(UAContext *ua, MEDIA_DBR *mr, /* Check for valid response. With cloud volumes, the upload of the part.1 can * generate a dir_update_volume_info() message that is handled by bget_dirmsg() */ - while (bget_dirmsg(sd) >= 0) { + while (bget_dirmsg(ua->jcr, sd, BSOCK_TYPE_SD) >= 0) { ua->send_msg("%s", sd->msg); if (sscanf(sd->msg, "3000 OK label. VolBytes=%llu VolABytes=%lld VolType=%d ", &VolBytes, &VolABytes, &VolType) == 3) { diff --git a/bacula/src/dird/verify.c b/bacula/src/dird/verify.c index 780426320..4bd41fe5c 100644 --- a/bacula/src/dird/verify.c +++ b/bacula/src/dird/verify.c @@ -267,7 +267,7 @@ bool do_verify(JCR *jcr) * Send the bootstrap file -- what Volumes/files to restore */ if (!send_bootstrap_file(jcr, sd) || - !response(jcr, sd, OKbootstrap, "Bootstrap", DISPLAY_ERROR)) { + !response(jcr, sd, BSOCK_TYPE_SD, OKbootstrap, "Bootstrap", DISPLAY_ERROR)) { goto bail_out; } if (!jcr->sd_calls_client) { @@ -373,7 +373,7 @@ bool do_verify(JCR *jcr) * Send verify command/level to File daemon */ fd->fsend(verifycmd, level); - if (!response(jcr, fd, OKverify, "Verify", DISPLAY_ERROR)) { + if (!response(jcr, fd, BSOCK_TYPE_FD, OKverify, "Verify", DISPLAY_ERROR)) { goto bail_out; } @@ -415,7 +415,7 @@ bool do_verify(JCR *jcr) case L_VERIFY_DATA: /* Nothing special to do */ - bget_dirmsg(fd); /* eat EOD */ + bget_dirmsg(jcr, fd, BSOCK_TYPE_FD); /* eat EOD */ break; default: Jmsg1(jcr, M_FATAL, 0, _("Unimplemented verify level %d\n"), jcr->getJobLevel()); @@ -623,7 +623,7 @@ void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) * Attributes * Link name ??? */ - while ((n=bget_dirmsg(fd)) >= 0 && !job_canceled(jcr)) { + while ((n=bget_dirmsg(jcr, fd, BSOCK_TYPE_FD)) >= 0 && !job_canceled(jcr)) { int32_t stream, full_stream; char *attr, *p, *fn; char Opts_Digest[MAXSTRING]; /* Verify Opts or MD5/SHA1 digest */ diff --git a/bacula/src/lib/bsock.h b/bacula/src/lib/bsock.h index 5020c96b7..1db9cc66d 100644 --- a/bacula/src/lib/bsock.h +++ b/bacula/src/lib/bsock.h @@ -44,6 +44,14 @@ #define BSOCK_TIMEOUT 3600 * 24 * 200; /* default 200 days */ +/* Type of bsock connection (to sd, to fd, to console, to dir...) */ +typedef enum { + BSOCK_TYPE_UNKN, + BSOCK_TYPE_FD, // Connected to FD + BSOCK_TYPE_SD, // Connected to DIR + BSOCK_TYPE_CONS // Connected to console +} BSOCK_CLIENT_TYPE; + class BSOCK: public BSOCKCORE { public: FILE *m_spool_fd; /* spooling file */ diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index 3856d9462..08de0940c 100644 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -80,7 +80,6 @@ pthread_once_t key_once = PTHREAD_ONCE_INIT; static char Job_status[] = "Status JobId=%ld JobStatus=%d\n"; - void lock_jobs() { P(job_start_mutex); @@ -893,6 +892,7 @@ static int get_status_priority(int JobStatus) /* * Send Job status to Director + * ATTN: Only the SD like components are expected to send there job status */ bool JCR::sendJobStatus() { @@ -904,6 +904,7 @@ bool JCR::sendJobStatus() /* * Set and send Job status to Director + * ATTN: Only the SD like components are expected to send there job status */ bool JCR::sendJobStatus(int aJobStatus) {