Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Unified Diff: content/browser/utility_process_host_impl.cc

Issue 1415483008: Get rid of SandboxedProcessLauncherDelegate::PreSandbox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missed one clang error. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/utility_process_host_impl.cc
diff --git a/content/browser/utility_process_host_impl.cc b/content/browser/utility_process_host_impl.cc
index 2fdd365ffa6706f38b28c5b5ef039ad26f1e3e22..8dc1e9230cb6a0b74a9e940df8501af5d9113e37 100644
--- a/content/browser/utility_process_host_impl.cc
+++ b/content/browser/utility_process_host_impl.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/command_line.h"
+#include "base/files/file_path.h"
#include "base/lazy_instance.h"
#include "base/message_loop/message_loop.h"
#include "base/process/process_handle.h"
@@ -32,6 +33,11 @@
#include "ipc/ipc_switches.h"
#include "ui/base/ui_base_switches.h"
+#if defined(OS_WIN)
+#include "sandbox/win/src/sandbox_policy.h"
+#include "sandbox/win/src/sandbox_types.h"
+#endif
+
namespace content {
// NOTE: changes to this class need to be reviewed by the security team.
@@ -57,10 +63,31 @@ class UtilitySandboxedProcessLauncherDelegate
#if defined(OS_WIN)
bool ShouldLaunchElevated() override { return launch_elevated_; }
- void PreSandbox(bool* disable_default_policy,
- base::FilePath* exposed_dir) override {
- *exposed_dir = exposed_dir_;
+
+ bool PreSpawnTarget(sandbox::TargetPolicy* policy) override {
+ if (exposed_dir_.empty()) {
+ return true;
+ }
+
+ sandbox::ResultCode result;
+ result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES,
+ sandbox::TargetPolicy::FILES_ALLOW_ANY,
+ exposed_dir_.value().c_str());
+ if (result != sandbox::SBOX_ALL_OK) {
+ return false;
+ }
+
+ base::FilePath exposed_files = exposed_dir_.AppendASCII("*");
+ result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES,
+ sandbox::TargetPolicy::FILES_ALLOW_ANY,
+ exposed_files.value().c_str());
+ if (result != sandbox::SBOX_ALL_OK) {
+ return false;
+ }
+
+ return true;
}
+
#elif defined(OS_POSIX)
bool ShouldUseZygote() override {

Powered by Google App Engine
This is Rietveld 408576698