return installed_location;
}
+std::string QueryMainappIdForPkgId(const std::string& pkg_id, uid_t uid) {
+ pkgmgrinfo_pkginfo_h package_info;
+ if (pkgmgrinfo_pkginfo_get_usr_all_pkginfo(pkg_id.c_str(), uid, &package_info)
+ != PMINFO_R_OK)
+ return {};
+
+ char* mainapp_id = nullptr;
+ bool ret = pkgmgrinfo_pkginfo_get_mainappid(package_info,
+ &mainapp_id) == PMINFO_R_OK;
+ std::string mainapp_id_value;
+ if (mainapp_id)
+ mainapp_id_value = mainapp_id;
+ pkgmgrinfo_pkginfo_destroy_pkginfo(package_info);
+ return mainapp_id_value;
+}
+
bool QueryIsPackageInstalled(const std::string& pkg_id,
RequestMode request_mode, uid_t uid) {
pkgmgrinfo_pkginfo_h handle;
*/
std::string QueryStorageForPkgId(const std::string& pkg_id, uid_t uid);
+/**
+ * \brief Adapter interface for external PkgMgr module used for getting
+ * storage for given package
+ *
+ * \param pkg_id id of package
+ * \param uid user id
+ *
+ * \return mainapp_id of empty if not installed
+ */
+std::string QueryMainappIdForPkgId(const std::string& pkg_id, uid_t uid);
+
/**
* \brief Adapter interface for external PkgMgr module used for checking
* if given package is installed/registered
namespace common_installer {
+bool RegisterSecurityContext(const std::string& app_id,
+ const std::string& pkg_id, const std::string& author_id,
+ const std::string& api_version, const boost::filesystem::path& path,
+ uid_t uid, const std::vector<std::string>& privileges,
+ bool cross_app_rules, std::string* error_message);
+
/**
* Adapter interface for external Security module.
*
bf::path package_directory =
context_->root_application_path.get() / context_->pkgid.get();
context_->pkg_path.set(package_directory);
+ context_->unpacked_dir_path.set(package_directory);
break;
}
default:
}
std::string error_message;
+ if (context_->pkg_type.get() == "wgt") {
+ std::string mainapp_id = QueryMainappIdForPkgId(pkgid, uid);
+ if (mainapp_id.empty())
+ mainapp_id = pkgid;
+ // This is for 2.4 -> 3.0 migration, we cannot access manifest at this time,
+ // because of legacy smack label. We need to register security context first
+ // to label files in external image.
+ if (!RegisterSecurityContext(mainapp_id, pkgid, {}, "3.0",
+ context_->pkg_path.get(), uid, {}, false, &error_message)) {
+ LOG(ERROR) << "error_message: " << error_message;
+ on_error(Status::SECURITY_ERROR, error_message);
+ }
+ }
+
if (!RegisterSecurityContextForPathExternalOnly(pkgid,
context_->pkg_type.get(), context_->pkg_path.get(),
uid, &error_message)) {
}
LOG(DEBUG) << "Security context installed";
+
return Status::OK;
}