00ceae58ffde50c9318d91e27620772ce97a0c48
[platform/core/appfw/app-installers.git] / src / common / step / security / step_rollback_installation_security.cc
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.
4
5 #include "common/step/security/step_rollback_installation_security.h"
6
7 #include <boost/filesystem.hpp>
8 #include <string>
9
10 #include "common/security_registration.h"
11
12 namespace common_installer {
13 namespace security {
14
15 Step::Status StepRollbackInstallationSecurity::precheck() {
16   if (context_->pkgid.get().empty()) {
17     LOG(ERROR) << "pkgid attribute is empty";
18     return Step::Status::PACKAGE_NOT_FOUND;
19   }
20   if (!context_->manifest_data.get()) {
21     LOG(ERROR) << "manifest_data attribute is empty";
22     return Step::Status::MANIFEST_NOT_FOUND;
23   }
24
25   return Step::Status::OK;
26 }
27
28 Step::Status StepRollbackInstallationSecurity::undo() {
29   std::string error_message;
30   if (!UnregisterSecurityContextForManifest(
31       context_->pkgid.get(), context_->pkg_type.get(), context_->uid.get(),
32       context_->manifest_data.get(), &error_message)) {
33     if (!error_message.empty()) {
34       LOG(ERROR) << "error_message: " << error_message;
35     }
36     return Status::SECURITY_ERROR;
37   }
38   LOG(DEBUG) << "Security context uninstalled";
39   return Status::OK;
40 }
41
42 }  // namespace security
43 }  // namespace common_installer