]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix org#2442 About the check of the Control Device during startup
authorEric Bollengier <eric@baculasystems.com>
Mon, 17 May 2021 07:42:08 +0000 (09:42 +0200)
committerEric Bollengier <eric@baculasystems.com>
Mon, 17 May 2021 07:42:18 +0000 (09:42 +0200)
bacula/src/stored/stored.c
bacula/src/stored/tape_alert.c

index 03ffe8be7556f270e3a23605120e30de6b3a4709..6e11abd85419d78e8ccecdece3264559a1ff4dd6 100644 (file)
@@ -716,9 +716,10 @@ void *device_initialization(void *arg)
                       (intptr_t)get_first_port_host_order(me->sdaddrs),
                       "Device initialization %s", device->hdr.name);
 
+      /* With USB devices, it might not be here when we start */
       if (device->control_name && stat(device->control_name, &statp) < 0) {
          berrno be;
-         Jmsg2(jcr, M_ERROR_TERM, 0, _("Unable to stat ControlDevice %s: ERR=%s\n"),
+         Jmsg2(jcr, M_ERROR, 0, _("Unable to stat ControlDevice %s: ERR=%s\n"),
             device->control_name, be.bstrerror());
       }
 
index f9ffb0cdecc5b27db91c967fb9477c67619af2c5..33abbb260260790c4ae2522363eb8703a7ef2834 100644 (file)
@@ -75,9 +75,10 @@ void alert_callback(void *ctx, const char *short_msg, const char *long_msg,
 bool tape_dev::get_tape_alerts(DCR *dcr)
 {
    JCR *jcr = dcr->jcr;
-
-   if (!job_canceled(jcr) && dcr->device->alert_command &&
-       dcr->device->control_name) {
+   if (job_canceled(jcr)) {
+      return false;
+   }
+   if (dcr->device->alert_command && dcr->device->control_name) {
       POOLMEM *alertcmd;
       int status = 1;
       int nalerts = 0;
@@ -86,6 +87,14 @@ bool tape_dev::get_tape_alerts(DCR *dcr)
       char line[MAXSTRING];
       const char *fmt = "TapeAlert[%d]";
 
+      struct stat statp;
+      if (stat(dcr->device->control_name, &statp) < 0) {
+          berrno be;
+          Jmsg2(jcr, M_ERROR, 0, _("Unable to stat ControlDevice %s: ERR=%s\n"),
+                dcr->device->control_name, be.bstrerror());
+          return false;
+      }
+
       if (!alert_list) {
          alert_list = New(alist(10));
       }