Bug 1692220 - Allow content-process read access to libFontRegistry caches. r=haik

Differential Revision: https://phabricator.services.mozilla.com/D105801
This commit is contained in:
Jonathan Kew 2021-02-19 21:56:59 +00:00
Родитель 1aaf619aea
Коммит 6a82712eab
2 изменённых файлов: 24 добавлений и 3 удалений

Просмотреть файл

@ -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;
@ -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");
@ -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());

Просмотреть файл

@ -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"))
@ -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