Loading cmds/idmap2/idmap2/CommandUtils.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ using android::idmap2::Result; using android::idmap2::Unit; Result<Unit> Verify(const std::string& idmap_path, const std::string& target_path, const std::string& overlay_path, uint32_t fulfilled_policies, const std::string& overlay_path, PolicyBitmask fulfilled_policies, bool enforce_overlayable) { SYSTRACE << "Verify " << idmap_path; std::ifstream fin(idmap_path); Loading cmds/idmap2/idmap2/CommandUtils.h +2 −1 Original line number Diff line number Diff line Loading @@ -17,12 +17,13 @@ #ifndef IDMAP2_IDMAP2_COMMAND_UTILS_H_ #define IDMAP2_IDMAP2_COMMAND_UTILS_H_ #include "idmap2/PolicyUtils.h" #include "idmap2/Result.h" android::idmap2::Result<android::idmap2::Unit> Verify(const std::string& idmap_path, const std::string& target_path, const std::string& overlay_path, uint32_t fulfilled_policies, PolicyBitmask fulfilled_policies, bool enforce_overlayable); #endif // IDMAP2_IDMAP2_COMMAND_UTILS_H_ cmds/idmap2/idmap2d/Idmap2Service.cpp +7 −9 Original line number Diff line number Diff line Loading @@ -70,12 +70,12 @@ PolicyBitmask ConvertAidlArgToPolicyBitmask(int32_t arg) { } Status GetCrc(const std::string& apk_path, uint32_t* out_crc) { const auto overlay_zip = ZipFile::Open(apk_path); if (!overlay_zip) { const auto zip = ZipFile::Open(apk_path); if (!zip) { return error(StringPrintf("failed to open apk %s", apk_path.c_str())); } const auto crc = GetPackageCrc(*overlay_zip); const auto crc = GetPackageCrc(*zip); if (!crc) { return error(crc.GetErrorMessage()); } Loading Loading @@ -121,6 +121,7 @@ Status Idmap2Service::verifyIdmap(const std::string& target_apk_path, bool* _aidl_return) { SYSTRACE << "Idmap2Service::verifyIdmap " << overlay_apk_path; assert(_aidl_return); const std::string idmap_path = Idmap::CanonicalIdmapPathFor(kIdmapCacheDir, overlay_apk_path); std::ifstream fin(idmap_path); const std::unique_ptr<const IdmapHeader> header = IdmapHeader::FromBinaryStream(fin); Loading Loading @@ -156,13 +157,10 @@ Status Idmap2Service::verifyIdmap(const std::string& target_apk_path, auto up_to_date = header->IsUpToDate(target_apk_path.c_str(), overlay_apk_path.c_str(), target_crc, overlay_crc, fulfilled_policies, enforce_overlayable); if (!up_to_date) { *_aidl_return = false; return error(up_to_date.GetErrorMessage()); } ConvertAidlArgToPolicyBitmask(fulfilled_policies), enforce_overlayable); return ok(); *_aidl_return = static_cast<bool>(up_to_date); return *_aidl_return ? ok() : error(up_to_date.GetErrorMessage()); } Status Idmap2Service::createIdmap(const std::string& target_apk_path, Loading cmds/idmap2/include/idmap2/Idmap.h +2 −2 Original line number Diff line number Diff line Loading @@ -141,9 +141,9 @@ class IdmapHeader { // field *must* be incremented. Because of this, we know that if the idmap // header is up-to-date the entire file is up-to-date. Result<Unit> IsUpToDate(const char* target_path, const char* overlay_path, uint32_t fulfilled_policies, bool enforce_overlayable) const; PolicyBitmask fulfilled_policies, bool enforce_overlayable) const; Result<Unit> IsUpToDate(const char* target_path, const char* overlay_path, uint32_t target_crc, uint32_t overlay_crc, uint32_t fulfilled_policies, uint32_t overlay_crc, PolicyBitmask fulfilled_policies, bool enforce_overlayable) const; void accept(Visitor* v) const; Loading cmds/idmap2/libidmap2/Idmap.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -115,8 +115,7 @@ std::unique_ptr<const IdmapHeader> IdmapHeader::FromBinaryStream(std::istream& s uint8_t enforce_overlayable; if (!Read32(stream, &idmap_header->magic_) || !Read32(stream, &idmap_header->version_) || !Read32(stream, &idmap_header->target_crc_) || !Read32(stream, &idmap_header->overlay_crc_) || !Read32(stream, &idmap_header->fulfilled_policies_) || !Read8(stream, &enforce_overlayable) || !Read32(stream, &idmap_header->fulfilled_policies_) || !Read8(stream, &enforce_overlayable) || !ReadString256(stream, idmap_header->target_path_) || !ReadString256(stream, idmap_header->overlay_path_)) { return nullptr; Loading @@ -134,7 +133,8 @@ std::unique_ptr<const IdmapHeader> IdmapHeader::FromBinaryStream(std::istream& s } Result<Unit> IdmapHeader::IsUpToDate(const char* target_path, const char* overlay_path, uint32_t fulfilled_policies, bool enforce_overlayable) const { PolicyBitmask fulfilled_policies, bool enforce_overlayable) const { const std::unique_ptr<const ZipFile> target_zip = ZipFile::Open(target_path); if (!target_zip) { return Error("failed to open target %s", target_path); Loading @@ -161,7 +161,8 @@ Result<Unit> IdmapHeader::IsUpToDate(const char* target_path, const char* overla Result<Unit> IdmapHeader::IsUpToDate(const char* target_path, const char* overlay_path, uint32_t target_crc, uint32_t overlay_crc, uint32_t fulfilled_policies, bool enforce_overlayable) const { PolicyBitmask fulfilled_policies, bool enforce_overlayable) const { if (magic_ != kIdmapMagic) { return Error("bad magic: actual 0x%08x, expected 0x%08x", magic_, kIdmapMagic); } Loading @@ -187,8 +188,7 @@ Result<Unit> IdmapHeader::IsUpToDate(const char* target_path, const char* overla if (enforce_overlayable != enforce_overlayable_) { return Error("bad enforce overlayable: idmap version %s, file system version %s", enforce_overlayable ? "true" : "false", enforce_overlayable_ ? "true" : "false"); enforce_overlayable ? "true" : "false", enforce_overlayable_ ? "true" : "false"); } if (strcmp(target_path, target_path_) != 0) { Loading Loading
cmds/idmap2/idmap2/CommandUtils.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ using android::idmap2::Result; using android::idmap2::Unit; Result<Unit> Verify(const std::string& idmap_path, const std::string& target_path, const std::string& overlay_path, uint32_t fulfilled_policies, const std::string& overlay_path, PolicyBitmask fulfilled_policies, bool enforce_overlayable) { SYSTRACE << "Verify " << idmap_path; std::ifstream fin(idmap_path); Loading
cmds/idmap2/idmap2/CommandUtils.h +2 −1 Original line number Diff line number Diff line Loading @@ -17,12 +17,13 @@ #ifndef IDMAP2_IDMAP2_COMMAND_UTILS_H_ #define IDMAP2_IDMAP2_COMMAND_UTILS_H_ #include "idmap2/PolicyUtils.h" #include "idmap2/Result.h" android::idmap2::Result<android::idmap2::Unit> Verify(const std::string& idmap_path, const std::string& target_path, const std::string& overlay_path, uint32_t fulfilled_policies, PolicyBitmask fulfilled_policies, bool enforce_overlayable); #endif // IDMAP2_IDMAP2_COMMAND_UTILS_H_
cmds/idmap2/idmap2d/Idmap2Service.cpp +7 −9 Original line number Diff line number Diff line Loading @@ -70,12 +70,12 @@ PolicyBitmask ConvertAidlArgToPolicyBitmask(int32_t arg) { } Status GetCrc(const std::string& apk_path, uint32_t* out_crc) { const auto overlay_zip = ZipFile::Open(apk_path); if (!overlay_zip) { const auto zip = ZipFile::Open(apk_path); if (!zip) { return error(StringPrintf("failed to open apk %s", apk_path.c_str())); } const auto crc = GetPackageCrc(*overlay_zip); const auto crc = GetPackageCrc(*zip); if (!crc) { return error(crc.GetErrorMessage()); } Loading Loading @@ -121,6 +121,7 @@ Status Idmap2Service::verifyIdmap(const std::string& target_apk_path, bool* _aidl_return) { SYSTRACE << "Idmap2Service::verifyIdmap " << overlay_apk_path; assert(_aidl_return); const std::string idmap_path = Idmap::CanonicalIdmapPathFor(kIdmapCacheDir, overlay_apk_path); std::ifstream fin(idmap_path); const std::unique_ptr<const IdmapHeader> header = IdmapHeader::FromBinaryStream(fin); Loading Loading @@ -156,13 +157,10 @@ Status Idmap2Service::verifyIdmap(const std::string& target_apk_path, auto up_to_date = header->IsUpToDate(target_apk_path.c_str(), overlay_apk_path.c_str(), target_crc, overlay_crc, fulfilled_policies, enforce_overlayable); if (!up_to_date) { *_aidl_return = false; return error(up_to_date.GetErrorMessage()); } ConvertAidlArgToPolicyBitmask(fulfilled_policies), enforce_overlayable); return ok(); *_aidl_return = static_cast<bool>(up_to_date); return *_aidl_return ? ok() : error(up_to_date.GetErrorMessage()); } Status Idmap2Service::createIdmap(const std::string& target_apk_path, Loading
cmds/idmap2/include/idmap2/Idmap.h +2 −2 Original line number Diff line number Diff line Loading @@ -141,9 +141,9 @@ class IdmapHeader { // field *must* be incremented. Because of this, we know that if the idmap // header is up-to-date the entire file is up-to-date. Result<Unit> IsUpToDate(const char* target_path, const char* overlay_path, uint32_t fulfilled_policies, bool enforce_overlayable) const; PolicyBitmask fulfilled_policies, bool enforce_overlayable) const; Result<Unit> IsUpToDate(const char* target_path, const char* overlay_path, uint32_t target_crc, uint32_t overlay_crc, uint32_t fulfilled_policies, uint32_t overlay_crc, PolicyBitmask fulfilled_policies, bool enforce_overlayable) const; void accept(Visitor* v) const; Loading
cmds/idmap2/libidmap2/Idmap.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -115,8 +115,7 @@ std::unique_ptr<const IdmapHeader> IdmapHeader::FromBinaryStream(std::istream& s uint8_t enforce_overlayable; if (!Read32(stream, &idmap_header->magic_) || !Read32(stream, &idmap_header->version_) || !Read32(stream, &idmap_header->target_crc_) || !Read32(stream, &idmap_header->overlay_crc_) || !Read32(stream, &idmap_header->fulfilled_policies_) || !Read8(stream, &enforce_overlayable) || !Read32(stream, &idmap_header->fulfilled_policies_) || !Read8(stream, &enforce_overlayable) || !ReadString256(stream, idmap_header->target_path_) || !ReadString256(stream, idmap_header->overlay_path_)) { return nullptr; Loading @@ -134,7 +133,8 @@ std::unique_ptr<const IdmapHeader> IdmapHeader::FromBinaryStream(std::istream& s } Result<Unit> IdmapHeader::IsUpToDate(const char* target_path, const char* overlay_path, uint32_t fulfilled_policies, bool enforce_overlayable) const { PolicyBitmask fulfilled_policies, bool enforce_overlayable) const { const std::unique_ptr<const ZipFile> target_zip = ZipFile::Open(target_path); if (!target_zip) { return Error("failed to open target %s", target_path); Loading @@ -161,7 +161,8 @@ Result<Unit> IdmapHeader::IsUpToDate(const char* target_path, const char* overla Result<Unit> IdmapHeader::IsUpToDate(const char* target_path, const char* overlay_path, uint32_t target_crc, uint32_t overlay_crc, uint32_t fulfilled_policies, bool enforce_overlayable) const { PolicyBitmask fulfilled_policies, bool enforce_overlayable) const { if (magic_ != kIdmapMagic) { return Error("bad magic: actual 0x%08x, expected 0x%08x", magic_, kIdmapMagic); } Loading @@ -187,8 +188,7 @@ Result<Unit> IdmapHeader::IsUpToDate(const char* target_path, const char* overla if (enforce_overlayable != enforce_overlayable_) { return Error("bad enforce overlayable: idmap version %s, file system version %s", enforce_overlayable ? "true" : "false", enforce_overlayable_ ? "true" : "false"); enforce_overlayable ? "true" : "false", enforce_overlayable_ ? "true" : "false"); } if (strcmp(target_path, target_path_) != 0) { Loading