diff --git a/libtar/append.c b/libtar/append.c index 6f0b2527..dff0f88d 100755 --- a/libtar/append.c +++ b/libtar/append.c @@ -185,7 +185,6 @@ tar_append_file(TAR *t, const char *realname, const char *savename) printf("failed to lookup fscrypt tar policy for '%s' - '%s'\n", realname, policy_hex); free(t->th_buf.fep); t->th_buf.fep = NULL; - return -1; } } else { diff --git a/libtar/extract.c b/libtar/extract.c index 65ea1d16..08e2914c 100755 --- a/libtar/extract.c +++ b/libtar/extract.c @@ -570,6 +570,7 @@ tar_extract_dir(TAR *t, const char *realname) #endif printf("tar_extract_dir(): restoring fscrypt policy %s to dir %s\n", (char *)policy_hex, realname); #endif + bool policy_lookup_error = false; #ifdef USE_FSCRYPT_POLICY_V1 uint8_t binary_policy[FS_KEY_DESCRIPTOR_SIZE]; memset(&binary_policy, 0, FS_KEY_DESCRIPTOR_SIZE); @@ -581,24 +582,28 @@ tar_extract_dir(TAR *t, const char *realname) #ifdef USE_FSCRYPT_POLICY_V1 if (!lookup_ref_tar(t->th_buf.fep->master_key_descriptor, &binary_policy[0])) { printf("error looking up fscrypt policy for '%s' - %s\n", realname, t->th_buf.fep->master_key_descriptor); - return -1; + policy_lookup_error = true; } memcpy(&t->th_buf.fep->master_key_descriptor, binary_policy, FS_KEY_DESCRIPTOR_SIZE); bytes_to_hex(t->th_buf.fep->master_key_descriptor, FS_KEY_DESCRIPTOR_SIZE, policy_hex); #else if (!lookup_ref_tar(t->th_buf.fep->master_key_identifier, &binary_policy[0])) { printf("error looking up fscrypt policy for '%s' - %s\n", realname, t->th_buf.fep->master_key_identifier); - return -1; + policy_lookup_error = true; } memcpy(&t->th_buf.fep->master_key_identifier, binary_policy, FSCRYPT_KEY_IDENTIFIER_SIZE); bytes_to_hex(t->th_buf.fep->master_key_identifier, FSCRYPT_KEY_IDENTIFIER_SIZE, policy_hex); #endif - printf("attempting to restore policy: %s\n", policy_hex); - if (!fscrypt_policy_set_struct(realname, t->th_buf.fep)) + if (!policy_lookup_error) { - printf("tar_extract_file(): failed to restore fscrypt policy to dir '%s' '%s'!!!\n", realname, policy_hex); - //return -1; // This may not be an error in some cases, so log and ignore - } + printf("attempting to restore policy: %s\n", policy_hex); + if (!fscrypt_policy_set_struct(realname, t->th_buf.fep)) + { + printf("tar_extract_file(): failed to restore fscrypt policy to dir '%s' '%s'!!!\n", realname, policy_hex); + //return -1; // This may not be an error in some cases, so log and ignore + } + } else + printf("No policy was found. Continuing restore."); } else printf("NULL FSCRYPT\n");