1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
5 #include "common/step/security/step_recover_security.h"
7 #include <boost/filesystem.hpp>
10 #include "common/security_registration.h"
12 namespace common_installer {
15 bool StepRecoverSecurity::Check() {
16 if (context_->pkg_path.get().empty())
18 if (!boost::filesystem::exists(context_->pkg_path.get()))
20 if (context_->pkgid.get().empty())
22 if (!context_->manifest_data.get())
27 Step::Status StepRecoverSecurity::RecoveryNew() {
30 std::string error_message;
31 if (!UnregisterSecurityContextForManifest(
32 context_->pkgid.get(), context_->uid.get(),
33 context_->manifest_data.get(), &error_message)) {
34 LOG(ERROR) << "Unsuccessful install";
35 if (!error_message.empty()) {
36 LOG(ERROR) << "error_message: " << error_message;
37 on_error(Status::RECOVERY_ERROR, error_message);
39 return Status::RECOVERY_ERROR;
44 Step::Status StepRecoverSecurity::RecoveryUpdate() {
46 LOG(ERROR) << "Invalid parameters";
47 return Status::INVALID_VALUE;
49 std::string error_message;
50 if (!RegisterSecurityContextForManifest(
51 context_->pkgid.get(), context_->pkg_path.get(), context_->uid.get(),
52 &context_->certificate_info.get(), context_->manifest_data.get(),
53 context_->cross_app_rules.get(), &error_message)) {
54 LOG(ERROR) << "Unsuccessful update";
55 if (!error_message.empty()) {
56 LOG(ERROR) << "error_message: " << error_message;
57 on_error(Status::RECOVERY_ERROR, error_message);
59 return Status::RECOVERY_ERROR;
61 if (!RegisterSecurityContextForPath(
62 context_->pkgid.get(), context_->pkg_path.get(), context_->uid.get(),
64 if (!error_message.empty()) {
65 LOG(ERROR) << "error_message: " << error_message;
66 on_error(Status::SECURITY_ERROR, error_message);
68 return Status::RECOVERY_ERROR;
72 } // namespace security
73 } // namespace common_installer