Bug 1717599 - Ensure XDG_CONFIG_DIRS / XDG_CONFIG_HOME are non empty r=gcp

Differential Revision: https://phabricator.services.mozilla.com/D118483
This commit is contained in:
Alexandre Lissy 2021-06-22 14:50:05 +00:00
Родитель bdd3269f89
Коммит fa60d28ad7
6 изменённых файлов: 50 добавлений и 5 удалений

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

@ -357,14 +357,17 @@ void SandboxBrokerPolicyFactory::InitContentPolicy() {
// For that we use AddPath(, SandboxBroker::Policy::AddCondition::AddAlways).
//
// Allow access to XDG_CONFIG_HOME and XDG_CONFIG_DIRS
if (const auto* xdgConfigPath = PR_GetEnv("XDG_CONFIG_HOME")) {
policy->AddPath(rdonly, xdgConfigPath,
nsAutoCString xdgConfigHome(PR_GetEnv("XDG_CONFIG_HOME"));
if (!xdgConfigHome.IsEmpty()) { // AddPath will fail on empty strings
policy->AddPath(rdonly, xdgConfigHome.get(),
SandboxBroker::Policy::AddCondition::AddAlways);
}
nsAutoCString xdgConfigDirs(PR_GetEnv("XDG_CONFIG_DIRS"));
for (const auto& path : xdgConfigDirs.Split(':')) {
policy->AddPath(rdonly, PromiseFlatCString(path).get(),
SandboxBroker::Policy::AddCondition::AddAlways);
if (!path.IsEmpty()) { // AddPath will fail on empty strings
policy->AddPath(rdonly, PromiseFlatCString(path).get(),
SandboxBroker::Policy::AddCondition::AddAlways);
}
}
// Allow fonts subdir in XDG_DATA_HOME

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

@ -4,7 +4,11 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
BROWSER_CHROME_MANIFESTS += ["test/browser.ini"]
BROWSER_CHROME_MANIFESTS += [
"test/browser.ini",
"test/browser_bug1717599_XDG-CONFIG-DIRS.ini",
"test/browser_bug1717599_XDG-CONFIG-HOME.ini",
]
with Files("**"):
BUG_COMPONENT = ("Core", "Security: Process Sandboxing")

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

@ -0,0 +1,8 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
[DEFAULT]
tags = contentsandbox
environment=XDG_CONFIG_DIRS=:/opt
[browser_content_sandbox_bug1717599_XDG-CONFIG-DIRS.js]
run-if = (os == 'linux')

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

@ -0,0 +1,8 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
[DEFAULT]
tags = contentsandbox
environment=XDG_CONFIG_HOME=
[browser_content_sandbox_bug1717599_XDG-CONFIG-HOME.js]
run-if = (os == 'linux')

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

@ -0,0 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from browser_content_sandbox_utils.js */
"use strict";
//
// Just test that browser does not die on empty env var
//
add_task(async function() {
ok(true, "Process can run");
});

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

@ -0,0 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from browser_content_sandbox_utils.js */
"use strict";
//
// Just test that browser does not die on empty env var
//
add_task(async function() {
ok(true, "Process can run");
});