From 09447d500c39b79d0ba40c295656fa28898fd441 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Mon, 17 May 2021 09:42:08 +0200 Subject: [PATCH] Fix org#2442 About the check of the Control Device during startup --- bacula/src/stored/stored.c | 3 ++- bacula/src/stored/tape_alert.c | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index 03ffe8be7..6e11abd85 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -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()); } diff --git a/bacula/src/stored/tape_alert.c b/bacula/src/stored/tape_alert.c index f9ffb0cde..33abbb260 100644 --- a/bacula/src/stored/tape_alert.c +++ b/bacula/src/stored/tape_alert.c @@ -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)); } -- 2.47.3