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_rollback_deinstallation_security.h"
9 #include "common/security_registration.h"
11 namespace common_installer {
14 Step::Status StepRollbackDeinstallationSecurity::precheck() {
15 if (context_->pkgid.get().empty()) {
16 LOG(ERROR) << "pkgid attribute is empty";
17 return Step::Status::PACKAGE_NOT_FOUND;
19 if (!context_->manifest_data.get()) {
20 LOG(ERROR) << "manifest_data attribute is empty";
21 return Step::Status::MANIFEST_NOT_FOUND;
24 return Step::Status::OK;
27 Step::Status StepRollbackDeinstallationSecurity::undo() {
28 std::string error_message;
29 if (!RegisterSecurityContextForManifest(context_, &error_message)) {
30 LOG(ERROR) << "Failure on re-installing security context for app "
31 << context_->pkgid.get();
32 if (!error_message.empty()) {
33 LOG(ERROR) << "error_message: " << error_message;
35 return Status::SECURITY_ERROR;
37 if (!RegisterSecurityContextForPath(context_->pkgid.get(),
38 context_->pkg_type.get(), context_->GetPkgPath(), context_->uid.get(),
39 context_->is_readonly_package.get(), &error_message)) {
40 if (!error_message.empty()) {
41 LOG(ERROR) << "error_message: " << error_message;
42 on_error_->on_error(Status::SECURITY_ERROR, error_message);
44 return Status::SECURITY_ERROR;
46 LOG(DEBUG) << "Security context installed";
50 } // namespace security
51 } // namespace common_installer