diff options
author | Ryan Mitchell <rtmitchell@google.com> | 2020-02-21 15:52:57 -0800 |
---|---|---|
committer | Ryan Mitchell <rtmitchell@google.com> | 2020-02-26 00:53:13 +0000 |
commit | 625ebd3911b82a5af4861fae5f8ee139f7d94589 (patch) | |
tree | 7c0b2fd88808f5ef073baa39a3166f77906e486f /cmds/idmap2 | |
parent | 3df3b53b8bc7e5b96a776c1ec26dceef9806cfed (diff) |
Call verify in create-multiple
Idmap Scan previously called Verify before calling Create. OverlayConfig
should do the same. Removing the verify call caused b/149784008.
Since sSystem is marked @UnsupportedAppUsage,
createSystemAssetsInZygoteLocked could potentially be invoked in the
system server. Rather than attempting to create the overlays a second
time, first check whether the idmap must be invalidated.
Bug: 149784008
Test: running forrest using web UI
Change-Id: I5d995a87e8552bd156fb5415b2c46a08f4c1d6c5
Diffstat (limited to 'cmds/idmap2')
-rw-r--r-- | cmds/idmap2/idmap2/CreateMultiple.cpp | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/cmds/idmap2/idmap2/CreateMultiple.cpp b/cmds/idmap2/idmap2/CreateMultiple.cpp index 0b0541fb6221..d4e888fd3119 100644 --- a/cmds/idmap2/idmap2/CreateMultiple.cpp +++ b/cmds/idmap2/idmap2/CreateMultiple.cpp @@ -31,6 +31,7 @@ #include "idmap2/Idmap.h" #include "idmap2/Policies.h" #include "idmap2/SysTrace.h" +#include "Commands.h" using android::ApkAssets; using android::base::StringPrintf; @@ -105,32 +106,34 @@ Result<Unit> CreateMultiple(const std::vector<std::string>& args) { continue; } - const std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path); - if (!overlay_apk) { - LOG(WARNING) << "failed to load apk " << overlay_apk_path.c_str(); - continue; - } - - const auto idmap = - Idmap::FromApkAssets(*target_apk, *overlay_apk, fulfilled_policies, !ignore_overlayable); - if (!idmap) { - LOG(WARNING) << "failed to create idmap"; - continue; - } - - umask(kIdmapFilePermissionMask); - std::ofstream fout(idmap_path); - if (fout.fail()) { - LOG(WARNING) << "failed to open idmap path " << idmap_path.c_str(); - continue; - } - - BinaryStreamVisitor visitor(fout); - (*idmap)->accept(&visitor); - fout.close(); - if (fout.fail()) { - LOG(WARNING) << "failed to write to idmap path %s" << idmap_path.c_str(); - continue; + if (!Verify(std::vector<std::string>({"--idmap-path", idmap_path}))) { + const std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path); + if (!overlay_apk) { + LOG(WARNING) << "failed to load apk " << overlay_apk_path.c_str(); + continue; + } + + const auto idmap = + Idmap::FromApkAssets(*target_apk, *overlay_apk, fulfilled_policies, !ignore_overlayable); + if (!idmap) { + LOG(WARNING) << "failed to create idmap"; + continue; + } + + umask(kIdmapFilePermissionMask); + std::ofstream fout(idmap_path); + if (fout.fail()) { + LOG(WARNING) << "failed to open idmap path " << idmap_path.c_str(); + continue; + } + + BinaryStreamVisitor visitor(fout); + (*idmap)->accept(&visitor); + fout.close(); + if (fout.fail()) { + LOG(WARNING) << "failed to write to idmap path %s" << idmap_path.c_str(); + continue; + } } idmap_paths.emplace_back(idmap_path); |