integritysetup: do not use crypt_init_data_device after crypt_init
crypt_init_data_device() replaces the crypt_device struct with a new allocation, losing the old one, which we get from crypt_init(). Use crypt_set_data_device() instead. Enhance the test to cover this option too.
This commit is contained in:
committed by
Luca Boccassi
parent
29e804dffd
commit
872f9da4d8
@@ -152,12 +152,6 @@ static int run(int argc, char *argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!isempty(arg_existing_data_device)) {
|
||||
r = crypt_init_data_device(&cd, device, arg_existing_data_device);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add separate data device: %m");
|
||||
}
|
||||
|
||||
r = crypt_load(cd,
|
||||
CRYPT_INTEGRITY,
|
||||
&(struct crypt_params_integrity) {
|
||||
@@ -168,6 +162,12 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to load integrity superblock: %m");
|
||||
|
||||
if (!isempty(arg_existing_data_device)) {
|
||||
r = crypt_set_data_device(cd, arg_existing_data_device);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add separate data device: %m");
|
||||
}
|
||||
|
||||
r = crypt_activate_by_volume_key(cd, volume, key_buf, key_buf_size, arg_activate_flags);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set up integrity device: %m");
|
||||
|
||||
Reference in New Issue
Block a user