Fix Mount Installation Failure 40/124240/1
authorjongmyeongko <jongmyeong.ko@samsung.com>
Sat, 8 Apr 2017 06:40:16 +0000 (15:40 +0900)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Tue, 11 Apr 2017 02:12:50 +0000 (19:12 -0700)
Fix side-effect from previous change related to symlink files

Submit with :
[tpk-backend] https://review.tizen.org/gerrit/#/c/123948/
[wgt-backend] https://review.tizen.org/gerrit/#/c/123949/

Change-Id: I7e39ac91c7fd17f1fcad9b4c134e19d636146f8b
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
(cherry picked from commit 0405750ddb8837f86c5cce017af0e463b2c6592f)

src/common/step/filesystem/step_change_ownership_and_permission.cc
src/common/step/filesystem/step_change_ownership_and_permission.h

index c739ff3..19e2bf8 100644 (file)
@@ -88,7 +88,7 @@ bool ChangeDataDir(const bf::path& pkg_path, uid_t uid) {
   return true;
 }
 
-bool GrantDefaultPermissions(bf::path pkg_path) {
+bool GrantDefaultPermissions(bf::path pkg_path, bool skip_symlink) {
   if (bf::is_directory(pkg_path)) {
     if (!GrantPermission755(pkg_path))
       return false;
@@ -97,6 +97,9 @@ bool GrantDefaultPermissions(bf::path pkg_path) {
       boost::make_iterator_range(bf::directory_iterator(pkg_path), {})) {
     auto path = entry.path();
 
+    if (skip_symlink && bf::is_symlink(symlink_status(path)))
+          continue;
+
     // skip path, which is related to mount or directory installer creates
     if (bf::is_directory(path) &&
         (path.filename() == ".mmc" || path.filename() == ".pkg" ||
@@ -158,6 +161,12 @@ bool GrantDefaultPermissions(bf::path pkg_path) {
 namespace common_installer {
 namespace filesystem {
 
+StepChangeOwnershipAndPermission::StepChangeOwnershipAndPermission(
+    InstallerContext* context, bool skip_symlink = false)
+    : Step(context),
+      skip_symlink_(skip_symlink) {
+}
+
 Step::Status StepChangeOwnershipAndPermission::precheck() {
   if (context_->root_application_path.get().empty()) {
     LOG(ERROR) << "root_application_path attribute is empty";
@@ -186,7 +195,7 @@ Step::Status StepChangeOwnershipAndPermission::process() {
     return Status::ERROR;
 
   // Grant default permissions
-  if (!GrantDefaultPermissions(context_->pkg_path.get()))
+  if (!GrantDefaultPermissions(context_->pkg_path.get(), skip_symlink_))
     return Status::GRANT_PERMISSION_ERROR;
 
   // Change owner of files at root path
index 9cb62c7..a7ee504 100644 (file)
@@ -23,10 +23,16 @@ class StepChangeOwnershipAndPermission : public Step {
  public:
   using Step::Step;
 
+  explicit StepChangeOwnershipAndPermission(InstallerContext* context,
+      bool skip_symlink);
+
   Status process() override;
   Status clean() override { return Status::OK; }
   Status undo() override { return Status::OK; }
   Status precheck() override;
+
+  bool skip_symlink_;
+
   STEP_NAME(ChangeOwnershipAndPermission)
 };