Bug 1723753 - Remove XRE_USER_SYS_EXTENSION_DEV_DIR r=handyman,robwu,haik,gcp

Differential Revision: https://phabricator.services.mozilla.com/D121647
This commit is contained in:
Alexandre Lissy 2021-08-10 15:54:02 +00:00
Родитель 625f7a5de1
Коммит f41c9baf2b
8 изменённых файлов: 0 добавлений и 101 удалений

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

@ -511,18 +511,6 @@ void SandboxBrokerPolicyFactory::InitContentPolicy() {
}
}
// ~/.mozilla/systemextensionsdev (bug 1393805)
nsCOMPtr<nsIFile> sysExtDevDir;
rv = NS_GetSpecialDirectory(XRE_USER_SYS_EXTENSION_DEV_DIR,
getter_AddRefs(sysExtDevDir));
if (NS_SUCCEEDED(rv)) {
nsAutoCString tmpPath;
rv = sysExtDevDir->GetNativePath(tmpPath);
if (NS_SUCCEEDED(rv)) {
policy->AddDir(rdonly, tmpPath.get());
}
}
if (mozilla::IsDevelopmentBuild()) {
// If this is a developer build the resources are symlinks to outside the
// binary dir. Therefore in non-release builds we allow reads from the whole

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

@ -284,10 +284,6 @@ static const char SandboxPolicyContent[] = R"SANDBOX_LITERAL(
(home-regex "/Library/Application Support/[^/]+/Extensions/")
(regex "^/Library/Application Support/[^/]+/Extensions/"))
; bug 1393805
(allow file-read*
(home-subpath "/Library/Application Support/Mozilla/SystemExtensionsDev"))
; The following rules impose file access restrictions which get
; more restrictive in higher levels. When file-origin-specific
; content processes are used for file:// origin browsing, the

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

