diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-19 14:51:13 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-19 14:51:13 +0000 |
commit | a89a55dd2a5fc953a936dbbbf0e5f00db0adf550 (patch) | |
tree | 60beab9c2a7dde200b9fb02ccc7fdd7328d168d9 /chrome/browser/zygote_main_linux.cc | |
parent | 521d76f78a831a4465e25649f39b1315726b28df (diff) | |
download | chromium_src-a89a55dd2a5fc953a936dbbbf0e5f00db0adf550.zip chromium_src-a89a55dd2a5fc953a936dbbbf0e5f00db0adf550.tar.gz chromium_src-a89a55dd2a5fc953a936dbbbf0e5f00db0adf550.tar.bz2 |
SELinux: add basic policy.
This patch removes the chromium_zygote_t type and adds a
chromium_renderer_t type. Also, a basic policy for chromium_renderer_t
is included.
I decided not to try to have a different policy for the zygote since
it just makes things more complex for little reason.
BUG=none
TEST=none
http://codereview.chromium.org/1104002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/zygote_main_linux.cc')
-rw-r--r-- | chrome/browser/zygote_main_linux.cc | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/chrome/browser/zygote_main_linux.cc b/chrome/browser/zygote_main_linux.cc index a7cfb76..8071f0f 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. @@ -265,6 +285,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); @@ -585,26 +609,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; } |