diff options
author | Nikita Ioffe <ioffe@google.com> | 2019-02-26 18:47:44 +0000 |
---|---|---|
committer | Nikita Ioffe <ioffe@google.com> | 2019-02-27 10:30:19 +0000 |
commit | 6994eff232e047dd5bcd64f13c387334e57f76f7 (patch) | |
tree | a35c78547093d825cf702ad1aa7857a043083910 | |
parent | 31dc34d5523d925da6f00d95e41f895b5d9e778d (diff) |
apexd: skip staging package if it is already in /data/apex/active
This should prevent following (very unlikely) situation:
1. New staged session is created containing following apexes:
foo@1.apex, bar@2.apex.
2. foo@1.apex is already activated (i.e. /data/apex/active/foo@1.apex exists).
3. stagePackages() fails to link bar@2.apex.
4. Deleter removes /data/apex/active/foo@1.apex
5. Apexd ends up deactivating a package it should've kept.
Test: apexservice_test
Change-Id: Id859d1bbc74664ca3d36bc2a72e829bc2ffff701
-rw-r--r-- | apexd/apexd.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/apexd/apexd.cpp b/apexd/apexd.cpp index 2894fed..16b5034 100644 --- a/apexd/apexd.cpp +++ b/apexd/apexd.cpp @@ -1175,10 +1175,8 @@ Status stagePackages(const std::vector<std::string>& tmpPaths) { std::string dest_path = path_fn(*apex_file); if (access(dest_path.c_str(), F_OK) == 0) { - LOG(DEBUG) << dest_path << " already exists. Unlinking it"; - if (unlink(dest_path.c_str()) != 0) { - return Status::Fail(PStringLog() << "Failed to unlink " << dest_path); - } + LOG(DEBUG) << dest_path << " already exists. Skipping"; + continue; } if (link(apex_file->GetPath().c_str(), dest_path.c_str()) != 0) { // TODO: Get correct binder error status. |