1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import("//build/config/features.gni")
8 compile_suid_client = is_linux
10 compile_credentials = is_linux
12 compile_seccomp_bpf_demo =
13 (is_linux && (cpu_arch == "x86" || cpu_arch == "x64"))
16 # We have two principal targets: sandbox and sandbox_linux_unittests
17 # All other targets are listed as dependencies.
18 # There is one notable exception: for historical reasons, chrome_sandbox is
19 # the setuid sandbox and is its own target.
26 if (compile_suid_client) {
27 deps += [ ":suid_sandbox_client" ]
29 if (use_seccomp_bpf) {
32 ":seccomp_bpf_helpers",
37 source_set("sandbox_linux_test_utils") {
40 "tests/sandbox_test_runner.cc",
41 "tests/sandbox_test_runner.h",
42 "tests/sandbox_test_runner_function_pointer.cc",
43 "tests/sandbox_test_runner_function_pointer.h",
44 "tests/test_utils.cc",
46 "tests/unit_tests.cc",
54 if (use_seccomp_bpf) {
56 "seccomp-bpf/bpf_tester_compatibility_delegate.h",
57 "seccomp-bpf/bpf_tests.h",
58 "seccomp-bpf/sandbox_bpf_test_runner.cc",
59 "seccomp-bpf/sandbox_bpf_test_runner.h",
67 # The main sandboxing test target.
68 test("sandbox_linux_unittests") {
70 "services/scoped_process_unittest.cc",
71 "services/thread_helpers_unittests.cc",
72 "services/yama_unittests.cc",
73 "syscall_broker/broker_process_unittest.cc",
75 "tests/scoped_temporary_file.cc",
76 "tests/scoped_temporary_file.h",
77 "tests/scoped_temporary_file_unittest.cc",
78 "tests/unit_tests_unittest.cc",
83 ":sandbox_linux_test_utils",
85 "//base/test:test_support",
90 # Don't use this on Android.
94 if (compile_suid_client) {
96 "suid/client/setuid_sandbox_client_unittest.cc",
99 if (use_seccomp_bpf) {
101 "bpf_dsl/bpf_dsl_more_unittest.cc",
102 "bpf_dsl/bpf_dsl_unittest.cc",
103 "bpf_dsl/cons_unittest.cc",
104 "seccomp-bpf-helpers/baseline_policy_unittest.cc",
105 "seccomp-bpf-helpers/syscall_parameters_restrictions_unittests.cc",
106 "seccomp-bpf/bpf_tests_unittest.cc",
107 "seccomp-bpf/codegen_unittest.cc",
108 "seccomp-bpf/errorcode_unittest.cc",
109 "seccomp-bpf/syscall_iterator_unittest.cc",
110 "seccomp-bpf/syscall_unittest.cc",
113 if (compile_credentials) {
115 "services/credentials_unittest.cc",
116 "services/unix_domain_socket_unittest.cc",
121 # TODO(GYP) Android version of this test.
123 # # This target is the shared library used by Android APK (i.e.
124 # # JNI-friendly) tests.
125 # "target_name": "sandbox_linux_jni_unittests",
127 # "sandbox_linux_test_sources.gypi",
129 # "type": "shared_library",
131 # [ "OS == "android"", {
133 # "../testing/android/native_test.gyp:native_test_native_code",
139 component("seccomp_bpf") {
141 "bpf_dsl/bpf_dsl.cc",
143 "bpf_dsl/bpf_dsl_forward.h",
144 "bpf_dsl/bpf_dsl_impl.h",
146 "bpf_dsl/dump_bpf.cc",
147 "bpf_dsl/dump_bpf.h",
150 "bpf_dsl/policy_compiler.cc",
151 "bpf_dsl/policy_compiler.h",
152 "bpf_dsl/trap_registry.h",
153 "seccomp-bpf/codegen.cc",
154 "seccomp-bpf/codegen.h",
155 "seccomp-bpf/die.cc",
157 "seccomp-bpf/errorcode.cc",
158 "seccomp-bpf/errorcode.h",
159 "seccomp-bpf/linux_seccomp.h",
160 "seccomp-bpf/sandbox_bpf.cc",
161 "seccomp-bpf/sandbox_bpf.h",
162 "seccomp-bpf/syscall.cc",
163 "seccomp-bpf/syscall.h",
164 "seccomp-bpf/syscall_iterator.cc",
165 "seccomp-bpf/syscall_iterator.h",
166 "seccomp-bpf/trap.cc",
167 "seccomp-bpf/trap.h",
168 "seccomp-bpf/verifier.cc",
169 "seccomp-bpf/verifier.h",
171 defines = [ "SANDBOX_IMPLEMENTATION" ]
174 ":sandbox_services_headers",
179 component("seccomp_bpf_helpers") {
181 "seccomp-bpf-helpers/baseline_policy.cc",
182 "seccomp-bpf-helpers/baseline_policy.h",
183 "seccomp-bpf-helpers/sigsys_handlers.cc",
184 "seccomp-bpf-helpers/sigsys_handlers.h",
185 "seccomp-bpf-helpers/syscall_parameters_restrictions.cc",
186 "seccomp-bpf-helpers/syscall_parameters_restrictions.h",
187 "seccomp-bpf-helpers/syscall_sets.cc",
188 "seccomp-bpf-helpers/syscall_sets.h",
190 defines = [ "SANDBOX_IMPLEMENTATION" ]
199 # The setuid sandbox for Linux.
200 executable("chrome_sandbox") {
202 "suid/common/sandbox.h",
203 "suid/common/suid_unsafe_environment_variables.h",
204 "suid/process_util.h",
205 "suid/process_util_linux.c",
212 # These files have a suspicious comparison.
213 # TODO fix this and re-enable this warning.
219 component("sandbox_services") {
221 "services/init_process_reaper.cc",
222 "services/init_process_reaper.h",
223 "services/scoped_process.cc",
224 "services/scoped_process.h",
225 "services/syscall_wrappers.cc",
226 "services/syscall_wrappers.h",
227 "services/thread_helpers.cc",
228 "services/thread_helpers.h",
231 "syscall_broker/broker_channel.cc",
232 "syscall_broker/broker_channel.h",
233 "syscall_broker/broker_client.cc",
234 "syscall_broker/broker_client.h",
235 "syscall_broker/broker_common.h",
236 "syscall_broker/broker_host.cc",
237 "syscall_broker/broker_host.h",
238 "syscall_broker/broker_policy.cc",
239 "syscall_broker/broker_policy.h",
240 "syscall_broker/broker_process.cc",
241 "syscall_broker/broker_process.h",
244 defines = [ "SANDBOX_IMPLEMENTATION" ]
246 if (compile_credentials) {
248 "services/credentials.cc",
249 "services/credentials.h",
251 # For capabilities.cc.
252 configs += [ "//build/config/linux:libcap" ]
260 source_set("sandbox_services_headers") {
262 "services/android_arm_ucontext.h",
263 "services/android_arm64_ucontext.h",
264 "services/android_futex.h",
265 "services/android_ucontext.h",
266 "services/android_i386_ucontext.h",
267 "services/arm_linux_syscalls.h",
268 "services/arm64_linux_syscalls.h",
269 "services/linux_syscalls.h",
270 "services/x86_32_linux_syscalls.h",
271 "services/x86_64_linux_syscalls.h",
275 # We make this its own target so that it does not interfere with our tests.
276 source_set("libc_urandom_override") {
278 "services/libc_urandom_override.cc",
279 "services/libc_urandom_override.h",
286 if (compile_suid_client) {
287 component("suid_sandbox_client") {
289 "suid/common/sandbox.h",
290 "suid/common/suid_unsafe_environment_variables.h",
291 "suid/client/setuid_sandbox_client.cc",
292 "suid/client/setuid_sandbox_client.h",
294 defines = [ "SANDBOX_IMPLEMENTATION" ]
304 # TODO(GYP) enable this. Needs an android_strip wrapper python script.
305 #action("sandbox_linux_unittests_stripped") {
306 # script = "android_stip.py"
308 # in_file = "$root_out_dir/sandbox_linux_unittests"
310 # out_file = "$root_out_dir/sandbox_linux_unittests_stripped"
311 # outputs = [ out_file ]
314 # rebase_path(in_file, root_build_dir),
315 # "-o", rebase_path(out_file, root_build_dir),
319 # ":sandbox_linux_unittests",
323 # TODO(GYP) convert this.
325 # 'target_name': 'sandbox_linux_jni_unittests_apk',
328 # 'test_suite_name': 'sandbox_linux_jni_unittests',
331 # 'sandbox_linux_jni_unittests',
333 # 'includes': [ '../../build/apk_test.gypi' ],