Skip to content

Commit

Permalink
Check for encryption before loading key
Browse files Browse the repository at this point in the history
Now we check if we need an encryption key
before we try to get it.

Fixes #338: bls always fails when scsicrypto-sd plugin is loaded

Signed-off-by: Marco van Wieringen <marco.van.wieringen@bareos.com>
  • Loading branch information
pstorz authored and Marco van Wieringen committed Sep 16, 2014
1 parent 12c8cb6 commit a41448d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/plugins/stored/scsicrypto-sd.c
Expand Up @@ -317,19 +317,35 @@ static bRC do_set_scsi_encryption_key(void *value)
*/
dcr = (DCR *)value;
if (!dcr) {
Dmsg0(dbglvl, "scsicrypto-sd: Error: dcr is not set!\n");
return bRC_Error;
}
dev = dcr->dev;
if (!dev) {
Dmsg0(dbglvl, "scsicrypto-sd: Error: dev is not set!\n");
return bRC_Error;
}
device = dev->device;
if (!device) {
Dmsg0(dbglvl, "scsicrypto-sd: Error: device is not set!\n");
return bRC_Error;
}

*StoredVolEncrKey = '\0';
if (!get_volume_encryption_key(dcr, StoredVolEncrKey)) {
Dmsg0(dbglvl, "scsicrypto-sd: Could not get_volume_encryption_key!\n");

/*
* Check if encryption key is needed for reading this volume.
*/
P(crypto_operation_mutex);
if (!need_scsi_crypto_key(dev->fd(), dev->dev_name, true)) {
V(crypto_operation_mutex);
Dmsg0(dbglvl, "scsicrypto-sd: No encryption key needed!\n");
return bRC_OK;
}
V(crypto_operation_mutex);

return bRC_Error;
}

Expand Down Expand Up @@ -407,14 +423,17 @@ static bRC do_clear_scsi_encryption_key(void *value)
*/
dcr = (DCR *)value;
if (!dcr) {
Dmsg0(dbglvl, "scsicrypto-sd: Error: dcr is not set!\n");
return bRC_Error;
}
dev = dcr->dev;
if (!dev) {
Dmsg0(dbglvl, "scsicrypto-sd: Error: dev is not set!\n");
return bRC_Error;
}
device = dev->device;
if (!device) {
Dmsg0(dbglvl, "scsicrypto-sd: Error: device is not set!\n");
return bRC_Error;
}

Expand Down

0 comments on commit a41448d

Please sign in to comment.