Skip to content

Commit

Permalink
Bug 1692220 - Allow content-process read access to libFontRegistry ca…
Browse files Browse the repository at this point in the history
…ches. r=haik

Differential Revision: https://phabricator.services.mozilla.com/D105801
  • Loading branch information
jfkthame committed Feb 19, 2021
1 parent 1aaf619 commit 6a82712
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
21 changes: 18 additions & 3 deletions security/sandbox/mac/Sandbox.mm
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,11 @@ bool StartMacSandbox(MacSandboxInfo const& aInfo, std::string& aErrorMessage) {

// Used for the Flash sandbox. Declared here so that they
// stay in scope until sandbox_init_with_parameters is called.
std::string flashCacheDir, flashTempDir, flashPath;
std::string flashTempDir, flashPath;

// Used for the content process to access to parts of the cache dir,
// and also for the Flash sandbox (which is presumably going away soon).
std::string userCacheDir;

if (aInfo.type == MacSandboxType_Flash) {
profile = SandboxPolicyFlash;
Expand Down Expand Up @@ -311,10 +315,10 @@ bool StartMacSandbox(MacSandboxInfo const& aInfo, std::string& aErrorMessage) {
if (!confstr(_CS_DARWIN_USER_CACHE_DIR, confStrBuf, sizeof(confStrBuf))) {
return false;
}
if (!GetRealPath(flashCacheDir, confStrBuf)) {
if (!GetRealPath(userCacheDir, confStrBuf)) {
return false;
}
params.push_back(flashCacheDir.c_str());
params.push_back(userCacheDir.c_str());

// User temp dir
params.push_back("DARWIN_USER_TEMP_DIR");
Expand Down Expand Up @@ -415,6 +419,17 @@ bool StartMacSandbox(MacSandboxInfo const& aInfo, std::string& aErrorMessage) {
params.push_back("CRASH_PORT");
params.push_back(aInfo.crashServerPort.c_str());
}

params.push_back("DARWIN_USER_CACHE_DIR");
char confStrBuf[PATH_MAX];
if (!confstr(_CS_DARWIN_USER_CACHE_DIR, confStrBuf, sizeof(confStrBuf))) {
return false;
}
if (!GetRealPath(userCacheDir, confStrBuf)) {
return false;
}
params.push_back(userCacheDir.c_str());

if (!aInfo.testingReadPath1.empty()) {
params.push_back("TESTING_READ_PATH1");
params.push_back(aInfo.testingReadPath1.c_str());
Expand Down
6 changes: 6 additions & 0 deletions security/sandbox/mac/SandboxPolicyContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ static const char SandboxPolicyContent[] = R"SANDBOX_LITERAL(
(define hasWindowServer (param "HAS_WINDOW_SERVER"))
(define home-path (param "HOME_PATH"))
(define debugWriteDir (param "DEBUG_WRITE_DIR"))
(define userCacheDir (param "DARWIN_USER_CACHE_DIR"))
(define testingReadPath1 (param "TESTING_READ_PATH1"))
(define testingReadPath2 (param "TESTING_READ_PATH2"))
(define testingReadPath3 (param "TESTING_READ_PATH3"))
Expand Down Expand Up @@ -262,6 +263,11 @@ static const char SandboxPolicyContent[] = R"SANDBOX_LITERAL(
(when testingReadPath4
(allow file-read* (subpath testingReadPath4)))))
; bug 1692220
(when userCacheDir
(allow file-read*
(subpath (string-append userCacheDir "/com.apple.FontRegistry"))))
; bug 1303987
(if (string? debugWriteDir)
(begin
Expand Down

0 comments on commit 6a82712

Please sign in to comment.