applypatch: Add backup_source parameter to PatchPartition.

And set it to false when installing recovery image via applypatch. We
only need to back up the source partition when doing in-place update
(e.g. when updating a given partition under recovery). When installing
recovery image via applypatch, we won't touch the source partition (i.e.
/boot).

Removing the backup step also allows dropping the dac_override_allowed
permission. Previously it was needed due to the access to /cache.
Because applypatch runs as root:root, while /cache is owned by
system:cache with 0770.

Bug: 68319577
Test: Invoke the code that installs recovery image; check that recovery
      is installed successfully without denials.
Test: recovery_unit_test passes on taimen.
Change-Id: I549a770b511762189d6672a2835b6e403d695919
This commit is contained in:
Tao Bao
2019-09-23 10:28:54 -07:00
parent 71c35b9fba
commit 5234ad466c
5 changed files with 17 additions and 14 deletions
+4 -3
View File
@@ -73,10 +73,11 @@ std::ostream& operator<<(std::ostream& os, const Partition& partition);
// the 'target' Partition. While patching, it will backup the data on the source partition to
// /cache, so that the patching could be resumed on interruption even if both of the source and
// target partitions refer to the same device. The function is idempotent if called multiple times.
// An optional arg 'bonus' can be provided, if the patch was generated with a bonus output.
// Returns the patching result.
// 'bonus' can be provided if the patch was generated with a bonus output, or nullptr.
// 'backup_source' indicates whether the source partition should be backed up prior to the update
// (e.g. when doing in-place update). Returns the patching result.
bool PatchPartition(const Partition& target, const Partition& source, const Value& patch,
const Value* bonus);
const Value* bonus, bool backup_source);
// Returns whether the contents of the eMMC target or the cached file match the embedded hash.
// It will look for the backup on /cache if the given partition doesn't match the checksum.