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

Unified Diff: content/browser/zygote_host_impl_linux.cc

Issue 10807059: Refactor the setuid sandbox client code to its own class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address reviewer's comments and other minor nits. Created 8 years, 5 months 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
« no previous file with comments | « base/linux_util.cc ('k') | content/zygote/zygote_main_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/zygote_host_impl_linux.cc
diff --git a/content/browser/zygote_host_impl_linux.cc b/content/browser/zygote_host_impl_linux.cc
index ee35ef6c4048f3b8644782e6a123a0461cf86049..49b5ec5a563f74b2144fdd773b2341cd394a77f2 100644
--- a/content/browser/zygote_host_impl_linux.cc
+++ b/content/browser/zygote_host_impl_linux.cc
@@ -31,43 +31,13 @@
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/result_codes.h"
-#include "sandbox/linux/suid/sandbox.h"
-#include "sandbox/linux/suid/suid_unsafe_environment_variables.h"
+#include "sandbox/linux/suid/client/setuid_sandbox_client.h"
+#include "sandbox/linux/suid/common/sandbox.h"
#if defined(USE_TCMALLOC)
#include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h"
#endif
-// Set an environment variable that reflects the API version we expect from the
-// setuid sandbox. Old versions of the sandbox will ignore this.
-static void SetSandboxAPIEnvironmentVariable() {
- scoped_ptr<base::Environment> env(base::Environment::Create());
- env->SetVar(base::kSandboxEnvironmentApiRequest,
- base::IntToString(base::kSUIDSandboxApiNumber));
-}
-
-static void SaveSUIDUnsafeEnvironmentVariables() {
- // The ELF loader will clear many environment variables so we save them to
- // different names here so that the SUID sandbox can resolve them for the
- // renderer.
-
- for (unsigned i = 0; kSUIDUnsafeEnvironmentVariables[i]; ++i) {
- const char* const envvar = kSUIDUnsafeEnvironmentVariables[i];
- char* const saved_envvar = SandboxSavedEnvironmentVariable(envvar);
- if (!saved_envvar)
- continue;
-
- scoped_ptr<base::Environment> env(base::Environment::Create());
- std::string value;
- if (env->GetVar(envvar, &value))
- env->SetVar(saved_envvar, value);
- else
- env->UnSetVar(saved_envvar);
-
- free(saved_envvar);
- }
-}
-
// static
content::ZygoteHost* content::ZygoteHost::GetInstance() {
return ZygoteHostImpl::GetInstance();
@@ -153,8 +123,9 @@ void ZygoteHostImpl::Init(const std::string& sandbox_cmd) {
using_suid_sandbox_ = true;
cmd_line.PrependWrapper(sandbox_binary_);
- SaveSUIDUnsafeEnvironmentVariables();
- SetSandboxAPIEnvironmentVariable();
+ scoped_ptr<sandbox::SetuidSandboxClient>
+ sandbox_client(sandbox::SetuidSandboxClient::Create());
+ sandbox_client->SetupLaunchEnvironment();
} else {
LOG(FATAL) << "The SUID sandbox helper binary was found, but is not "
"configured correctly. Rather than run without sandboxing "
« no previous file with comments | « base/linux_util.cc ('k') | content/zygote/zygote_main_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698