From: Kern Sibbald Date: Sun, 11 Nov 2018 16:30:25 +0000 (+0100) Subject: More Enterprise backports X-Git-Tag: Release-9.4.0~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfd9999b7d5225a439e68d0db96e3e5c7a5f2c35;p=thirdparty%2Fbacula.git More Enterprise backports --- diff --git a/bacula/src/lib/bsockcore.c b/bacula/src/lib/bsockcore.c index 3b9c7c692..2cda1f798 100644 --- a/bacula/src/lib/bsockcore.c +++ b/bacula/src/lib/bsockcore.c @@ -714,7 +714,8 @@ bool BSOCKCORE::set_buffer_size(uint32_t size, int rw) dbuf_size = DEFAULT_NETWORK_BUFFER_SIZE; } start_size = dbuf_size; - if ((msg = realloc_pool_memory(msg, dbuf_size + 100)) == NULL) { + /* The extra 512 can hold data such as Sparse/Offset pointer */ + if ((msg = realloc_pool_memory(msg, dbuf_size + 512)) == NULL) { Qmsg0(get_jcr(), M_FATAL, 0, _("Could not malloc BSOCKCORE data buffer\n")); return false; } diff --git a/bacula/src/lib/bsockcore.h b/bacula/src/lib/bsockcore.h index 695ad38d4..70e9e8299 100644 --- a/bacula/src/lib/bsockcore.h +++ b/bacula/src/lib/bsockcore.h @@ -124,7 +124,7 @@ protected: void master_lock() const { if (m_use_locking) pP((&m_mmutex)); }; void master_unlock() const { if (m_use_locking) pV((&m_mmutex)); }; virtual void init(); - void _destroy(); /* called by destroy() */ + virtual void _destroy(); /* called by destroy() */ virtual int32_t write_nbytes(char *ptr, int32_t nbytes); virtual int32_t read_nbytes(char *ptr, int32_t nbytes); @@ -140,7 +140,7 @@ public: virtual int32_t recv(int /*len*/); virtual bool send(); bool fsend(const char*, ...); - void close(); /* close connection and destroy packet */ + virtual void close(); /* close connection and destroy packet */ void destroy(); /* destroy socket packet */ const char *bstrerror(); /* last error on socket */ int get_peer(char *buf, socklen_t buflen); diff --git a/bacula/src/lib/crypto.c b/bacula/src/lib/crypto.c index 0cb4f9fee..c8e9b2a3a 100644 --- a/bacula/src/lib/crypto.c +++ b/bacula/src/lib/crypto.c @@ -195,7 +195,7 @@ IMPLEMENT_ASN1_FUNCTIONS(RecipientInfo) IMPLEMENT_ASN1_FUNCTIONS(SignatureData) IMPLEMENT_ASN1_FUNCTIONS(CryptoData) -#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) +#if defined(DEFINE_STACK_OF) DEFINE_STACK_OF(SignerInfo); DEFINE_STACK_OF(RecipientInfo); #else @@ -391,7 +391,7 @@ X509_KEYPAIR *crypto_keypair_dup(X509_KEYPAIR *keypair) if (keypair->pubkey) { ret = EVP_PKEY_up_ref(keypair->pubkey); if (ret == 0) - goto out_free_new; + goto out_free_new; newpair->pubkey = keypair->pubkey; } @@ -399,7 +399,7 @@ X509_KEYPAIR *crypto_keypair_dup(X509_KEYPAIR *keypair) if (keypair->privkey) { ret = EVP_PKEY_up_ref(keypair->privkey); if (ret == 0) - goto out_free_new; + goto out_free_new; newpair->privkey = keypair->privkey; } @@ -407,7 +407,7 @@ X509_KEYPAIR *crypto_keypair_dup(X509_KEYPAIR *keypair) if (keypair->keyid) { newpair->keyid = ASN1_OCTET_STRING_dup(keypair->keyid); if (!newpair->keyid) - goto out_free_new; + goto out_free_new; } return newpair; @@ -600,7 +600,7 @@ DIGEST *crypto_digest_new(JCR *jcr, crypto_digest_t type) /* Initialize the OpenSSL message digest context */ digest->ctx = EVP_MD_CTX_new(); if (!digest->ctx) - goto err; + goto err; EVP_MD_CTX_reset(digest->ctx); /* Determine the correct OpenSSL message digest type */ @@ -1261,11 +1261,11 @@ CIPHER_CONTEXT *crypto_cipher_new(CRYPTO_SESSION *cs, bool encrypt, uint32_t *bl cipher_ctx = (CIPHER_CONTEXT *)malloc(sizeof(CIPHER_CONTEXT)); if (!cipher_ctx) - return NULL; + return NULL; cipher_ctx->ctx = EVP_CIPHER_CTX_new(); if (!cipher_ctx->ctx) - goto err; + goto err; /* * Acquire a cipher instance for the given ASN.1 cipher NID diff --git a/bacula/src/lib/devlock.c b/bacula/src/lib/devlock.c index 606449ffc..5975f6a17 100644 --- a/bacula/src/lib/devlock.c +++ b/bacula/src/lib/devlock.c @@ -44,7 +44,7 @@ devlock *new_devlock() { devlock *lock; lock = (devlock *)malloc(sizeof (devlock)); - memset(lock, 0, sizeof(devlock)); + bmemset(lock, 0, sizeof(devlock)); return lock; } diff --git a/bacula/src/lib/lockmgr.c b/bacula/src/lib/lockmgr.c index 53f466af8..3ec1c2e5a 100644 --- a/bacula/src/lib/lockmgr.c +++ b/bacula/src/lib/lockmgr.c @@ -1,7 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright (C) 2000-2017 Kern Sibbald + Copyright (C) 2000-2018 Kern Sibbald The original author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -582,7 +582,11 @@ static pthread_key_t lmgr_key; /* used to get lgmr_thread_t object */ static dlist *global_mgr = NULL; /* used to store all lgmr_thread_t objects */ static pthread_mutex_t lmgr_global_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_t undertaker; -static bool use_undertaker=true; +static pthread_cond_t undertaker_cond; +static pthread_mutex_t undertaker_mutex = PTHREAD_MUTEX_INITIALIZER; +static bool use_undertaker = true; +static bool do_quit = false; + #define lmgr_is_active() (global_mgr != NULL) @@ -745,12 +749,26 @@ void cln_hdl(void *a) void *check_deadlock(void *) { - int old; lmgr_init_thread(); pthread_cleanup_push(cln_hdl, NULL); - while (!bmicrosleep(30, 0)) { - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old); + while (!do_quit) { + struct timeval tv; + struct timezone tz; + struct timespec timeout; + + gettimeofday(&tv, &tz); + timeout.tv_nsec = 0; + timeout.tv_sec = tv.tv_sec + 30; + + pthread_mutex_lock(&undertaker_mutex); + pthread_cond_timedwait(&undertaker_cond, &undertaker_mutex, &timeout); + pthread_mutex_unlock(&undertaker_mutex); + + if(do_quit) { + goto bail_out; + } + if (lmgr_detect_deadlock()) { /* If we have information about P()/V(), display them */ if (debug_flags & DEBUG_MUTEX_EVENT && chk_dbglvl(DBGLEVEL_EVENT)) { @@ -759,9 +777,9 @@ void *check_deadlock(void *) lmgr_dump(); ASSERT2(0, "Lock deadlock"); /* Abort if we found a deadlock */ } - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old); - pthread_testcancel(); } + +bail_out: Dmsg0(100, "Exit check_deadlock.\n"); pthread_cleanup_pop(1); return NULL; @@ -817,6 +835,14 @@ void create_lmgr_key() global_mgr = New(dlist(n, &n->link)); if (use_undertaker) { + /* Create condwait */ + status = pthread_cond_init(&undertaker_cond, NULL); + if (status != 0) { + berrno be; + Pmsg1(000, _("pthread_cond_init failed: ERR=%s\n"), + be.bstrerror(status)); + ASSERT2(0, "pthread_cond_init failed"); + } status = pthread_create(&undertaker, NULL, check_deadlock, NULL); if (status != 0) { berrno be; @@ -871,11 +897,14 @@ void lmgr_cleanup_main() return; } if (use_undertaker) { - pthread_cancel(undertaker); -#ifdef DEVELOPER + /* Signal to the check_deadlock thread to stop itself */ + pthread_mutex_lock(&undertaker_mutex); + do_quit = true; + pthread_cond_signal(&undertaker_cond); + pthread_mutex_unlock(&undertaker_mutex); /* Should avoid memory leak reporting */ pthread_join(undertaker, NULL); -#endif + pthread_cond_destroy(&undertaker_cond); } lmgr_cleanup_thread(); lmgr_p(&lmgr_global_mutex); diff --git a/bacula/src/lib/mem_pool.c b/bacula/src/lib/mem_pool.c index a29e68ef3..feedc2d6d 100644 --- a/bacula/src/lib/mem_pool.c +++ b/bacula/src/lib/mem_pool.c @@ -1,7 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright (C) 2000-2017 Kern Sibbald + Copyright (C) 2000-2018 Kern Sibbald The original author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -145,9 +145,11 @@ POOLMEM *sm_get_memory(const char *fname, int lineno, int32_t size) buf->ablen = size; buf->pool = pool; buf->next = NULL; + P(mutex); pool_ctl[pool].in_use++; if (pool_ctl[pool].in_use > pool_ctl[pool].max_used) pool_ctl[pool].max_used = pool_ctl[pool].in_use; + V(mutex); return (POOLMEM *)(((char *)buf)+HEAD_SIZE); } diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index 786853b7d..b8e78ed5c 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -1191,6 +1191,21 @@ void set_trace(int trace_flag) } } +/* + * Can be called by Bacula's tools that use Bacula's libraries, to control where + * to redirect Dmsg() emitted by the code inside the Bacula's library. + * This should not be called by the main daemon, this is a Hack ! + * See in bsnapshot.c how it is used + * In your tools be careful to no call any function that here in messages.c + * that modify "trace" or close() or re-open() trace_fd + */ +void set_trace_for_tools(FILE *new_trace_fd) +{ + // don't call fclose(trace_fd) here + trace = true; + trace_fd = new_trace_fd; +} + void set_hangup(int hangup_value) { if (hangup_value != -1) { diff --git a/bacula/src/lib/message.h b/bacula/src/lib/message.h index f4a63818f..ed23ce39f 100644 --- a/bacula/src/lib/message.h +++ b/bacula/src/lib/message.h @@ -179,6 +179,7 @@ bool get_trace(void); void set_debug_flags(char *options); const char *get_basename(const char *pathname); bool is_message_type_set(JCR *jcr, int type); +void set_trace_for_tools(FILE *new_trace_fd); // called by Bacula's tools only class BDB; /* define forward reference */ typedef bool (*sql_query_call)(JCR *jcr, const char *cmd); diff --git a/bacula/src/lib/openssl.c b/bacula/src/lib/openssl.c index 558868b52..7499a301d 100644 --- a/bacula/src/lib/openssl.c +++ b/bacula/src/lib/openssl.c @@ -1,7 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright (C) 2000-2016 Kern Sibbald + Copyright (C) 2000-2018 Kern Sibbald The original author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -11,7 +11,7 @@ Public License, v3.0 ("AGPLv3") and some additional permissions and terms pursuant to its AGPLv3 Section 7. - This notice must be preserved when any source code is + This notice must be preserved when any source code is conveyed and/or propagated. Bacula(R) is a registered trademark of Kern Sibbald. @@ -69,7 +69,7 @@ void openssl_post_errors(JCR *jcr, int code, const char *errstring) } } -#if (OPENSSL_VERSION_NUMBER < 0x10100000L) +#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER) /* Array of mutexes for use with OpenSSL static locking */ static pthread_mutex_t *mutexes; @@ -267,7 +267,7 @@ int init_crypto (void) { int stat = 0; -#if (OPENSSL_VERSION_NUMBER < 0x10100000L) +#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER) if ((stat = openssl_init_threads()) != 0) { berrno be; Jmsg1(NULL, M_ABORT, 0, @@ -314,7 +314,7 @@ int cleanup_crypto (void) Jmsg0(NULL, M_ERROR, 0, _("Failed to save OpenSSL PRNG\n")); } -#if (OPENSSL_VERSION_NUMBER < 0x10100000L) +#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER) openssl_cleanup_threads(); /* Free libssl and libcrypto error strings */ diff --git a/bacula/src/lib/output.c b/bacula/src/lib/output.c index e07ad7dc4..ae12c1627 100644 --- a/bacula/src/lib/output.c +++ b/bacula/src/lib/output.c @@ -1,7 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright (C) 2000-2017 Kern Sibbald + Copyright (C) 2000-2018 Kern Sibbald The original author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -205,7 +205,7 @@ char *OutputWriter::get_output(va_list ap, POOLMEM **out, OutputType first) POOLMEM *tmp2 = get_pool_memory(PM_FNAME); POOLMEM *tmp = get_pool_memory(PM_FNAME); OutputType val = first; - + while (val != OT_END) { *tmp = 0; @@ -306,6 +306,12 @@ char *OutputWriter::get_output(va_list ap, POOLMEM **out, OutputType first) Mmsg(tmp, "%s_epoch=%lld%c%s=%s%c", k, bt, separator, k, ed1, separator); break; + case OT_DURATION: + bt = va_arg(ap, utime_t); + bstrutime(ed1, sizeof(ed1), bt); + Mmsg(tmp, "%s=%lld%c%s_str=%s%c", k, bt, separator, k, edit_utime(bt, ed1, sizeof(ed1)), separator); + break; + case OT_SIZE: case OT_INT64: i64 = va_arg(ap, int64_t); @@ -326,7 +332,11 @@ char *OutputWriter::get_output(va_list ap, POOLMEM **out, OutputType first) case OT_JOBTYPE: case OT_JOBSTATUS: i32 = va_arg(ap, int32_t); - Mmsg(tmp, "%s=%c%c", k, (char) i32, separator); + if (i32 == 0) { + Mmsg(tmp, "%s=%c", k, separator); + } else { + Mmsg(tmp, "%s=%c%c", k, (char)i32, separator); + } break; case OT_CLEAR: diff --git a/bacula/src/lib/parse_conf.c b/bacula/src/lib/parse_conf.c index cb3573fbd..d907a7cd7 100644 --- a/bacula/src/lib/parse_conf.c +++ b/bacula/src/lib/parse_conf.c @@ -94,7 +94,7 @@ static const char *get_default_configdir(); * name handler value code flags default_value */ RES_ITEM msgs_items[] = { - {"Name", store_name, ITEM(res_msgs.hdr.name), 0, 0, 0}, + {"Name", store_name, ITEM(res_msgs.hdr.name), 0, ITEM_REQUIRED, 0}, {"Description", store_str, ITEM(res_msgs.hdr.desc), 0, 0, 0}, {"MailCommand", store_str, ITEM(res_msgs.mail_cmd), 0, ITEM_ALLOW_DUPS, 0}, {"OperatorCommand", store_str, ITEM(res_msgs.operator_cmd), 0, ITEM_ALLOW_DUPS, 0}, diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 939546be2..53c5a470c 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -145,6 +145,7 @@ int bget_msg(BSOCK *sock); /* bpipe.c */ BPIPE * open_bpipe(char *prog, int wait, const char *mode, char *envp[]=NULL); int close_wpipe(BPIPE *bpipe); +int close_epipe(BPIPE *bpipe); int close_bpipe(BPIPE *bpipe); /* cram-md5.c */ diff --git a/bacula/src/lib/runscript.c b/bacula/src/lib/runscript.c index bbe7ce063..3aa7af501 100644 --- a/bacula/src/lib/runscript.c +++ b/bacula/src/lib/runscript.c @@ -1,7 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright (C) 2000-2016 Kern Sibbald + Copyright (C) 2000-2018 Kern Sibbald The original author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -11,7 +11,7 @@ Public License, v3.0 ("AGPLv3") and some additional permissions and terms pursuant to its AGPLv3 Section 7. - This notice must be preserved when any source code is + This notice must be preserved when any source code is conveyed and/or propagated. Bacula(R) is a registered trademark of Kern Sibbald. @@ -276,9 +276,11 @@ void free_runscripts(alist *runscripts) { Dmsg0(500, "runscript: freeing all RUNSCRIPTS object\n"); - RUNSCRIPT *elt; - foreach_alist(elt, runscripts) { - free_runscript(elt); + if (runscripts){ + RUNSCRIPT *elt; + foreach_alist(elt, runscripts) { + free_runscript(elt); + } } } diff --git a/bacula/src/lib/tls.c b/bacula/src/lib/tls.c index 7d25ea354..604ccaee7 100644 --- a/bacula/src/lib/tls.c +++ b/bacula/src/lib/tls.c @@ -1,7 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright (C) 2000-2017 Kern Sibbald + Copyright (C) 2000-2018 Kern Sibbald The original author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -79,6 +79,15 @@ static int openssl_verify_peer(int ok, X509_STORE_CTX *store) char issuer[256]; char subject[256]; + if (err == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT || + err == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN) + { + /* It seems that the error can be also + * 24 X509_V_ERR_INVALID_CA: invalid CA certificate + * But it's not very specific... + */ + Jmsg0(NULL, M_ERROR, 0, _("CA certificate is self signed. With OpenSSL 1.1, enforce basicConstraints = CA:true in the certificate creation to avoid this issue\n")); + } X509_NAME_oneline(X509_get_issuer_name(cert), issuer, 256); X509_NAME_oneline(X509_get_subject_name(cert), subject, 256); @@ -219,7 +228,6 @@ TLS_CONTEXT *new_tls_context(const char *ca_certfile, const char *ca_certdir, SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT, openssl_verify_peer); } - return ctx; err: @@ -731,7 +739,6 @@ bool tls_bsock_probe(BSOCKCORE *bsock) return SSL_peek(bsock->tls->openssl, &pktsiz, sizeof(pktsiz))==sizeof(pktsiz); } - #else /* HAVE_OPENSSL */ # error No TLS implementation available. #endif /* !HAVE_OPENSSL */ diff --git a/bacula/src/lib/tree.c b/bacula/src/lib/tree.c index 76a5542c4..572d9cd8c 100644 --- a/bacula/src/lib/tree.c +++ b/bacula/src/lib/tree.c @@ -1,7 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright (C) 2000-2017 Kern Sibbald + Copyright (C) 2000-2018 Kern Sibbald The original author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -81,7 +81,7 @@ TREE_ROOT *new_tree(int count) count = 1000; } root = (TREE_ROOT *)malloc(sizeof(TREE_ROOT)); - memset(root, 0, sizeof(TREE_ROOT)); + bmemset(root, 0, sizeof(TREE_ROOT)); /* Assume filename + node = 40 characters average length */ size = count * (BALIGN(sizeof(TREE_NODE)) + 40); if (count > 1000000 || size > (MAX_BUF_SIZE / 2)) { @@ -107,7 +107,7 @@ static TREE_NODE *new_tree_node(TREE_ROOT *root) TREE_NODE *node; int size = sizeof(TREE_NODE); node = (TREE_NODE *)tree_alloc(root, size); - memset(node, 0, size); + bmemset(node, 0, size); node->delta_seq = -1; node->can_access = 1; return node; diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index 4da226a0e..fa65232f9 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -319,7 +319,13 @@ bool dir_find_next_appendable_volume(DCR *dcr) BSOCK *dir = jcr->dir_bsock; bool rtn; char lastVolume[MAX_NAME_LENGTH]; + int nb_retry; + /* + * Calculate the number of possible drives + 30 for the size of the + * Volume list to consider. + */ + nb_retry = ((rblist *)res_head[R_DEVICE-r_first]->res_list)->size() + 30; Dmsg2(dbglvl, "dir_find_next_appendable_volume: reserved=%d Vol=%s\n", dcr->is_reserved(), dcr->VolumeName); Mmsg(jcr->errmsg, "Unknown error\n"); @@ -333,7 +339,7 @@ bool dir_find_next_appendable_volume(DCR *dcr) P(vol_info_mutex); dcr->clear_found_in_use(); lastVolume[0] = 0; - for (int vol_index=1; vol_index < 30; vol_index++) { + for (int vol_index=1; vol_index < nb_retry; vol_index++) { bash_spaces(dcr->media_type); bash_spaces(dcr->pool_name); dir->fsend(Find_media, jcr->JobId, vol_index, dcr->pool_name, dcr->media_type, @@ -358,7 +364,7 @@ bool dir_find_next_appendable_volume(DCR *dcr) */ /* ***FIXME*** find better way to handle voltype */ if (dcr->VolCatInfo.VolCatType != 0 && - (dcr->dev->dev_type == B_FILE_DEV || dcr->dev->dev_type == B_ALIGNED_DEV || + (dcr->dev->dev_type == B_FILE_DEV || dcr->dev->dev_type == B_ALIGNED_DEV || dcr->dev->dev_type == B_CLOUD_DEV) && dcr->dev->dev_type != (int)dcr->VolCatInfo.VolCatType) { Dmsg2(000, "Skip vol. Wanted VolType=%d Got=%d\n", dcr->dev->dev_type, dcr->VolCatInfo.VolCatType); @@ -433,7 +439,7 @@ bool dir_update_volume_info(DCR *dcr, bool label, bool update_LastWritten, POOL_MEM VolumeName; /* If system job, do not update catalog, except if we explicitly force it. */ - if (jcr->getJobType() == JT_SYSTEM && + if (jcr->getJobType() == JT_SYSTEM && !dcr->force_update_volume_info) { return true; } @@ -537,6 +543,7 @@ bool dir_update_volume_info(DCR *dcr, bool label, bool update_LastWritten, dev->VolCatInfo.VolCatRecycles = dcr->VolCatInfo.VolCatRecycles; dev->VolCatInfo.VolCatWrites = dcr->VolCatInfo.VolCatWrites; dev->VolCatInfo.VolCatReads = dcr->VolCatInfo.VolCatReads; + dev->VolCatInfo.VolEnable = dcr->VolCatInfo.VolEnable; dev->VolCatInfo.VolRecycle = dcr->VolCatInfo.VolRecycle; } ok = true; diff --git a/bacula/src/stored/autochanger.c b/bacula/src/stored/autochanger.c index c0e386881..24ffacab5 100644 --- a/bacula/src/stored/autochanger.c +++ b/bacula/src/stored/autochanger.c @@ -771,7 +771,9 @@ char *edit_device_codes(DCR *dcr, char *omsg, const char *imsg, const char *cmd) str = dcr->jcr->Job; break; case 'v': - if (dcr->VolCatInfo.VolCatName[0]) { + if (dcr->dev->LoadedVolName[0]) { + str = dcr->dev->LoadedVolName; + } else if (dcr->VolCatInfo.VolCatName[0]) { str = dcr->VolCatInfo.VolCatName; } else if (dcr->VolumeName[0]) { str = dcr->VolumeName; diff --git a/bacula/src/stored/block.h b/bacula/src/stored/block.h index 6b23d3ebe..2a2e2f1f8 100644 --- a/bacula/src/stored/block.h +++ b/bacula/src/stored/block.h @@ -52,6 +52,7 @@ * int32_t FileIndex * int32_t Stream * uint32_t data_length + * uint64_t FileOffset (if offset_stream) */ #define RECHDR2_LENGTH (3*sizeof(int32_t)) #define WRITE_RECHDR_LENGTH RECHDR2_LENGTH diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index eb53b63be..9815d8793 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -391,12 +391,12 @@ static void do_scan() { attr = new_attr(bjcr); - memset(&ar, 0, sizeof(ar)); - memset(&pr, 0, sizeof(pr)); - memset(&jr, 0, sizeof(jr)); - memset(&cr, 0, sizeof(cr)); - memset(&fsr, 0, sizeof(fsr)); - memset(&fr, 0, sizeof(fr)); + bmemset(&ar, 0, sizeof(ar)); + bmemset(&pr, 0, sizeof(pr)); + bmemset(&jr, 0, sizeof(jr)); + bmemset(&cr, 0, sizeof(cr)); + bmemset(&fsr, 0, sizeof(fsr)); + bmemset(&fr, 0, sizeof(fr)); /* Detach bscan's jcr as we are not a real Job on the tape */ @@ -483,7 +483,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) } /* Check Media Info */ - memset(&mr, 0, sizeof(mr)); + bmemset(&mr, 0, sizeof(mr)); bstrncpy(mr.VolumeName, dev->VolHdr.VolumeName, sizeof(mr.VolumeName)); mr.PoolId = pr.PoolId; num_media++; @@ -528,7 +528,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) ignored_msgs = 0; } unser_session_label(&label, rec); - memset(&jr, 0, sizeof(jr)); + bmemset(&jr, 0, sizeof(jr)); bstrncpy(jr.Job, label.Job, sizeof(jr.Job)); if (db_get_job_record(bjcr, db, &jr)) { /* Job record already exists in DB */ @@ -669,6 +669,9 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) Pmsg3(0, _("End of all Volumes. VolFiles=%u VolBlocks=%u VolBytes=%s\n"), mr.VolFiles, mr.VolBlocks, edit_uint64_with_commas(mr.VolBytes, ec1)); break; + case STREAM_PLUGIN_NAME: + break; + default: break; } /* end switch */ @@ -887,7 +890,7 @@ static void bscan_free_jcr(JCR *jcr) free_bsock(jcr->file_bsock); free_bsock(jcr->store_bsock); if (jcr->RestoreBootstrap) { - free(jcr->RestoreBootstrap); + bfree_and_null(jcr->RestoreBootstrap); } if (jcr->dcr) { free_dcr(jcr->dcr); @@ -1279,7 +1282,7 @@ static int create_jobmedia_record(BDB *db, JCR *mjcr) dcr->EndAddr = dev->EndAddr; dcr->VolMediaId = dev->VolCatInfo.VolMediaId; - memset(&jmr, 0, sizeof(jmr)); + bmemset(&jmr, 0, sizeof(jmr)); jmr.JobId = mjcr->JobId; jmr.MediaId = mr.MediaId; jmr.FirstIndex = dcr->VolFirstIndex; diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index dc098280c..257875bca 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -430,7 +430,7 @@ btime_t DEVICE::get_timer_count() /* read from fd */ ssize_t DEVICE::read(void *buf, size_t len) { - ssize_t read_len ; + ssize_t read_len; get_timer_count();