Bug 1384483 - Allow reading userContent.css in the sandbox. j?jld draft
authorGian-Carlo Pascutto <gcp@mozilla.com>
Mon, 31 Jul 2017 17:58:19 +0200
changeset 618500 0c8355b34e79d8b0f4ec744a6f2b8b4414e0ab5c
parent 618382 748a817e823e076f483cee7e26e69dcf8a807a4c
child 618501 8b168e291469efb3afb90754a2833c07dd815e9f
push id71362
push usergpascutto@mozilla.com
push dateMon, 31 Jul 2017 15:59:03 +0000
bugs1384483
milestone56.0a1
Bug 1384483 - Allow reading userContent.css in the sandbox. j?jld MozReview-Commit-ID: A43RY1J95VF
security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
--- a/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
+++ b/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
@@ -245,16 +245,35 @@ SandboxBrokerPolicyFactory::GetContentPo
     Preferences::GetCString("security.sandbox.content.write_path_whitelist");
   AddDynamicPathList(policy.get(), extraWritePathString, rdwr);
 
   // file:// processes get global read permissions
   if (aFileProcess) {
     policy->AddDir(rdonly, "/");
   }
 
+  // userContent.css sits in the profile, which is normally blocked
+  // and we can't get the profile dir earlier
+  nsCOMPtr<nsIFile> profileDir;
+  nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
+                                       getter_AddRefs(profileDir));
+  if (NS_SUCCEEDED(rv)) {
+      rv = profileDir->AppendNative(NS_LITERAL_CSTRING("chrome"));
+      if (NS_SUCCEEDED(rv)) {
+        rv = profileDir->AppendNative(NS_LITERAL_CSTRING("userContent.css"));
+        if (NS_SUCCEEDED(rv)) {
+          nsAutoCString tmpPath;
+          rv = profileDir->GetNativePath(tmpPath);
+          if (NS_SUCCEEDED(rv)) {
+            policy->AddPath(rdonly, tmpPath.get());
+          }
+        }
+    }
+  }
+
   // Return the common policy.
   return policy;
 
 }
 
 void
 SandboxBrokerPolicyFactory::AddDynamicPathList(SandboxBroker::Policy *policy,
                                                nsAdoptingCString& pathList,