1 --- content/utility/utility_main.cc.orig 2022-07-22 17:30:31 UTC 2 +++ content/utility/utility_main.cc 3 @@ -31,17 +31,19 @@ 4 #include "third_party/icu/source/common/unicode/unistr.h" 5 #include "third_party/icu/source/i18n/unicode/timezone.h" 6 7 -#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) 8 +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD) 9 #include "content/utility/speech/speech_recognition_sandbox_hook_linux.h" 10 #if BUILDFLAG(ENABLE_PRINTING) 11 #include "printing/sandbox/print_backend_sandbox_hook_linux.h" 12 #endif 13 +#if !BUILDFLAG(IS_BSD) 14 #include "sandbox/policy/linux/sandbox_linux.h" 15 +#endif 16 #include "services/audio/audio_sandbox_hook_linux.h" 17 #include "services/network/network_sandbox_hook_linux.h" 18 #endif 19 20 -#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_ASH) 21 +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_BSD) 22 #include "gpu/config/gpu_info_collector.h" 23 #include "media/gpu/sandbox/hardware_video_decoding_sandbox_hook_linux.h" 24 25 @@ -50,6 +52,10 @@ 26 #include "third_party/angle/src/gpu_info_util/SystemInfo.h" // nogncheck 27 #endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_ASH) 28 29 +#if BUILDFLAG(IS_BSD) 30 +#include "sandbox/policy/openbsd/sandbox_openbsd.h" 31 +#endif 32 + 33 #if BUILDFLAG(IS_CHROMEOS_ASH) 34 #include "ash/services/ime/ime_sandbox_hook.h" 35 #include "chromeos/ash/components/assistant/buildflags.h" 36 @@ -129,7 +135,7 @@ int UtilityMain(MainFunctionParams parameters) { 37 } 38 } 39 40 -#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) 41 +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_BSD) 42 // Initializes the sandbox before any threads are created. 43 // TODO(jorgelo): move this after GTK initialization when we enable a strict 44 // Seccomp-BPF policy. 45 @@ -157,7 +163,7 @@ int UtilityMain(MainFunctionParams parameters) { 46 pre_sandbox_hook = base::BindOnce(&screen_ai::ScreenAIPreSandboxHook); 47 break; 48 #endif 49 -#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_ASH) 50 +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_BSD) 51 case sandbox::mojom::Sandbox::kHardwareVideoDecoding: 52 pre_sandbox_hook = 53 base::BindOnce(&media::HardwareVideoDecodingPreSandboxHook); 54 @@ -180,10 +186,11 @@ int UtilityMain(MainFunctionParams parameters) { 55 default: 56 break; 57 } 58 +#if !BUILDFLAG(IS_BSD) 59 if (!sandbox::policy::IsUnsandboxedSandboxType(sandbox_type) && 60 (parameters.zygote_child || !pre_sandbox_hook.is_null())) { 61 sandbox::policy::SandboxLinux::Options sandbox_options; 62 -#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_ASH) 63 +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_BSD) 64 if (sandbox_type == sandbox::mojom::Sandbox::kHardwareVideoDecoding) { 65 // The kHardwareVideoDecoding sandbox needs to know the GPU type in order 66 // to select the right policy. 67 @@ -196,6 +203,11 @@ int UtilityMain(MainFunctionParams parameters) { 68 sandbox::policy::Sandbox::Initialize( 69 sandbox_type, std::move(pre_sandbox_hook), sandbox_options); 70 } 71 +#else 72 + sandbox::policy::Sandbox::Initialize( 73 + sandbox_type, std::move(pre_sandbox_hook), 74 + sandbox::policy::SandboxLinux::Options()); 75 +#endif 76 #elif BUILDFLAG(IS_WIN) 77 g_utility_target_services = parameters.sandbox_info->target_services; 78 #endif 79