Fix privileges of globally installed applications 90/53490/5
authorArkadiusz Szulakiewicz <a.szulakiewi@partner.samsung.com>
Mon, 7 Dec 2015 09:18:04 +0000 (10:18 +0100)
committerPawel Sikorski <p.sikorski@samsung.com>
Tue, 8 Dec 2015 15:18:26 +0000 (07:18 -0800)
Change-Id: I44076b5defdd60899352046d9e990b5ea9f4a14a

src/common/step/step_copy.cc
src/common/step/step_generate_xml.cc
src/common/step/step_unzip.cc
src/common/utils/file_util.cc
src/tpk/step/step_create_symbolic_link.cc
src/wgt/step/step_create_symbolic_link.cc
src/wgt/step/step_rds_modify.cc

index 5b09a55..39e53fd 100644 (file)
@@ -70,7 +70,8 @@ Step::Status StepCopy::process() {
     return Step::Status::ERROR;
   }
   if (!MoveDir(context_->unpacked_dir_path.get(), install_path)) {
-    LOG(ERROR) << "Cannot move widget directory to install path";
+    LOG(ERROR) << "Cannot move widget directory to install path, from "
+        << context_->unpacked_dir_path.get() << " to " << install_path;
     return Status::ERROR;
   }
   LOG(INFO) << "Successfully move: " << context_->unpacked_dir_path.get()
index 60f5f8f..53629d8 100644 (file)
@@ -212,13 +212,6 @@ common_installer::Step::Status StepGenerateXml::process() {
           "Directory for manifest xml is missing and cannot be created";
       return Status::ERROR;
     }
-
-    if (!common_installer::SetDirPermissions(xml_path.parent_path(),
-        bf::owner_all | bf::group_read | bf::others_read)) {
-      LOG(ERROR) <<
-          "Could not set permissions for dir:" << xml_path.parent_path();
-      return Status::ERROR;
-    }
   }
 
   xmlTextWriterPtr writer;
index 1172ce7..62a4bc2 100644 (file)
@@ -92,13 +92,6 @@ Step::Status StepUnzip::process() {
     return Step::Status::ERROR;
   }
 
-  if (!SetDirPermissions(tmp_dir,
-      bf::owner_all | bf::group_read | bf::others_read)) {
-    LOG(ERROR) <<
-        "Could not set permissions for dir:" << tmp_dir;
-    return Status::ERROR;
-  }
-
   int64_t required_size =
       GetUnpackedPackageSize(context_->file_path.get());
 
index 66ff55e..1b97475 100644 (file)
@@ -135,13 +135,6 @@ bool CopyDir(const bf::path& src, const bf::path& dst) {
       LOG(ERROR) << "Unable to create destination directory" << dst.string();
       return false;
     }
