Commit 7b6c5d7c authored by Joe Mason's avatar Joe Mason Committed by Commit Bot

Update chrome_Cleaner's zip_archiver subdir to support quarantine feature

Includes a fix to ComputeSHA256DigestOfPath required by the unit test

R=csharp@chromium.org

Bug: 830892
Change-Id: I72e6c1a4fcf21565357e5e6043ee93b480931a4f
Reviewed-on: https://chromium-review.googlesource.com/c/1338659Reviewed-by: default avatarChris Sharp <csharp@chromium.org>
Commit-Queue: Joe Mason <joenotcharles@google.com>
Cr-Commit-Position: refs/heads/master@{#608794}
parent a7702f58
...@@ -590,7 +590,8 @@ bool ComputeSHA256DigestOfPath(const base::FilePath& path, ...@@ -590,7 +590,8 @@ bool ComputeSHA256DigestOfPath(const base::FilePath& path,
std::string* digest) { std::string* digest) {
DCHECK(digest); DCHECK(digest);
base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ); base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ |
base::File::FLAG_SHARE_DELETE);
if (!file.IsValid()) if (!file.IsValid())
return false; return false;
......
...@@ -31,7 +31,7 @@ enum RemovalStatusOverridePermission { ...@@ -31,7 +31,7 @@ enum RemovalStatusOverridePermission {
// when previous knowledge was FAILED_TO_REMOVE. // when previous knowledge was FAILED_TO_REMOVE.
kOkToOverride, kOkToOverride,
// This should never happen in the code, and we should raise an error. // This should never happen in the code, and we should raise an error.
// TODO: Currently there is no error, and kNotAllowed is // TODO(joenotcharles): Currently there is no error, and kNotAllowed is
// implemented as kSkip. This is because DCHECK writes an error message to // implemented as kSkip. This is because DCHECK writes an error message to
// the log, and until recently this took the logging lock which might already // the log, and until recently this took the logging lock which might already
// be held while checking this permission. Now that it's safe to DCHECK while // be held while checking this permission. Now that it's safe to DCHECK while
......
...@@ -9,8 +9,10 @@ static_library("common") { ...@@ -9,8 +9,10 @@ static_library("common") {
] ]
deps = [ deps = [
"//chrome/chrome_cleaner/constants:quarantine_constants",
"//chrome/chrome_cleaner/interfaces:zip_archiver_interface", "//chrome/chrome_cleaner/interfaces:zip_archiver_interface",
"//chrome/chrome_cleaner/ipc:mojo_task_runner", "//chrome/chrome_cleaner/ipc:mojo_task_runner",
"//chrome/chrome_cleaner/ipc:sandbox",
"//chrome/chrome_cleaner/os:common_os", "//chrome/chrome_cleaner/os:common_os",
"//chrome/chrome_cleaner/zip_archiver/broker:common", "//chrome/chrome_cleaner/zip_archiver/broker:common",
"//mojo/public/cpp/system:system", "//mojo/public/cpp/system:system",
...@@ -41,6 +43,7 @@ source_set("unittest_sources") { ...@@ -41,6 +43,7 @@ source_set("unittest_sources") {
deps = [ deps = [
"//base/test:test_support", "//base/test:test_support",
"//chrome/chrome_cleaner/constants:quarantine_constants",
"//chrome/chrome_cleaner/interfaces:zip_archiver_interface", "//chrome/chrome_cleaner/interfaces:zip_archiver_interface",
"//chrome/chrome_cleaner/ipc:mojo_task_runner", "//chrome/chrome_cleaner/ipc:mojo_task_runner",
"//chrome/chrome_cleaner/os:common_os", "//chrome/chrome_cleaner/os:common_os",
......
include_rules = [ include_rules = [
"+third_party/zlib", "+third_party/zlib",
] ]
...@@ -15,25 +15,34 @@ ...@@ -15,25 +15,34 @@
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "chrome/chrome_cleaner/interfaces/zip_archiver.mojom.h" #include "chrome/chrome_cleaner/interfaces/zip_archiver.mojom.h"
#include "chrome/chrome_cleaner/ipc/mojo_task_runner.h" #include "chrome/chrome_cleaner/ipc/mojo_task_runner.h"
#include "chrome/chrome_cleaner/ipc/sandbox.h"
#include "chrome/chrome_cleaner/zip_archiver/broker/sandbox_setup.h" #include "chrome/chrome_cleaner/zip_archiver/broker/sandbox_setup.h"
namespace chrome_cleaner { namespace chrome_cleaner {
namespace internal {
base::string16 ConstructZipArchiveFileName(const base::string16& filename,
const std::string& file_hash);
} // namespace internal
class SandboxedZipArchiver { class SandboxedZipArchiver {
public: public:
using ArchiveResultCallback =
base::OnceCallback<void(mojom::ZipArchiverResultCode)>;
SandboxedZipArchiver(scoped_refptr<MojoTaskRunner> mojo_task_runner, SandboxedZipArchiver(scoped_refptr<MojoTaskRunner> mojo_task_runner,
UniqueZipArchiverPtr zip_archiver_ptr, UniqueZipArchiverPtr zip_archiver_ptr,
const base::FilePath& dst_archive_folder, const base::FilePath& dst_archive_folder,
const std::string& zip_password); const std::string& zip_password);
~SandboxedZipArchiver(); ~SandboxedZipArchiver();
mojom::ZipArchiverResultCode Archive(const base::FilePath& src_file_path, void Archive(const base::FilePath& src_file_path,
base::FilePath* output_zip_file_path); ArchiveResultCallback result_callback);
private: private:
mojom::ZipArchiverResultCode DoArchive(base::File src_file, mojom::ZipArchiverResultCode CheckFileSize(base::File* file);
base::File zip_file,
const std::string& filename_in_zip);
scoped_refptr<MojoTaskRunner> mojo_task_runner_; scoped_refptr<MojoTaskRunner> mojo_task_runner_;
UniqueZipArchiverPtr zip_archiver_ptr_; UniqueZipArchiverPtr zip_archiver_ptr_;
...@@ -45,7 +54,7 @@ ResultCode SpawnZipArchiverSandbox( ...@@ -45,7 +54,7 @@ ResultCode SpawnZipArchiverSandbox(
const base::FilePath& dst_archive_folder, const base::FilePath& dst_archive_folder,
const std::string& zip_password, const std::string& zip_password,
scoped_refptr<MojoTaskRunner> mojo_task_runner, scoped_refptr<MojoTaskRunner> mojo_task_runner,
base::OnceClosure connection_error_handler, const SandboxConnectionErrorCallback& connection_error_callback,
std::unique_ptr<SandboxedZipArchiver>* sandboxed_zip_archiver); std::unique_ptr<SandboxedZipArchiver>* sandboxed_zip_archiver);
} // namespace chrome_cleaner } // namespace chrome_cleaner
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment