mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-18 14:20:09 +01:00
Do not resume device when not suspended.
Abort action luksResume early if device is not suspended. We would needlesly ask for passphrase or load cryptsetup plugins only to fail later in crypt_resume_by_* API.
This commit is contained in:
@@ -2189,6 +2189,7 @@ static int action_luksResume(void)
|
||||
char *password = NULL;
|
||||
size_t passwordLen;
|
||||
int r, tries;
|
||||
struct crypt_active_device cad;
|
||||
const char *req_type = luksType(device_type);
|
||||
|
||||
if (req_type && !isLUKS(req_type))
|
||||
@@ -2208,6 +2209,16 @@ static int action_luksResume(void)
|
||||
goto out;
|
||||
}
|
||||
|
||||
r = crypt_get_active_device(cd, action_argv[0], &cad);
|
||||
if (r < 0)
|
||||
goto out;
|
||||
|
||||
if (!(cad.flags & CRYPT_ACTIVATE_SUSPENDED)) {
|
||||
log_err(_("Volume %s is not suspended."), action_argv[0]);
|
||||
r = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* try to resume LUKS2 device by token first */
|
||||
r = crypt_resume_by_token_pin(cd, action_argv[0], ARG_STR(OPT_TOKEN_TYPE_ID),
|
||||
ARG_INT32(OPT_TOKEN_ID_ID), NULL, 0, NULL);
|
||||
|
||||
Reference in New Issue
Block a user