BUILD.gn 3.2 KB
Newer Older
X
<feat>  
xiacong 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import(
    "//base/startup/init/services/modules/seccomp/scripts/seccomp_policy_fixer.gni")
import("//build/config/clang/clang.gni")
import("//build/ohos.gni")
import("//build/ohos/kernel/kernel.gni")

INIT_PART = "init"
21 22 23 24 25 26 27 28
declare_args() {
  appspawn_featrue = false

  if (defined(global_parts_info) &&
      defined(global_parts_info.startup_appspawn)) {
    appspawn_featrue = true
  }
}
X
<feat>  
xiacong 已提交
29

X
<feat>  
xiacong 已提交
30 31 32 33 34 35
if (build_variant == "root") {
  seccomp_enable_debug = true
} else {
  seccomp_enable_debug = false
}

X
<feat>  
xiacong 已提交
36
ohos_prebuilt_seccomp("system_filter") {
37 38 39 40
  sources = [ "seccomp_policy/system.seccomp.policy" ]

  filtername = "system"
  process_type = "system"
X
<feat>  
xiacong 已提交
41 42 43 44 45

  part_name = INIT_PART
  subsystem_name = "startup"

  install_enable = true
X
<fix>  
xiacong 已提交
46
  install_images = [ "system" ]
X
<feat>  
xiacong 已提交
47 48 49
}

ohos_prebuilt_seccomp("appspawn_filter") {
50 51 52 53
  sources = [ "seccomp_policy/spawn.seccomp.policy" ]

  filtername = "appspawn"
  process_type = "system"
X
<feat>  
xiacong 已提交
54 55 56 57 58

  part_name = INIT_PART
  subsystem_name = "startup"

  install_enable = true
X
<feat>  
xiacong 已提交
59
  install_images = [ "system" ]
X
<feat>  
xiacong 已提交
60 61
}

62
ohos_prebuilt_seccomp("nwebspawn_filter") {
63 64 65 66
  sources = [ "seccomp_policy/renderer.seccomp.policy" ]

  filtername = "nwebspawn"
  process_type = "app"
67 68 69 70 71

  part_name = INIT_PART
  subsystem_name = "startup"

  install_enable = true
X
<feat>  
xiacong 已提交
72 73 74 75
  install_images = [ "system" ]
}

ohos_prebuilt_seccomp("app_filter") {
76 77 78 79
  sources = [ "seccomp_policy/app.seccomp.policy" ]

  filtername = "app"
  process_type = "app"
X
<feat>  
xiacong 已提交
80 81 82 83 84 85

  part_name = INIT_PART
  subsystem_name = "startup"

  install_enable = true
  install_images = [ "system" ]
86 87
}

Q
qy136 已提交
88 89 90 91 92 93 94 95 96 97 98 99 100
ohos_prebuilt_seccomp("updater_filter") {
  sources = [ "seccomp_policy/updater.seccomp.policy" ]

  filtername = "updater"
  process_type = "system"

  part_name = INIT_PART
  subsystem_name = "startup"

  install_enable = true
  install_images = [ "updater" ]
}

X
<fix>  
xiacong 已提交
101
config("libseccomp_static_config") {
X
<feat>  
xiacong 已提交
102
  include_dirs = [
103 104
    "..",
    "../../../interfaces/innerkits/seccomp/include",
X
<feat>  
xiacong 已提交
105
  ]
X
<feat>  
xiacong 已提交
106 107 108 109 110 111 112 113 114

  if (seccomp_enable_debug) {
    include_dirs += [
      "../../../services/include",
      "../../../services/include/param",
    ]

    defines = [ "WITH_SECCOMP_DEBUG" ]
  }
X
<fix>  
xiacong 已提交
115
}
X
<feat>  
xiacong 已提交
116

X
<fix>  
xiacong 已提交
117 118 119 120
ohos_source_set("libseccomp_static") {
  sources = [
    "seccomp_policy.c",
    "seccomp_policy_static.c",
X
<feat>  
xiacong 已提交
121
  ]
X
<fix>  
xiacong 已提交
122 123
  public_configs = [
    ":libseccomp_static_config",
124 125 126 127 128 129
    "../../../interfaces/innerkits/init_module_engine:init_module_engine_exported_config",
  ]

  external_deps = [
    "bounds_checking_function:libsec_shared",
    "config_policy:configpolicy_util",
X
<feat>  
xiacong 已提交
130 131 132
  ]
}

X
<fix>  
xiacong 已提交
133 134 135 136
group("seccomp_filter") {
  deps = [
    ":app_filter",
    ":system_filter",
Q
qy136 已提交
137
    ":updater_filter",
X
<feat>  
xiacong 已提交
138
  ]
139 140 141 142 143 144
  if (appspawn_featrue) {
    deps += [
      ":appspawn_filter",
      ":nwebspawn_filter",
    ]
  }
X
<feat>  
xiacong 已提交
145
}