namespace common_installer {
-bool CheckPkgCertificateMismatch(const std::string& pkgid,
- const std::string& certificate) {
- bool certificate_mismatch = false;
- uid_t uid = G_MAXUINT;
- auto old_certificate = ci::QueryCertificateAuthorCertificate(pkgid, uid);
-
- if (!old_certificate.empty()) {
- bool is_same = ci::IsSameAuthor(old_certificate, certificate);
- certificate_mismatch = !is_same;
- }
- return certificate_mismatch;
-}
-
-bool Signature::CheckSignatureMismatch(std::string* error_message) {
- const auto& cert = cert_info_->auth_cert.get();
- if (cert) {
- bool certificate_mismatch =
- CheckPkgCertificateMismatch(pkgid_, cert->getBase64());
- if (certificate_mismatch) {
- *error_message =
- "Package with the same id and different certificate "
- "has been already installed";
- return false;
- }
- }
- return true;
-}
-
bool Signature::SetPath() {
bf::path path = bf::path((is_readonly_package_) ?
tzplatform_getenv(TZ_SYS_RO_SHARE) : tzplatform_getenv(TZ_SYS_SHARE)) /
if (!CheckSignatures(check_reference, level, sig_root_path, error_message))
return false;
- if (!CheckSignatureMismatch(error_message))
- return false;
-
if (*level == PrivilegeLevel::UNTRUSTED)
if (!GetSignatureFromFile(pkgid_, is_readonly_package_, level, cert_info_))
LOG(INFO) << "Unable to get privilege level from file";