From 997c9dc4160c468f26acb851eb65408f41e2a091 Mon Sep 17 00:00:00 2001 From: Ryan Gonzalez Date: Tue, 25 Aug 2020 19:26:07 -0500 Subject: [PATCH] flatpak: Adjust paths for the sandbox --- chrome/common/BUILD.gn | 4 ++++ chrome/common/chrome_paths.cc | 26 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn index 76cf6a5985990..4044c87b656c4 100644 --- a/chrome/common/BUILD.gn +++ b/chrome/common/BUILD.gn @@ -642,6 +642,10 @@ static_library("constants") { "//third_party/widevine/cdm:headers", ] } + + if (is_linux) { + deps += [ "//sandbox/linux:sandbox_services" ] + } } # Use a static library here because many test binaries depend on this but don't diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc index ec09803ffabcf..ecbc300b99e1d 100644 --- a/chrome/common/chrome_paths.cc +++ b/chrome/common/chrome_paths.cc @@ -38,6 +38,10 @@ #include "base/win/registry.h" #endif +#if BUILDFLAG(IS_LINUX) +#include "sandbox/linux/services/flatpak_sandbox.h" +#endif + #if BUILDFLAG(ENABLE_WIDEVINE) #include "third_party/widevine/cdm/widevine_cdm_common.h" // nogncheck #endif @@ -537,6 +541,14 @@ bool PathProvider(int key, base::FilePath* result) { break; #if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_OPENBSD) case chrome::DIR_POLICY_FILES: { +#if defined(OS_LINUX) + if (sandbox::FlatpakSandbox::GetInstance()->GetSandboxLevel() > + sandbox::FlatpakSandbox::SandboxLevel::kNone) { + cur = base::FilePath( + FILE_PATH_LITERAL("/app/chromium/extensions/policies")); + break; + } +#endif cur = base::FilePath(policy::kPolicyPath); break; } @@ -557,7 +569,13 @@ bool PathProvider(int key, base::FilePath* result) { #endif #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) case chrome::DIR_STANDALONE_EXTERNAL_EXTENSIONS: { - cur = base::FilePath(kFilepathSinglePrefExtensions); + if (sandbox::FlatpakSandbox::GetInstance()->GetSandboxLevel() > + sandbox::FlatpakSandbox::SandboxLevel::kNone) { + cur = base::FilePath( + FILE_PATH_LITERAL("/app/chromium/extensions/extensions")); + } else { + cur = base::FilePath(kFilepathSinglePrefExtensions); + } break; } #endif @@ -604,6 +622,12 @@ bool PathProvider(int key, base::FilePath* result) { "/Library/Application Support/Chromium/NativeMessagingHosts")); #endif #else // BUILDFLAG(IS_MAC) + if (sandbox::FlatpakSandbox::GetInstance()->GetSandboxLevel() > + sandbox::FlatpakSandbox::SandboxLevel::kNone) { + cur = base::FilePath(FILE_PATH_LITERAL( + "/app/chromium/extensions/native-messaging-hosts")); + break; + } #if BUILDFLAG(GOOGLE_CHROME_BRANDING) cur = base::FilePath( FILE_PATH_LITERAL("/etc/opt/chrome/native-messaging-hosts")); -- 2.46.1