Bug 1575564 - avoid non-mainthread use of NS_GetSpecialDirectory in linux sandboxbroker, r=jld,gcp

Differential Revision: https://phabricator.services.mozilla.com/D42951

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gijs Kruitbosch 2019-08-22 16:37:18 +00:00
Родитель e0b48a710c
Коммит 871832fcf9
2 изменённых файлов: 15 добавлений и 10 удалений

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

@ -62,6 +62,15 @@ SandboxBroker::SandboxBroker(UniquePtr<const Policy> aPolicy, int aChildPid,
mFileDesc = -1;
aClientFd = -1;
}
nsCOMPtr<nsIFile> tmpDir;
nsresult rv = NS_GetSpecialDirectory(NS_APP_CONTENT_PROCESS_TEMP_DIR,
getter_AddRefs(tmpDir));
if (NS_SUCCEEDED(rv)) {
rv = tmpDir->GetNativePath(mContentTempPath);
if (NS_FAILED(rv)) {
mContentTempPath.Truncate();
}
}
}
UniquePtr<SandboxBroker> SandboxBroker::Create(
@ -540,17 +549,12 @@ size_t SandboxBroker::RemapTempDirs(char* aPath, size_t aBufSize,
Substring(path, prefixLen, path.Length() - prefixLen);
// Only now try to get the content process temp dir
nsCOMPtr<nsIFile> tmpDir;
nsresult rv = NS_GetSpecialDirectory(NS_APP_CONTENT_PROCESS_TEMP_DIR,
getter_AddRefs(tmpDir));
if (NS_SUCCEEDED(rv)) {
if (!mContentTempPath.IsEmpty()) {
nsAutoCString tmpPath;
rv = tmpDir->GetNativePath(tmpPath);
if (NS_SUCCEEDED(rv)) {
tmpPath.Append(cutPath);
base::strlcpy(aPath, tmpPath.get(), aBufSize);
return strlen(aPath);
}
tmpPath.Assign(mContentTempPath);
tmpPath.Append(cutPath);
base::strlcpy(aPath, tmpPath.get(), aBufSize);
return strlen(aPath);
}
}

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

@ -137,6 +137,7 @@ class SandboxBroker final : private SandboxBrokerCommon,
const int mChildPid;
const UniquePtr<const Policy> mPolicy;
nsCString mTempPath;
nsCString mContentTempPath;
typedef nsDataHashtable<nsCStringHashKey, nsCString> PathMap;
PathMap mSymlinkMap;