fix: crashReporter incompatible with sandbox on Linux (#23265)
This commit is contained in:
parent
fc434f136b
commit
06bf0d08dc
77 changed files with 2235 additions and 2404 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "base/base_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/environment.h"
|
||||
#include "base/files/file_util.h"
|
||||
|
@ -24,6 +25,7 @@
|
|||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "chrome/common/chrome_version.h"
|
||||
#include "components/net_log/chrome_net_log.h"
|
||||
#include "components/network_hints/common/network_hints.mojom.h"
|
||||
|
@ -37,6 +39,7 @@
|
|||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/site_instance.h"
|
||||
#include "content/public/common/content_descriptors.h"
|
||||
#include "content/public/common/content_paths.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/service_names.mojom.h"
|
||||
|
@ -47,6 +50,7 @@
|
|||
#include "extensions/browser/extension_navigation_ui_data.h"
|
||||
#include "extensions/browser/extension_protocols.h"
|
||||
#include "extensions/common/constants.h"
|
||||
#include "extensions/common/switches.h"
|
||||
#include "net/base/escape.h"
|
||||
#include "net/ssl/ssl_cert_request_info.h"
|
||||
#include "ppapi/buildflags/buildflags.h"
|
||||
|
@ -58,6 +62,7 @@
|
|||
#include "services/service_manager/public/cpp/binder_map.h"
|
||||
#include "shell/app/manifests.h"
|
||||
#include "shell/browser/api/electron_api_app.h"
|
||||
#include "shell/browser/api/electron_api_crash_reporter.h"
|
||||
#include "shell/browser/api/electron_api_protocol.h"
|
||||
#include "shell/browser/api/electron_api_session.h"
|
||||
#include "shell/browser/api/electron_api_web_contents.h"
|
||||
|
@ -67,7 +72,6 @@
|
|||
#include "shell/browser/electron_browser_context.h"
|
||||
#include "shell/browser/electron_browser_main_parts.h"
|
||||
#include "shell/browser/electron_navigation_throttle.h"
|
||||
#include "shell/browser/electron_paths.h"
|
||||
#include "shell/browser/electron_quota_permission_context.h"
|
||||
#include "shell/browser/electron_speech_recognition_manager_delegate.h"
|
||||
#include "shell/browser/font_defaults.h"
|
||||
|
@ -89,6 +93,7 @@
|
|||
#include "shell/browser/window_list.h"
|
||||
#include "shell/common/api/api.mojom.h"
|
||||
#include "shell/common/application_info.h"
|
||||
#include "shell/common/electron_paths.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
#include "shell/common/platform_util.h"
|
||||
#include "third_party/blink/public/common/loader/url_loader_throttle.h"
|
||||
|
@ -164,6 +169,14 @@
|
|||
#include "content/public/common/child_process_host.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
#include "base/debug/leak_annotations.h"
|
||||
#include "components/crash/content/browser/crash_handler_host_linux.h"
|
||||
#include "components/crash/core/app/breakpad_linux.h"
|
||||
#include "components/crash/core/app/crash_switches.h"
|
||||
#include "components/crash/core/app/crashpad.h"
|
||||
#endif
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace electron {
|
||||
|
@ -265,6 +278,64 @@ const extensions::Extension* GetEnabledExtensionFromEffectiveURL(
|
|||
}
|
||||
#endif // BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost(
|
||||
const std::string& process_type) {
|
||||
base::FilePath dumps_path;
|
||||
base::PathService::Get(electron::DIR_CRASH_DUMPS, &dumps_path);
|
||||
{
|
||||
ANNOTATE_SCOPED_MEMORY_LEAK;
|
||||
breakpad::CrashHandlerHostLinux* crash_handler =
|
||||
new breakpad::CrashHandlerHostLinux(process_type, dumps_path, true);
|
||||
crash_handler->StartUploaderThread();
|
||||
return crash_handler;
|
||||
}
|
||||
}
|
||||
|
||||
int GetCrashSignalFD(const base::CommandLine& command_line) {
|
||||
// Extensions have the same process type as renderers.
|
||||
if (command_line.HasSwitch(extensions::switches::kExtensionProcess)) {
|
||||
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr;
|
||||
if (!crash_handler)
|
||||
crash_handler = CreateCrashHandlerHost("extension");
|
||||
return crash_handler->GetDeathSignalSocket();
|
||||
}
|
||||
|
||||
std::string process_type =
|
||||
command_line.GetSwitchValueASCII(::switches::kProcessType);
|
||||
|
||||
if (process_type == ::switches::kRendererProcess) {
|
||||
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr;
|
||||
if (!crash_handler)
|
||||
crash_handler = CreateCrashHandlerHost(process_type);
|
||||
return crash_handler->GetDeathSignalSocket();
|
||||
}
|
||||
|
||||
if (process_type == ::switches::kPpapiPluginProcess) {
|
||||
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr;
|
||||
if (!crash_handler)
|
||||
crash_handler = CreateCrashHandlerHost(process_type);
|
||||
return crash_handler->GetDeathSignalSocket();
|
||||
}
|
||||
|
||||
if (process_type == ::switches::kGpuProcess) {
|
||||
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr;
|
||||
if (!crash_handler)
|
||||
crash_handler = CreateCrashHandlerHost(process_type);
|
||||
return crash_handler->GetDeathSignalSocket();
|
||||
}
|
||||
|
||||
if (process_type == ::switches::kUtilityProcess) {
|
||||
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr;
|
||||
if (!crash_handler)
|
||||
crash_handler = CreateCrashHandlerHost(process_type);
|
||||
return crash_handler->GetDeathSignalSocket();
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
#endif // defined(OS_LINUX)
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
|
@ -649,6 +720,23 @@ void ElectronBrowserClient::AppendExtraCommandLineSwitches(
|
|||
std::string process_type =
|
||||
command_line->GetSwitchValueASCII(::switches::kProcessType);
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
bool enable_crash_reporter = false;
|
||||
enable_crash_reporter = breakpad::IsCrashReporterEnabled();
|
||||
if (enable_crash_reporter) {
|
||||
command_line->AppendSwitch(::switches::kEnableCrashReporter);
|
||||
std::string switch_value;
|
||||
for (const auto& pair : api::crash_reporter::GetGlobalCrashKeys()) {
|
||||
if (!switch_value.empty())
|
||||
switch_value += ",";
|
||||
switch_value += pair.first;
|
||||
switch_value += "=";
|
||||
switch_value += pair.second;
|
||||
}
|
||||
command_line->AppendSwitchASCII(switches::kGlobalCrashKeys, switch_value);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (process_type == ::switches::kUtilityProcess ||
|
||||
process_type == ::switches::kRendererProcess) {
|
||||
// Copy following switches to child process.
|
||||
|
@ -1530,6 +1618,18 @@ void ElectronBrowserClient::RegisterBrowserInterfaceBindersForFrame(
|
|||
#endif
|
||||
}
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
void ElectronBrowserClient::GetAdditionalMappedFilesForChildProcess(
|
||||
const base::CommandLine& command_line,
|
||||
int child_process_id,
|
||||
content::PosixFileDescriptorInfo* mappings) {
|
||||
int crash_signal_fd = GetCrashSignalFD(command_line);
|
||||
if (crash_signal_fd >= 0) {
|
||||
mappings->Share(service_manager::kCrashDumpSignal, crash_signal_fd);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
std::unique_ptr<content::LoginDelegate>
|
||||
ElectronBrowserClient::CreateLoginDelegate(
|
||||
const net::AuthChallengeInfo& auth_info,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue