From 84afae85a82451964363db8f16037abbddc70e0c Mon Sep 17 00:00:00 2001 From: Arkadiusz Szulakiewicz Date: Mon, 7 Dec 2015 10:18:04 +0100 Subject: [PATCH] Fix privileges of globally installed applications Change-Id: I44076b5defdd60899352046d9e990b5ea9f4a14a --- src/common/step/step_copy.cc | 3 ++- src/common/step/step_generate_xml.cc | 7 ----- src/common/step/step_unzip.cc | 7 ----- src/common/utils/file_util.cc | 20 +++----------- src/tpk/step/step_create_symbolic_link.cc | 6 ----- src/wgt/step/step_create_symbolic_link.cc | 3 --- src/wgt/step/step_rds_modify.cc | 43 ------------------------------- 7 files changed, 6 insertions(+), 83 deletions(-) diff --git a/src/common/step/step_copy.cc b/src/common/step/step_copy.cc index 5b09a55..39e53fd 100644 --- a/src/common/step/step_copy.cc +++ b/src/common/step/step_copy.cc @@ -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() diff --git a/src/common/step/step_generate_xml.cc b/src/common/step/step_generate_xml.cc index 60f5f8f..53629d8 100644 --- a/src/common/step/step_generate_xml.cc +++ b/src/common/step/step_generate_xml.cc @@ -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; diff --git a/src/common/step/step_unzip.cc b/src/common/step/step_unzip.cc index 1172ce7..62a4bc2 100644 --- a/src/common/step/step_unzip.cc +++ b/src/common/step/step_unzip.cc @@ -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()); diff --git a/src/common/utils/file_util.cc b/src/common/utils/file_util.cc index 66ff55e..1b97475 100644 --- a/src/common/utils/file_util.cc +++ b/src/common/utils/file_util.cc @@ -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()) { diff --git a/src/tpk/step/step_create_symbolic_link.cc b/src/tpk/step/step_create_symbolic_link.cc index 386a6a4..cb75a75 100644 --- a/src/tpk/step/step_create_symbolic_link.cc +++ b/src/tpk/step/step_create_symbolic_link.cc @@ -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 diff --git a/src/wgt/step/step_create_symbolic_link.cc b/src/wgt/step/step_create_symbolic_link.cc index 77c7733..6d53415 100644 --- a/src/wgt/step/step_create_symbolic_link.cc +++ b/src/wgt/step/step_create_symbolic_link.cc @@ -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) { diff --git a/src/wgt/step/step_rds_modify.cc b/src/wgt/step/step_rds_modify.cc index 85273c1..9400bd6 100644 --- a/src/wgt/step/step_rds_modify.cc +++ b/src/wgt/step/step_rds_modify.cc @@ -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); -- 2.7.4