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"
7 #include <boost/filesystem.hpp>
10 #include "common/security_registration.h"
12 namespace common_installer {
15 Step::Status StepRollbackDeinstallationSecurity::precheck() {
16 if (context_->pkgid.get().empty()) {
17 LOG(ERROR) << "pkgid attribute is empty";
18 return Step::Status::PACKAGE_NOT_FOUND;
20 if (!context_->manifest_data.get()) {
21 LOG(ERROR) << "manifest_data attribute is empty";
22 return Step::Status::MANIFEST_NOT_FOUND;
25 return Step::Status::OK;
28 Step::Status StepRollbackDeinstallationSecurity::undo() {
29 std::string error_message;
30 if (!RegisterSecurityContextForManifest(context_, &error_message)) {
31 LOG(ERROR) << "Failure on re-installing security context for app "
32 << context_->pkgid.get();
33 if (!error_message.empty()) {
34 LOG(ERROR) << "error_message: " << error_message;
36 return Status::SECURITY_ERROR;
38 if (!RegisterSecurityContextForPath(
39 context_->pkgid.get(), context_->GetPkgPath(), context_->uid.get(),
40 context_->is_readonly_package.get(), &error_message)) {
41 if (!error_message.empty()) {
42 LOG(ERROR) << "error_message: " << error_message;
43 on_error(Status::SECURITY_ERROR, error_message);
45 return Status::SECURITY_ERROR;
47 LOG(DEBUG) << "Security context installed";
51 } // namespace security
52 } // namespace common_installer