mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-14 20:30:04 +01:00
Reformat crypt_resize function.
This commit is contained in:
@@ -495,20 +495,26 @@ static int action_resize(void)
|
||||
struct crypt_device *cd = NULL;
|
||||
|
||||
r = crypt_init_by_name_and_header(&cd, action_argv[0], opt_header_device);
|
||||
if (r == 0) {
|
||||
r = crypt_get_active_device(cd, action_argv[0], &cad);
|
||||
if (r)
|
||||
goto out;
|
||||
|
||||
if (!r && (cad.flags & CRYPT_ACTIVATE_KEYRING_KEY)) {
|
||||
/* FIXME: resize of LUKS2 in metadata? */
|
||||
r = crypt_get_active_device(cd, action_argv[0], &cad);
|
||||
if (r)
|
||||
goto out;
|
||||
|
||||
if (cad.flags & CRYPT_ACTIVATE_KEYRING_KEY) {
|
||||
if (opt_disable_keyring) {
|
||||
r = -EINVAL;
|
||||
log_err(_("Resize of active device requires volume key in keyring but --disable-keyring option is set.\n"));
|
||||
log_err(_("Resize of active device requires volume key "
|
||||
"in keyring but --disable-keyring option is set.\n"));
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* try load VK in kernel keyring using token */
|
||||
r = crypt_activate_by_token(cd, NULL, opt_token, NULL, CRYPT_ACTIVATE_KEYRING_KEY);
|
||||
if (r < 0) {
|
||||
if (opt_token_only)
|
||||
r = crypt_activate_by_token(cd, NULL, opt_token, NULL,
|
||||
CRYPT_ACTIVATE_KEYRING_KEY);
|
||||
if (r < 0 && opt_token_only)
|
||||
goto out;
|
||||
|
||||
r = tools_get_key(NULL, &password, &passwordLen,
|
||||
@@ -517,17 +523,16 @@ static int action_resize(void)
|
||||
if (r < 0)
|
||||
goto out;
|
||||
|
||||
r = crypt_activate_by_passphrase(cd, NULL, opt_key_slot, password, passwordLen, CRYPT_ACTIVATE_KEYRING_KEY);
|
||||
r = crypt_activate_by_passphrase(cd, NULL, opt_key_slot,
|
||||
password, passwordLen,
|
||||
CRYPT_ACTIVATE_KEYRING_KEY);
|
||||
tools_passphrase_msg(r);
|
||||
crypt_safe_free(password);
|
||||
}
|
||||
}
|
||||
|
||||
if (r >= 0)
|
||||
r = crypt_resize(cd, action_argv[0], opt_size);
|
||||
}
|
||||
out:
|
||||
|
||||
crypt_free(cd);
|
||||
return r;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user