Add --key-description for resize command.

This commit is contained in:
Milan Broz
2024-02-14 13:32:48 +01:00
parent 3e01e151f8
commit 82118bdd5f
3 changed files with 9 additions and 8 deletions

View File

@@ -441,7 +441,7 @@ it is requested.
Reencrypt only the LUKS1 header and keyslots. Skips data in-place reencryption.
endif::[]
ifdef::ACTION_LUKSFORMAT,ACTION_LUKSDUMP,ACTION_TOKEN[]
ifdef::ACTION_LUKSFORMAT,ACTION_LUKSDUMP,ACTION_RESIZE,ACTION_TOKEN[]
*--key-description <text>*::
Set key description in keyring that will be used for passphrase retrieval.
endif::[]

View File

@@ -896,6 +896,7 @@ static int action_resize(void)
uint64_t dev_size = 0;
char *password = NULL;
struct crypt_device *cd = NULL;
struct crypt_keyslot_context *kc = NULL;
r = crypt_init_by_name_and_header(&cd, action_argv[0], ARG_STR(OPT_HEADER_ID));
if (r)
@@ -936,15 +937,14 @@ static int action_resize(void)
if (r >= 0 || quit || ARG_SET(OPT_TOKEN_ONLY_ID))
goto out;
r = tools_get_key(NULL, &password, &passwordLen,
ARG_UINT64(OPT_KEYFILE_OFFSET_ID), ARG_UINT32(OPT_KEYFILE_SIZE_ID), ARG_STR(OPT_KEY_FILE_ID),
ARG_UINT32(OPT_TIMEOUT_ID), verify_passphrase(0), 0, cd);
r = init_keyslot_context(cd, &password, &passwordLen, verify_passphrase(0),
false, false, &kc);
if (r < 0)
goto out;
r = crypt_activate_by_passphrase(cd, NULL, ARG_INT32(OPT_KEY_SLOT_ID),
password, passwordLen,
CRYPT_ACTIVATE_KEYRING_KEY);
r = crypt_activate_by_keyslot_context(cd, NULL,ARG_INT32(OPT_KEY_SLOT_ID),
kc, CRYPT_ANY_SLOT, NULL,
CRYPT_ACTIVATE_KEYRING_KEY);
tools_passphrase_msg(r);
tools_keyslot_msg(r, UNLOCKED);
}
@@ -954,6 +954,7 @@ out:
r = crypt_resize(cd, action_argv[0], dev_size);
crypt_safe_free(password);
crypt_keyslot_context_free(kc);
crypt_free(cd);
return r;
}

View File

@@ -71,7 +71,7 @@
#define OPT_ITER_TIME_ACTIONS { BENCHMARK_ACTION, FORMAT_ACTION, ADDKEY_ACTION, CHANGEKEY_ACTION, CONVERTKEY_ACTION, REENCRYPT_ACTION }
#define OPT_IV_LARGE_SECTORS_ACTIONS { OPEN_ACTION }
#define OPT_KEEP_KEY_ACTIONS { REENCRYPT_ACTION }
#define OPT_KEY_DESCRIPTION_ACTIONS { TOKEN_ACTION, LUKSDUMP_ACTION, FORMAT_ACTION }
#define OPT_KEY_DESCRIPTION_ACTIONS { TOKEN_ACTION, LUKSDUMP_ACTION, FORMAT_ACTION, RESIZE_ACTION }
#define OPT_KEY_SIZE_ACTIONS { OPEN_ACTION, BENCHMARK_ACTION, FORMAT_ACTION, REENCRYPT_ACTION, ADDKEY_ACTION }
#define OPT_KEY_SLOT_ACTIONS { OPEN_ACTION, REENCRYPT_ACTION, CONFIG_ACTION, FORMAT_ACTION, ADDKEY_ACTION, CHANGEKEY_ACTION, CONVERTKEY_ACTION, LUKSDUMP_ACTION, TOKEN_ACTION, RESUME_ACTION }
#define OPT_KEYSLOT_CIPHER_ACTIONS { FORMAT_ACTION, REENCRYPT_ACTION, ADDKEY_ACTION, CHANGEKEY_ACTION, CONVERTKEY_ACTION }