Rename FstabEntry::metadata_encryption to metadata_encryption_options

There have been two bugs where people use !metadata_encryption.empty()
to check whether metadata encryption is enabled.  It should actually be
!metadata_key_dir.empty(), since 'metadata_encryption' is the encryption
options, which can be empty if the defaults are sufficient.

Rename the field in FstabEntry appropriately.

To avoid breaking fstab files, don't rename the flag in the fstab file
itself.  So, now the fstab flags map to FstabEntry fields as follows:

    keydirectory => metadata_key_dir
    metadata_encryption => metadata_encryption_options

Change-Id: I3b5e28c273950bcf13bfd433aaaa49d1e92e177c
This commit is contained in:
Eric Biggers 2022-03-17 23:18:18 +00:00
parent f14f8627bb
commit 41d7843513

View file

@ -261,7 +261,7 @@ bool fscrypt_mount_metadata_encrypted(const std::string& blk_device, const std::
CryptoOptions options;
if (options_format_version == 1) {
if (!data_rec->metadata_encryption.empty()) {
if (!data_rec->metadata_encryption_options.empty()) {
LOG(ERROR) << "metadata_encryption options cannot be set in legacy mode";
return false;
}
@ -274,7 +274,7 @@ bool fscrypt_mount_metadata_encrypted(const std::string& blk_device, const std::
return false;
}
} else if (options_format_version == 2) {
if (!parse_options(data_rec->metadata_encryption, &options)) return false;
if (!parse_options(data_rec->metadata_encryption_options, &options)) return false;
} else {
LOG(ERROR) << "Unknown options_format_version: " << options_format_version;
return false;