mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-18 14:20:09 +01:00
Enhance persistent flags handling in cryptsetup.
With --persistent option, write only flags actually used during activation. In other words we will not store anymore flags not supported by running kernel.
This commit is contained in:
committed by
Milan Broz
parent
f6cb8e4118
commit
471f781022
@@ -1077,6 +1077,17 @@ out:
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int update_persistent_flags(struct crypt_device *cd, const char *name, uint32_t activation_flags)
|
||||||
|
{
|
||||||
|
struct crypt_active_device cad;
|
||||||
|
|
||||||
|
/* write only flags not filtered by current kernel during activation */
|
||||||
|
if (crypt_get_active_device(cd, name, &cad))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
return crypt_persistent_flags_set(cd, CRYPT_FLAGS_ACTIVATION, cad.flags & activation_flags);
|
||||||
|
}
|
||||||
|
|
||||||
static int action_open_luks(void)
|
static int action_open_luks(void)
|
||||||
{
|
{
|
||||||
struct crypt_device *cd = NULL;
|
struct crypt_device *cd = NULL;
|
||||||
@@ -1139,10 +1150,9 @@ static int action_open_luks(void)
|
|||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
if (r >= 0 && opt_persistent &&
|
if (r >= 0 && opt_persistent &&
|
||||||
crypt_persistent_flags_set(cd, CRYPT_FLAGS_ACTIVATION, activate_flags))
|
update_persistent_flags(cd, activated_name, activate_flags))
|
||||||
log_err(_("Device activated but cannot make flags persistent.\n"));
|
log_err(_("Device activated but cannot make flags persistent.\n"));
|
||||||
|
|
||||||
|
|
||||||
crypt_safe_free(key);
|
crypt_safe_free(key);
|
||||||
crypt_safe_free(password);
|
crypt_safe_free(password);
|
||||||
crypt_free(cd);
|
crypt_free(cd);
|
||||||
|
|||||||
Reference in New Issue
Block a user