• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# The 'custom_fork' example demonstrates how to:
16# - create a custom fork-server, which will prepare and fork a sandboxee
17#   from the current process
18
19load("@com_google_sandboxed_api//sandboxed_api/bazel:build_defs.bzl", "sapi_platform_copts")
20
21package(default_visibility = [
22    "@com_google_sandboxed_api//sandboxed_api/sandbox2:__subpackages__",
23])
24
25licenses(["notice"])
26
27# Executor
28cc_binary(
29    name = "custom_fork_sandbox",
30    srcs = ["custom_fork_sandbox.cc"],
31    copts = sapi_platform_copts(),
32    data = [":custom_fork_bin"],
33    deps = [
34        "@com_google_absl//absl/flags:parse",
35        "@com_google_absl//absl/log",
36        "@com_google_absl//absl/log:check",
37        "@com_google_absl//absl/log:globals",
38        "@com_google_absl//absl/log:initialize",
39        "@com_google_absl//absl/time",
40        "@com_google_sandboxed_api//sandboxed_api:config",
41        "@com_google_sandboxed_api//sandboxed_api/sandbox2",
42        "@com_google_sandboxed_api//sandboxed_api/sandbox2:comms",
43        "@com_google_sandboxed_api//sandboxed_api/sandbox2:fork_client",
44        "@com_google_sandboxed_api//sandboxed_api/util:runfiles",
45    ],
46)
47
48# Sandboxee
49cc_binary(
50    name = "custom_fork_bin",
51    srcs = ["custom_fork_bin.cc"],
52    copts = sapi_platform_copts(),
53    deps = [
54        "@com_google_absl//absl/base:log_severity",
55        "@com_google_absl//absl/flags:parse",
56        "@com_google_absl//absl/log:globals",
57        "@com_google_absl//absl/log:initialize",
58        "@com_google_sandboxed_api//sandboxed_api/sandbox2:comms",
59        "@com_google_sandboxed_api//sandboxed_api/sandbox2:forkingclient",
60        "@com_google_sandboxed_api//sandboxed_api/util:raw_logging",
61    ],
62)
63
64# Test
65sh_test(
66    name = "custom_fork_sandbox_test",
67    srcs = ["custom_fork_sandbox_test.sh"],
68    data = [":custom_fork_sandbox"],
69    tags = ["no_qemu_user_mode"],
70)
71