summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Ioffe <ioffe@google.com>2019-05-02 14:40:06 +0100
committerNikita Ioffe <ioffe@google.com>2019-05-02 16:03:44 +0100
commita32ccec1c4d247e29eef4288706c303b9e71f08b (patch)
tree23be635188441953b5c7d2fa245f208b8ca6397d
parent076018a12eb1979c831af73627bb7ddd026f6d2f (diff)
downloadapex-a32ccec1c4d247e29eef4288706c303b9e71f08b.tar.gz
Don't mount non-flattened apexes if device doesn't support them
* During boot sequence, apexd will just ignore non-flattened apexes if ro.apex.updatable is not set to true. * Also added a safeguard in mountNonFlattened mostly for consistency. Test: test every mainline pixel phone boots & camera works Test: pre-installed shim apex on marlin, checked it wasn't activated Bug: 130623080 Change-Id: I69a3b4994dcf81e713eb76cc046943a999918950
-rw-r--r--apexd/apexd.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/apexd/apexd.cpp b/apexd/apexd.cpp
index 9f7b23d1..ad8aa7ea 100644
--- a/apexd/apexd.cpp
+++ b/apexd/apexd.cpp
@@ -397,6 +397,12 @@ StatusOr<MountedApexData> mountNonFlattened(const ApexFile& apex,
using StatusM = StatusOr<MountedApexData>;
const std::string& full_path = apex.GetPath();
+ if (!kUpdatable) {
+ return StatusM::Fail(StringLog()
+ << "Unable to mount non-flattened apex package "
+ << full_path << " because device doesn't support it");
+ }
+
loop::LoopbackDeviceUniqueFd loopbackDevice;
for (size_t attempts = 1;; ++attempts) {
StatusOr<loop::LoopbackDeviceUniqueFd> ret = loop::createLoopDevice(
@@ -1310,6 +1316,8 @@ Status scanPackagesDirAndActivate(const char* apex_package_dir) {
const auto& packages_with_code = GetActivePackagesMap();
std::vector<std::string> failed_pkgs;
+ size_t activated_cnt = 0;
+ size_t skipped_cnt = 0;
for (const std::string& name : *scan) {
LOG(INFO) << "Found " << name;
@@ -1328,6 +1336,14 @@ Status scanPackagesDirAndActivate(const char* apex_package_dir) {
LOG(INFO) << "Skipping activation of " << name
<< " same package with higher version " << it->second
<< " is already active";
+ skipped_cnt++;
+ continue;
+ }
+
+ if (!kUpdatable && !apex_file->IsFlattened()) {
+ LOG(INFO) << "Skipping activation of non-flattened apex package " << name
+ << " because device doesn't support it";
+ skipped_cnt++;
continue;
}
@@ -1336,6 +1352,8 @@ Status scanPackagesDirAndActivate(const char* apex_package_dir) {
LOG(ERROR) << "Failed to activate " << name << " : "
<< res.ErrorMessage();
failed_pkgs.push_back(name);
+ } else {
+ activated_cnt++;
}
}
@@ -1345,7 +1363,8 @@ Status scanPackagesDirAndActivate(const char* apex_package_dir) {
<< Join(failed_pkgs, ','));
}
- LOG(INFO) << "Activated " << scan->size() << " packages";
+ LOG(INFO) << "Activated " << activated_cnt
+ << " packages. Skipped: " << skipped_cnt;
return Status::Success();
}