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/broker_process_unittest.cc",
71 "services/scoped_process_unittest.cc",
72 "services/thread_helpers_unittests.cc",
73 "services/yama_unittests.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",
144 "seccomp-bpf/basicblock.cc",
145 "seccomp-bpf/basicblock.h",
146 "seccomp-bpf/codegen.cc",
147 "seccomp-bpf/codegen.h",
148 "seccomp-bpf/die.cc",
150 "seccomp-bpf/errorcode.cc",
151 "seccomp-bpf/errorcode.h",
152 "seccomp-bpf/instruction.h",
153 "seccomp-bpf/linux_seccomp.h",
154 "seccomp-bpf/sandbox_bpf.cc",
155 "seccomp-bpf/sandbox_bpf.h",
156 "seccomp-bpf/sandbox_bpf_policy.cc",
157 "seccomp-bpf/sandbox_bpf_policy.h",
158 "seccomp-bpf/syscall.cc",
159 "seccomp-bpf/syscall.h",
160 "seccomp-bpf/syscall_iterator.cc",
161 "seccomp-bpf/syscall_iterator.h",
162 "seccomp-bpf/trap.cc",
163 "seccomp-bpf/trap.h",
164 "seccomp-bpf/verifier.cc",
165 "seccomp-bpf/verifier.h",
167 defines = [ "SANDBOX_IMPLEMENTATION" ]
170 ":sandbox_services_headers",
175 component("seccomp_bpf_helpers") {
177 "seccomp-bpf-helpers/baseline_policy.cc",
178 "seccomp-bpf-helpers/baseline_policy.h",
179 "seccomp-bpf-helpers/sigsys_handlers.cc",
180 "seccomp-bpf-helpers/sigsys_handlers.h",
181 "seccomp-bpf-helpers/syscall_parameters_restrictions.cc",
182 "seccomp-bpf-helpers/syscall_parameters_restrictions.h",
183 "seccomp-bpf-helpers/syscall_sets.cc",
184 "seccomp-bpf-helpers/syscall_sets.h",
186 defines = [ "SANDBOX_IMPLEMENTATION" ]
195 # The setuid sandbox for Linux.
196 executable("chrome_sandbox") {
198 "suid/common/sandbox.h",
199 "suid/common/suid_unsafe_environment_variables.h",
200 "suid/process_util.h",
201 "suid/process_util_linux.c",
208 # These files have a suspicious comparison.
209 # TODO fix this and re-enable this warning.
215 component("sandbox_services") {
217 "services/broker_process.cc",
218 "services/broker_process.h",
219 "services/init_process_reaper.cc",
220 "services/init_process_reaper.h",
221 "services/scoped_process.cc",
222 "services/scoped_process.h",
223 "services/thread_helpers.cc",
224 "services/thread_helpers.h",
229 defines = [ "SANDBOX_IMPLEMENTATION" ]
231 if (compile_credentials) {
233 "services/credentials.cc",
234 "services/credentials.h",
236 # For capabilities.cc.
237 configs += [ "//build/config/linux:libcap" ]
245 source_set("sandbox_services_headers") {
247 "services/android_arm_ucontext.h",
248 "services/android_arm64_ucontext.h",
249 "services/android_futex.h",
250 "services/android_ucontext.h",
251 "services/android_i386_ucontext.h",
252 "services/arm_linux_syscalls.h",
253 "services/arm64_linux_syscalls.h",
254 "services/linux_syscalls.h",
255 "services/x86_32_linux_syscalls.h",
256 "services/x86_64_linux_syscalls.h",
260 # We make this its own target so that it does not interfere with our tests.
261 source_set("libc_urandom_override") {
263 "services/libc_urandom_override.cc",
264 "services/libc_urandom_override.h",
271 if (compile_suid_client) {
272 component("suid_sandbox_client") {
274 "suid/common/sandbox.h",
275 "suid/common/suid_unsafe_environment_variables.h",
276 "suid/client/setuid_sandbox_client.cc",
277 "suid/client/setuid_sandbox_client.h",
279 defines = [ "SANDBOX_IMPLEMENTATION" ]
289 # TODO(GYP) enable this. Needs an android_strip wrapper python script.
290 #action("sandbox_linux_unittests_stripped") {
291 # script = "android_stip.py"
293 # in_file = "$root_out_dir/sandbox_linux_unittests"
295 # out_file = "$root_out_dir/sandbox_linux_unittests_stripped"
296 # outputs = [ out_file ]
299 # rebase_path(in_file, root_build_dir),
300 # "-o", rebase_path(out_file, root_build_dir),
304 # ":sandbox_linux_unittests",
308 # TODO(GYP) convert this.
310 # 'target_name': 'sandbox_linux_jni_unittests_apk',
313 # 'test_suite_name': 'sandbox_linux_jni_unittests',
316 # 'sandbox_linux_jni_unittests',
318 # 'includes': [ '../../build/apk_test.gypi' ],