]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix #10453 volume with a wrong label
authorAlain Spineux <alain@baculasystems.com>
Thu, 16 Nov 2023 11:11:10 +0000 (12:11 +0100)
committerEric Bollengier <eric@baculasystems.com>
Tue, 13 Feb 2024 09:36:02 +0000 (10:36 +0100)
- 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

bacula/src/stored/label.c

index 0d90cf1e540c5f993c4467e8317772afe624b1b4..82f877e2ef40a030257e870d48b4be304fe3f933 100644 (file)
@@ -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;
    }