From fefe5915b06a1121d885fba3680dd1b90027fd5d Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Sat, 30 Sep 2017 22:22:13 -0500 Subject: FBE for Pixel 2 Includes various minor fixes for building in Android 8 trees with r23+ tag Update FBE extended header in libtar to version 2 and include the entire ext4_encryption_policy structure now after translating the policy. See this post for more details: https://plus.google.com/u/1/+DeesTroy/posts/i33ygUi7tiu Change-Id: I2af981e51f459b17fcd895fb8c2d3f6c8200e24b --- libtar/extract.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'libtar/extract.c') diff --git a/libtar/extract.c b/libtar/extract.c index 82ed766b2..fcd403a04 100644 --- a/libtar/extract.c +++ b/libtar/extract.c @@ -549,22 +549,23 @@ tar_extract_dir(TAR *t, const char *realname) } #ifdef HAVE_EXT4_CRYPT - if(t->th_buf.e4crypt_policy != NULL) + if(t->th_buf.eep != NULL) { #ifdef DEBUG - printf("tar_extract_file(): restoring EXT4 crypt policy %s to dir %s\n", t->th_buf.e4crypt_policy, realname); + printf("tar_extract_file(): restoring EXT4 crypt policy %s to dir %s\n", t->th_buf.eep->master_key_descriptor, realname); #endif char binary_policy[EXT4_KEY_DESCRIPTOR_SIZE]; - if (!lookup_ref_tar(t->th_buf.e4crypt_policy, &binary_policy)) { - printf("error looking up proper e4crypt policy for '%s' - %s\n", realname, t->th_buf.e4crypt_policy); + if (!lookup_ref_tar(t->th_buf.eep->master_key_descriptor, &binary_policy[0])) { + printf("error looking up proper e4crypt policy for '%s' - %s\n", realname, t->th_buf.eep->master_key_descriptor); return -1; } - char policy_hex[EXT4_KEY_DESCRIPTOR_HEX]; + char policy_hex[EXT4_KEY_DESCRIPTOR_SIZE_HEX]; policy_to_hex(binary_policy, policy_hex); - printf("restoring policy %s > '%s' to '%s'\n", t->th_buf.e4crypt_policy, policy_hex, realname); - if (!e4crypt_policy_set(realname, binary_policy, EXT4_KEY_DESCRIPTOR_SIZE, 0)) + printf("restoring policy %s > '%s' to '%s'\n", t->th_buf.eep->master_key_descriptor, policy_hex, realname); + memcpy(&t->th_buf.eep->master_key_descriptor, binary_policy, EXT4_KEY_DESCRIPTOR_SIZE); + if (!e4crypt_policy_set_struct(realname, t->th_buf.eep)) { - printf("tar_extract_file(): failed to restore EXT4 crypt policy %s to dir '%s' '%s'!!!\n", t->th_buf.e4crypt_policy, realname, policy_hex); + printf("tar_extract_file(): failed to restore EXT4 crypt policy to dir '%s' '%s'!!!\n", realname, policy_hex); //return -1; // This may not be an error in some cases, so log and ignore } } -- cgit v1.2.3