Bug 1321134 - Allow access to dconf shared-memory flags. r?gcp r?glandium draft
authorJed Davis <jld@mozilla.com>
Tue, 30 May 2017 07:10:15 -0600
changeset 586835 28a5e6d1396a6c2af01cd46b100f5f944ebb5016
parent 586626 fbe0e3f31233cc7846a2168c613452a1d7147cc2
child 631114 04d1c83cba0c97528e1a5209e2d12e668a6664b7
push id61539
push userbmo:jld@mozilla.com
push dateWed, 31 May 2017 05:03:05 +0000
reviewersgcp, glandium
bugs1321134
milestone55.0a1
Bug 1321134 - Allow access to dconf shared-memory flags. r?gcp r?glandium DConf uses small memory-mapped files for the writer to signal readers to invalidate cached data; the file is created by the first reader and readers will write to it to force storage allocation. If we don't allow opening the file, DConf will still work, but it will reread the database on every pref access, and it prints messages on stderr claiming it won't work. So we should avoid that. MozReview-Commit-ID: 9xoBIhtu5cu
security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
security/sandbox/linux/broker/moz.build
--- a/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
+++ b/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
@@ -15,16 +15,20 @@
 #include "nsThreadUtils.h"
 #include "nsXULAppAPI.h"
 #include "SpecialSystemDirectory.h"
 
 #ifdef ANDROID
 #include "cutils/properties.h"
 #endif
 
+#ifdef MOZ_WIDGET_GTK
+#include <glib.h>
+#endif
+
 namespace mozilla {
 
 /* static */ bool
 SandboxBrokerPolicyFactory::IsSystemSupported() {
 #ifdef ANDROID
   char hardware[PROPERTY_VALUE_MAX];
   int length = property_get("ro.hardware", hardware, nullptr);
   // "goldfish" -> emulator.  Other devices can be added when we're
@@ -144,16 +148,25 @@ SandboxBrokerPolicyFactory::SandboxBroke
   // Bug 1312678: radeonsi/Intel with DRI when using WebGL
   policy->AddDir(rdwr, "/dev/dri");
 
 #ifdef MOZ_ALSA
   // Bug 1309098: ALSA support
   policy->AddDir(rdwr, "/dev/snd");
 #endif
 
+#ifdef MOZ_WIDGET_GTK
+  // Bug 1321134: DConf's single bit of shared memory
+  if (const auto userDir = g_get_user_runtime_dir()) {
+    // The leaf filename is "user" by default, but is configurable.
+    nsPrintfCString shmPath("%s/dconf/", userDir);
+    policy->AddPrefix(rdwrcr, shmPath.get());
+  }
+#endif
+
   mCommonContentPolicy.reset(policy);
 #endif
 }
 
 #ifdef MOZ_CONTENT_SANDBOX
 UniquePtr<SandboxBroker::Policy>
 SandboxBrokerPolicyFactory::GetContentPolicy(int aPid)
 {
--- a/security/sandbox/linux/broker/moz.build
+++ b/security/sandbox/linux/broker/moz.build
@@ -27,10 +27,12 @@ LOCAL_INCLUDES += [
 include('/ipc/chromium/chromium-config.mozbuild')
 
 # Need this for safe_sprintf.h used by SandboxLogging.h,
 # but it has to be after ipc/chromium/src.
 LOCAL_INCLUDES += [
     '/security/sandbox/chromium',
 ]
 
+if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
+    CXXFLAGS += CONFIG['GLIB_CFLAGS']
 
 FINAL_LIBRARY = 'xul'