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

Unified Diff: chrome/browser/zygote_main_linux.cc

Issue 1104002: SELinux: add basic policy. (Closed)
Patch Set: ... Created 10 years, 9 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 | « no previous file | ipc/ipc_channel_posix.cc » ('j') | ipc/ipc_channel_posix.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/zygote_main_linux.cc
diff --git a/chrome/browser/zygote_main_linux.cc b/chrome/browser/zygote_main_linux.cc
index e8b5f7bd203875d251935e4a333c9c17637dc22d..6578d129e960f55038b823295a830b0e1770576a 100644
--- a/chrome/browser/zygote_main_linux.cc
+++ b/chrome/browser/zygote_main_linux.cc
@@ -64,6 +64,26 @@ static bool g_suid_sandbox_active = false;
static int g_proc_fd = -1;
#endif
+#if defined(CHROMIUM_SELINUX)
+static void SELinuxTransitionToTypeOrDie(const char* type) {
+ security_context_t security_context;
+ if (getcon(&security_context))
+ LOG(FATAL) << "Cannot get SELinux context";
+
+ context_t context = context_new(security_context);
+ context_type_set(context, type);
+ const int r = setcon(context_str(context));
+ context_free(context);
+ freecon(security_context);
+
+ if (r) {
+ LOG(FATAL) << "dynamic transition to type '" << type << "' failed. "
+ "(this binary has been built with SELinux support, but maybe "
+ "the policies haven't been loaded into the kernel?)";
+ }
+}
+#endif // CHROMIUM_SELINUX
+
// This is the object which implements the zygote. The ZygoteMain function,
// which is called from ChromeMain, at the the bottom and simple constructs one
// of these objects and runs it.
@@ -264,6 +284,10 @@ class Zygote {
close(kZygoteIdDescriptor); // another socket from the browser
Singleton<base::GlobalDescriptors>()->Reset(mapping);
+#if defined(CHROMIUM_SELINUX)
+ SELinuxTransitionToTypeOrDie("chromium_renderer_t");
+#endif
+
// Reset the process-wide command line to our new command line.
CommandLine::Reset();
CommandLine::Init(0, NULL);
@@ -580,26 +604,6 @@ static bool EnterSandbox() {
static bool EnterSandbox() {
PreSandboxInit();
SkiaFontConfigUseIPCImplementation(kMagicSandboxIPCDescriptor);
-
- security_context_t security_context;
- if (getcon(&security_context)) {
- LOG(ERROR) << "Cannot get SELinux context";
- return false;
- }
-
- context_t context = context_new(security_context);
- context_type_set(context, "chromium_zygote_t");
- const int r = setcon(context_str(context));
- context_free(context);
- freecon(security_context);
-
- if (r) {
- LOG(ERROR) << "dynamic transition to type 'chromium_zygote_t' failed. "
- "(this binary has been built with SELinux support, but maybe "
- "the policies haven't been loaded into the kernel?)";
- return false;
- }
-
return true;
}
« no previous file with comments | « no previous file | ipc/ipc_channel_posix.cc » ('j') | ipc/ipc_channel_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698