bool IsValid() const {
return req_ != NULL;
}
- bool PrepareBasic(const std::string& pkg_id, uid_t uid) {
- if (pkg_id.empty()) {
- LOG(ERROR) << "Pkgid is empty";
+ bool PrepareBasic(const std::string& pkg_id, uid_t uid,
+ const std::string& type = "" ) {
+ if (pkg_id.empty() || type.empty()) {
+ LOG(ERROR) << "Invalid parameter";
return false;
}
int error = security_manager_app_inst_req_set_pkg_id(req_, pkg_id.c_str());
SetErrorMessage(&error_message_, error);
return false;
}
+
+ pkg_type pkgtype = SM_PKG_TYPE_NONE;
+ if (type == "tpk")
+ pkgtype = SM_PKG_TYPE_CORE;
+ else if (type == "wgt")
+ pkgtype = SM_PKG_TYPE_WRT;
+
+ error = security_manager_app_inst_req_set_pkg_type(req_, pkgtype);
+ if (error != SECURITY_MANAGER_SUCCESS) {
+ SetErrorMessage(&error_message_, error);
+ return false;
+ }
return true;
}
return true;
}
+ bool PreparePrivilegeLevel(ci::PrivilegeLevel priv_level) {
+ pkg_privilege_level level = (pkg_privilege_level)priv_level;
+ int error = security_manager_app_inst_req_set_pkg_privilege_level(
+ req_, level);
+ if (error != SECURITY_MANAGER_SUCCESS) {
+ SetErrorMessage(&error_message_, error);
+ return false;
+ }
+ return true;
+ }
+
bool PrepareAppWithPrivileges(const std::string& app_id,
const std::vector<std::string>& privileges,
const AppDefinedPrivInfo& appdef_privileges,
}
}
-bool RegisterSecurityContextForManifest(
- const std::string& pkg_id, const boost::filesystem::path& path, uid_t uid,
- common_installer::CertificateInfo* cert_info, manifest_x* manifest,
- bool cross_app_rules, std::string* error_message) {
+bool RegisterSecurityContextForManifest(const ci::InstallerContext* context,
+ std::string* error_message) {
+ std::string pkg_id = context->pkgid.get();
+ std::string pkg_type = context->pkg_type.get();
+ bf::path path = context->GetPkgPath();
+ uid_t uid = context->uid.get();
+ const ci::CertificateInfo* cert_info = &(context->certificate_info.get());
+ manifest_x* manifest = context->manifest_data.get();
+ bool cross_app_rules = context->cross_app_rules.get();
+
// Although application framework hold list of privilege per package, there
// is situation where we need to filter privileges. This data model doesn't
// cover hybrid apps well where native privileges should be granted only to
*error_message = req.ErrorMessage();
return false;
}
- if (!req.PrepareBasic(pkg_id, uid)) {
+ if (!req.PrepareBasic(pkg_id, uid, pkg_type)) {
*error_message = req.ErrorMessage();
return false;
}
return false;
}
+ if (!req.PreparePrivilegeLevel(context->privilege_level.get())) {
+ *error_message = req.ErrorMessage();
+ return false;
+ }
+
for (application_x* app : GListRange<application_x*>(manifest->application)) {
if (!app->appid) {
return false;
* Adapter interface for external Security module used for registering
* package to security context
*
- * \param pkg_id pkgid of given package
- * \param path path of installed package
- * \param uid uid
- * \param cert_info pointer to certificate info
- * \param manifest pointer to manifest structure
- * \param cross_app_rules true if n-to-n smack rules should be generated
- * apps (should be set for hybrid applications).
+ * \param context installer context contains necessary information
* \param error_message extra/detailed error message
*
* \return true if success
*/
-bool RegisterSecurityContextForManifest(const std::string& pkg_id,
- const boost::filesystem::path& path, uid_t uid,
- common_installer::CertificateInfo* cert_info, manifest_x* manifest,
- bool cross_app_rules, std::string* error_message);
+bool RegisterSecurityContextForManifest(
+ const common_installer::InstallerContext* context,
+ std::string* error_message);
/**
* Adapter interface for external Security module.
return Status::INVALID_VALUE;
}
std::string error_message;
- if (!RegisterSecurityContextForManifest(
- context_->pkgid.get(), context_->GetPkgPath(), context_->uid.get(),
- &context_->certificate_info.get(), context_->manifest_data.get(),
- context_->cross_app_rules.get(), &error_message)) {
+ if (!RegisterSecurityContextForManifest(context_, &error_message)) {
LOG(ERROR) << "Unsuccessful update";
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
return Status::INVALID_VALUE;
}
std::string error_message;
- if (!RegisterSecurityContextForManifest(
- context_->pkgid.get(), context_->GetPkgPath(), context_->uid.get(),
- &context_->certificate_info.get(), context_->manifest_data.get(),
- context_->cross_app_rules.get(), &error_message)) {
+ if (!RegisterSecurityContextForManifest(context_, &error_message)) {
LOG(ERROR) << "Unsuccessful update";
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
Step::Status StepRegisterSecurity::process() {
std::string error_message;
if (context_->request_type.get() != RequestType::Move &&
- !RegisterSecurityContextForManifest(
- context_->pkgid.get(), context_->GetPkgPath(), context_->uid.get(),
- &context_->certificate_info.get(), context_->manifest_data.get(),
- context_->cross_app_rules.get(), &error_message)) {
+ !RegisterSecurityContextForManifest(context_, &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
on_error(Status::SECURITY_ERROR, error_message);
Step::Status StepRollbackDeinstallationSecurity::undo() {
std::string error_message;
- if (!RegisterSecurityContextForManifest(
- context_->pkgid.get(), context_->GetPkgPath(), context_->uid.get(),
- &context_->certificate_info.get(), context_->manifest_data.get(),
- context_->cross_app_rules.get(), &error_message)) {
+ if (!RegisterSecurityContextForManifest(context_, &error_message)) {
LOG(ERROR) << "Failure on re-installing security context for app "
<< context_->pkgid.get();
if (!error_message.empty()) {
Step::Status StepUpdateSecurity::process() {
std::string error_message;
- if (!RegisterSecurityContextForManifest(
- context_->pkgid.get(), context_->GetPkgPath(), context_->uid.get(),
- &context_->certificate_info.get(), context_->manifest_data.get(),
- context_->cross_app_rules.get(), &error_message)) {
+ if (!RegisterSecurityContextForManifest(context_, &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
on_error(Status::SECURITY_ERROR, error_message);
Step::Status StepUpdateSecurity::undo() {
std::string error_message;
- if (!RegisterSecurityContextForManifest(
- context_->pkgid.get(), context_->GetPkgPath(), context_->uid.get(),
- &context_->certificate_info.get(), context_->old_manifest_data.get(),
- context_->cross_app_rules.get(), &error_message)) {
+ if (!RegisterSecurityContextForManifest(context_, &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
}