From: Alain Spineux Date: Thu, 16 Nov 2023 11:11:10 +0000 (+0100) Subject: Fix #10453 volume with a wrong label X-Git-Tag: Beta-15.0.1~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad5add036dc1d3d986a95f570025aebb7565d56a;p=thirdparty%2Fbacula.git Fix #10453 volume with a wrong label - when labeling if an error occurs, the fd stays open, and other attempt to label another volume will reuse the same fd (instead of opening a new one) making the label and the filename mismatched. - this is appening when auto labeling is enable and when the keymanager is failing - this could appends for other situation, maybe uncomment the commented line could help --- diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index 0d90cf1e5..82f877e2e 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -414,9 +414,11 @@ bool DEVICE::write_volume_label(DCR *dcr, const char *VolName, Dmsg1(150, "Label type=%d\n", dev->label_type); if (!load_encryption_key(dcr, "LABEL", VolName, &VolHdr.EncCypherKeySize, VolHdr.EncCypherKey, &VolHdr.MasterKeyIdSize, VolHdr.MasterKeyId)) { + close(dcr); goto bail_out; } if (!write_volume_label_to_dev(dcr, VolName, PoolName, relabel, no_prelabel)) { + /* close(dcr); uncomment if you get mismatched label like in #10453 */ goto bail_out; }