diff options
author | Luca Boccassi <bluca@debian.org> | 2022-08-03 18:41:13 +0100 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2022-08-04 00:58:57 +0100 |
commit | 872f9da4d8b67b012f1b1b227416d0c99bcdf43c (patch) | |
tree | e1f819a243389821d69e2b67d60861748f23da4f /src/integritysetup | |
parent | 29e804dffd52496aaad2d0fc6a50d18a9940010d (diff) | |
download | systemd-872f9da4d8b67b012f1b1b227416d0c99bcdf43c.tar.gz |
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.
Diffstat (limited to 'src/integritysetup')
-rw-r--r-- | src/integritysetup/integritysetup.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/integritysetup/integritysetup.c b/src/integritysetup/integritysetup.c index 924c15b6eb..a602886cb3 100644 --- a/src/integritysetup/integritysetup.c +++ b/src/integritysetup/integritysetup.c @@ -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"); |