-
-    if (!SetDirPermissions(dst,
-                           bf::owner_all | bf::group_read | bf::others_read)) {
-      LOG(ERROR) <<
-          "Could not set permissions for dir:" << dst;
-      return false;
-    }
   } catch (const bf::filesystem_error& error) {
     LOG(ERROR) << "Failed to copy directory: " << error.what();
     return false;
@@ -185,8 +178,11 @@ bool CopyFile(const bf::path& src, const bf::path& dst) {
 }
 
 bool MoveDir(const bf::path& src, const bf::path& dst) {
-  if (bf::exists(dst))
+  if (bf::exists(dst)) {
+    LOG(ERROR) << "Destination directory does not exist: " << dst;
     return false;
+  }
+
   bs::error_code error;
   bf::rename(src, dst, error);
   if (error) {
@@ -350,14 +346,6 @@ bool ExtractToTmpDir(const char* zip_path, const bf::path& tmp_dir,
               << filename_in_zip_path.parent_path();
           return false;
         }
-        if (!SetDirPermissions(
-            filename_in_zip_path.parent_path(),
-            bf::owner_all | bf::group_read | bf::others_read)) {
-          LOG(ERROR) <<
-              "Could not set permissions for dir:" <<
-              filename_in_zip_path.parent_path();
-          return false;
-        }
       }
 
       if (!zip_file.OpenCurrent()) {
index 386a6a4..cb75a75 100644 (file)
@@ -31,12 +31,6 @@ bool CreateSymLink(application_x* app, InstallerContext* context) {
     LOG(ERROR) << "Directory creation failure: " << bindir;
     return false;
   }
-  if (!common_installer::SetDirPermissions(bindir,
-      bf::owner_all | bf::group_read | bf::others_read)) {
-    LOG(ERROR) <<
-        "Could not set permissions for dir:" << bindir;
-    return false;
-  }
 
   // Exec path
   // Make a symlink with the name of appid, pointing exec file
index 77c7733..6d53415 100644 (file)
@@ -39,9 +39,6 @@ common_installer::Step::Status StepCreateSymbolicLink::process() {
             / bf::path("bin");
     common_installer::CreateDir(exec_path);
 
-    common_installer::SetDirPermissions(exec_path,
-        bf::owner_all | bf::group_read | bf::others_read);
-
     exec_path /= bf::path(app->appid);
 
     if (strcmp(app->component_type, "uiapp") == 0) {
index 85273c1..9400bd6 100644 (file)
@@ -93,29 +93,12 @@ bool StepRDSModify::AddFiles(bf::path unzip_path, bf::path install_path) {
         LOG(ERROR) << "unable to create dir for temp backup data";
         return false;
       }
-      if (!cu::SetDirPermissions(temp_install_path,
-          bf::owner_all | bf::group_read | bf::others_read)) {
-        LOG(ERROR) <<
-            "Could not set permissions for dir:" << temp_install_path;
-        return false;
-      }
-
-
     } else {
       if (!bf::exists(temp_install_path.parent_path()) &&
           !cu::CreateDir(temp_install_path.parent_path())) {
         LOG(ERROR) << "unable to create dir for temp backup data";
         return false;
       }
-      if (!cu::SetDirPermissions(temp_install_path.parent_path(),
-          bf::owner_all | bf::group_read | bf::others_read)) {
-        LOG(ERROR) <<
-            "Could not set permissions for dir:"
-            << temp_install_path.parent_path();
-        return false;
-      }
-
-
       bf::path temp_unzip_path(unzip_path / file);
       bf::copy_file(temp_unzip_path, temp_install_path, error);
       if (error) {
@@ -174,14 +157,6 @@ bool StepRDSModify::SetUpTempBackupDir() {
     return false;
   }
 
-  if (!cu::SetDirPermissions(backup_temp_dir_,
-           bf::owner_all | bf::group_read | bf::others_read)) {
-         LOG(ERROR) <<
-             "Could not set permissions for dir:"
-             << backup_temp_dir_;
-         return false;
-       }
-
   return true;
 }
 
@@ -197,14 +172,6 @@ bool StepRDSModify::PerformBackup(std::string relative_path,
         LOG(ERROR) << "unable to create dir for temp backup data";
         return false;
       }
-      if (!cu::SetDirPermissions(backup_temp_dir_ / relative_path,
-          bf::owner_all | bf::group_read | bf::others_read)) {
-        LOG(ERROR)
-            << "Could not set permissions for dir:"
-            << (backup_temp_dir_ / relative_path).string();
-        return false;
-      }
-
     } else {
       bs::error_code error;
       bf::path tmp_dest_path = backup_temp_dir_ / relative_path;
@@ -213,14 +180,6 @@ bool StepRDSModify::PerformBackup(std::string relative_path,
         LOG(ERROR) << "unable to create dir for temp backup data";
         return false;
       }
-
-      if (!cu::SetDirPermissions((tmp_dest_path).parent_path(),
-          bf::owner_all | bf::group_read | bf::others_read)) {
-        LOG(ERROR) << "Could not set permissions for dir:"
-            << (tmp_dest_path).parent_path();
-        return false;
-      }
-
       bf::copy_file(source_path, tmp_dest_path, error);
       if (error) {
         LOG(ERROR) << "unable to backup file: "
@@ -252,8 +211,6 @@ void StepRDSModify::RestoreFiles() {
     } else {
       if (bf::is_directory(source_path)) {
         cu::CreateDir(destination_path);
-        cu::SetDirPermissions(destination_path,
-            bf::owner_all | bf::group_read | bf::others_read);
       } else {
         bf::copy_file(source_path, destination_path,
                       bf::copy_option::overwrite_if_exists);