]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Ensure that the DIR will reject catalog update from the FD
authorAlain Spineux <alain@baculasystems.com>
Tue, 3 Aug 2021 11:25:56 +0000 (13:25 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:03 +0000 (09:03 +0100)
- bget_dirmsg() allows or denies some operation reagarding the role

14 files changed:
bacula/src/dird/backup.c
bacula/src/dird/fd_cmds.c
bacula/src/dird/getmsg.c
bacula/src/dird/mac.c
bacula/src/dird/msgchan.c
bacula/src/dird/protos.h
bacula/src/dird/restore.c
bacula/src/dird/snapshot.c
bacula/src/dird/ua_cmds.c
bacula/src/dird/ua_label.c
bacula/src/dird/ua_purge.c
bacula/src/dird/verify.c
bacula/src/lib/bsock.h
bacula/src/lib/jcr.c

index e5b5a2c81e9d0c3ba222c94977045043733b7e1b..664c62c86c142ce230bd039330db2c0d612cd8e4 100644 (file)
@@ -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,
index 8e3f7e679f4d0d8da5037a2c89524144baf50cf0..6bc7df5ee568f7b8a6ca511d0be234cbe2a52615 100644 (file)
@@ -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, "<filed: %s", fd->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;
index d12b440674e34bb237b62a22871181a9a0e7f4dd..69f06b15cb7284b160955a831335d5fe546125bd 100644 (file)
@@ -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;
       }
index fea49f6471d71cf6d3b8846287f0f4dac99080f3..7754299d137634a361d9fa3968d141544315d871 100644 (file)
@@ -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",
index 275081098ea132f02bb4d66a6544be4b044c6714..17a47db6f83570a6c93aeb79798297b65d258ea1 100644 (file)
@@ -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, "<stored: %s", sd->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, "<stored: %s", sd->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, "<stored: %s", sd->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, "<stored: %s", sd->msg);
       if (sscanf(sd->msg, Job_start, Job) == 1) {
          continue;
index b03a83e77f616e073b20db1ada89b0ecbdc1bdf5..a2e6a3af5ce66c97347fcae52e7d0434b597d4f6 100644 (file)
@@ -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);
 
index cddf5b427726d7ce141efdbd9fc1ab7be5add13c..6c8410b1029b94a5539f97e3dad4e150220b68ac 100644 (file)
@@ -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);
index b9403edf8832e2c9605a8bc5e3ac1533173c28cd..e578450cbd26bd21ff969b4bf9a557b482101f0f 100644 (file)
@@ -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;
       }
index 8f2a7aca2330e74cbc0a2a72feaa517ba6fd8c51..2731def1622123b77bd2b2858fc35056cec041ad 100644 (file)
@@ -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;
index b89ac403b880665b80b8a64e7ab9b9415b310e30..695b86bade73c8f794c3158ecfc849912108ee70 100644 (file)
@@ -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) {
index 0a529813c776f53dd6e1228717e618077bf19c79..d7f12265784be91dd6b52cee4cb41d85bc492471 100644 (file)
@@ -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) {
index 780426320e263e9338d2b4c91c8d6d122b2ad23a..4bd41fe5c82a79642786faab87c402eb8fbd8fc1 100644 (file)
@@ -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 */
index 5020c96b7ef3a450c53499831b43ffc61fa094a8..1db9cc66d0082d605f1d0c8833a5ed0e331462b8 100644 (file)
 
 #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 */
index 3856d94624bcb2536a5dd7e0175c078a33478937..08de0940c34c9e476cb3a790a6db7b1535c32bcf 100644 (file)
@@ -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)
 {