Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 20a5f92a authored by Eric Biggers's avatar Eric Biggers
Browse files

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: I5bf673047c99e077bd6e1ac006d80e7e16bc814b
parent 4e0a7f22
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -287,11 +287,16 @@ bool ParseFsMgrFlags(const std::string& flags, FstabEntry* entry) {
            entry->fs_mgr_flags.avb = true;
            entry->vbmeta_partition = arg;
        } else if (StartsWith(flag, "keydirectory=")) {
            // The metadata flag is followed by an = and the directory for the keys.
            // The keydirectory flag enables metadata encryption.  It is
            // followed by an = and the directory containing the metadata
            // encryption key.
            entry->metadata_key_dir = arg;
        } else if (StartsWith(flag, "metadata_encryption=")) {
            // Specify the cipher and flags to use for metadata encryption
            entry->metadata_encryption = arg;
            // The metadata_encryption flag specifies the cipher and flags to
            // use for metadata encryption, if the defaults aren't sufficient.
            // It doesn't actually enable metadata encryption; that is done by
            // "keydirectory".
            entry->metadata_encryption_options = arg;
        } else if (StartsWith(flag, "sysfs_path=")) {
            // The path to trigger device gc by idle-maint of vold.
            entry->sysfs_path = arg;
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ struct FstabEntry {
    std::string fs_options;
    std::string fs_checkpoint_opts;
    std::string metadata_key_dir;
    std::string metadata_encryption;
    std::string metadata_encryption_options;
    off64_t length = 0;
    std::string label;
    int partnum = -1;
+3 −3
Original line number Diff line number Diff line
@@ -943,7 +943,7 @@ source none0 swap defaults keydirectory=/dir/key,metadata_encryptio
    ASSERT_LE(1U, fstab.size());

    auto entry = fstab.begin();
    EXPECT_EQ("adiantum", entry->metadata_encryption);
    EXPECT_EQ("adiantum", entry->metadata_encryption_options);
}

TEST(fs_mgr, ReadFstabFromFile_FsMgrOptions_MetadataEncryption_WrappedKey) {
@@ -960,8 +960,8 @@ source none0 swap defaults keydirectory=/dir/key,metadata_encryptio
    ASSERT_LE(1U, fstab.size());

    auto entry = fstab.begin();
    EXPECT_EQ("aes-256-xts:wrappedkey_v0", entry->metadata_encryption);
    auto parts = android::base::Split(entry->metadata_encryption, ":");
    EXPECT_EQ("aes-256-xts:wrappedkey_v0", entry->metadata_encryption_options);
    auto parts = android::base::Split(entry->metadata_encryption_options, ":");
    EXPECT_EQ(2U, parts.size());
    EXPECT_EQ("aes-256-xts", parts[0]);
    EXPECT_EQ("wrappedkey_v0", parts[1]);