@ -104,16 +104,6 @@ async function testFileAccessAllPlatforms() {
});
}
let sysExtDevDir = GetSystemExtensionsDevDir();
tests.push({
desc: "system extensions dev dir",
ok: true,
browser: webBrowser,
file: sysExtDevDir,
minLevel: 0,
func: readDir,
});
let extensionsDir = GetProfileEntry("extensions");
if (extensionsDir.exists() && extensionsDir.isDirectory()) {
tests.push({

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

@ -289,10 +289,6 @@ function GetSubdirFile(dir) {
return newFile;
}
function GetSystemExtensionsDevDir() {
return Services.dirsvc.get("XRESysExtDev", Ci.nsIFile);
}
function GetPerUserExtensionDir() {
return Services.dirsvc.get("XREUSysExt", Ci.nsIFile);
}

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

@ -52,7 +52,6 @@ static UniquePtr<nsString> sProfileDir;
static UniquePtr<nsString> sContentTempDir;
static UniquePtr<nsString> sRoamingAppDataDir;
static UniquePtr<nsString> sLocalAppDataDir;
static UniquePtr<nsString> sUserExtensionsDevDir;
#ifdef ENABLE_SYSTEM_EXTENSION_DIRS
static UniquePtr<nsString> sUserExtensionsDir;
#endif
@ -159,8 +158,6 @@ void SandboxBroker::GeckoDependentInitialize() {
&sContentTempDir);
CacheDirAndAutoClear(dirSvc, NS_WIN_APPDATA_DIR, &sRoamingAppDataDir);
CacheDirAndAutoClear(dirSvc, NS_WIN_LOCAL_APPDATA_DIR, &sLocalAppDataDir);
CacheDirAndAutoClear(dirSvc, XRE_USER_SYS_EXTENSION_DEV_DIR,
&sUserExtensionsDevDir);
#ifdef ENABLE_SYSTEM_EXTENSION_DIRS
CacheDirAndAutoClear(dirSvc, XRE_USER_SYS_EXTENSION_DIR,
&sUserExtensionsDir);
@ -718,10 +715,6 @@ void SandboxBroker::SetSecurityLevelForContentProcess(int32_t aSandboxLevel,
AddCachedDirRule(mPolicy, sandbox::TargetPolicy::FILES_ALLOW_READONLY,
sProfileDir, u"\\extensions\\*"_ns);
// Read access to a directory for system extension dev (see bug 1393805)
AddCachedDirRule(mPolicy, sandbox::TargetPolicy::FILES_ALLOW_READONLY,
sUserExtensionsDevDir, u"\\*"_ns);
#ifdef ENABLE_SYSTEM_EXTENSION_DIRS
// Add rule to allow read access to the per-user extensions directory.
AddCachedDirRule(mPolicy, sandbox::TargetPolicy::FILES_ALLOW_READONLY,

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

@ -485,8 +485,6 @@ nsXREDirProvider::GetFile(const char* aProperty, bool* aPersistent,
#else
return NS_ERROR_FAILURE;
#endif
} else if (!strcmp(aProperty, XRE_USER_SYS_EXTENSION_DEV_DIR)) {
return GetSysUserExtensionsDevDirectory(aFile);
} else if (!strcmp(aProperty, XRE_USER_RUNTIME_DIR)) {
#if defined(XP_UNIX)
nsPrintfCString path("/run/user/%d/%s/", getuid(), GetAppName());
@ -1500,29 +1498,6 @@ nsresult nsXREDirProvider::GetSysUserExtensionsDirectory(nsIFile** aFile) {
return NS_OK;
}
nsresult nsXREDirProvider::GetSysUserExtensionsDevDirectory(nsIFile** aFile) {
nsCOMPtr<nsIFile> localDir;
nsresult rv = GetUserDataDirectoryHome(getter_AddRefs(localDir), false);
NS_ENSURE_SUCCESS(rv, rv);
rv = AppendSysUserExtensionsDevPath(localDir);
NS_ENSURE_SUCCESS(rv, rv);
rv = EnsureDirectoryExists(localDir);
NS_ENSURE_SUCCESS(rv, rv);
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
// This is used in sandbox rules, so we need to make sure it doesn't contain
// any junction points or symlinks or the sandbox will reject those rules.
if (!mozilla::widget::WinUtils::ResolveJunctionPointsAndSymLinks(localDir)) {
NS_WARNING("Failed to resolve sys user extensions dev directory.");
}
#endif
localDir.forget(aFile);
return NS_OK;
}
#if defined(XP_UNIX) || defined(XP_MACOSX)
nsresult nsXREDirProvider::GetSystemExtensionsDirectory(nsIFile** aFile) {
nsresult rv;
@ -1612,37 +1587,6 @@ nsresult nsXREDirProvider::AppendSysUserExtensionPath(nsIFile* aFile) {
return NS_OK;
}
nsresult nsXREDirProvider::AppendSysUserExtensionsDevPath(nsIFile* aFile) {
MOZ_ASSERT(aFile);
nsresult rv;
#if defined(XP_MACOSX) || defined(XP_WIN)
static const char* const sXR = "Mozilla";
rv = aFile->AppendNative(nsDependentCString(sXR));
NS_ENSURE_SUCCESS(rv, rv);
static const char* const sExtensions = "SystemExtensionsDev";
rv = aFile->AppendNative(nsDependentCString(sExtensions));
NS_ENSURE_SUCCESS(rv, rv);
#elif defined(XP_UNIX)
static const char* const sXR = ".mozilla";
rv = aFile->AppendNative(nsDependentCString(sXR));
NS_ENSURE_SUCCESS(rv, rv);
static const char* const sExtensions = "systemextensionsdev";
rv = aFile->AppendNative(nsDependentCString(sExtensions));
NS_ENSURE_SUCCESS(rv, rv);
#else
# error "Don't know how to get XRE system extension dev path on your platform"
#endif
return NS_OK;
}
nsresult nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal) {
NS_ASSERTION(aFile, "Null pointer!");

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

@ -114,7 +114,6 @@ class nsXREDirProvider final : public nsIDirectoryServiceProvider2,
nsISimpleEnumerator** aResult);
static nsresult GetUserDataDirectoryHome(nsIFile** aFile, bool aLocal);
static nsresult GetSysUserExtensionsDirectory(nsIFile** aFile);
static nsresult GetSysUserExtensionsDevDirectory(nsIFile** aFile);
#if defined(XP_UNIX) || defined(XP_MACOSX)
static nsresult GetSystemExtensionsDirectory(nsIFile** aFile);
#endif
@ -125,7 +124,6 @@ class nsXREDirProvider final : public nsIDirectoryServiceProvider2,
static nsresult AppendProfilePath(nsIFile* aFile, bool aLocal);
static nsresult AppendSysUserExtensionPath(nsIFile* aFile);
static nsresult AppendSysUserExtensionsDevPath(nsIFile* aFile);
// Internal helper that splits a path into components using the '/' and '\\'
// delimiters.

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

@ -124,12 +124,6 @@ struct Module;
*/
#define XRE_USER_SYS_EXTENSION_DIR "XREUSysExt"
/**
* A directory service key which specifies a directory where temporary
* system extensions can be loaded from during development.
*/
#define XRE_USER_SYS_EXTENSION_DEV_DIR "XRESysExtDev"
/**
* A directory service key which specifies the distribution specific files for
* the application.